Commit c1bb6937 authored by Tarun Prabhu's avatar Tarun Prabhu

Changes to deal with multiple link properties on a link more correctly

than earlier.
parent 00f8abf4
......@@ -531,9 +531,20 @@ bool populate_links(DOMElement *root, tb_pgraph &pg, tb_sgraph &sg,
link_characteristics characteristics
= rspecParser->readLinkCharacteristics (elt, count);
if (count == RSPEC_ASYMMETRIC_LINK) {
cout << "*** Disallowed asymmetric link found on " << componentId
<< ". Links must be symmetric" << endl;
is_ok = false;
}
else if (count > 2) {
cout << "*** Too many link properties found on " << componentId
<< ". Max. allowed: 2" << endl;
is_ok = false;
}
int bandwidth = characteristics.bandwidth;
int latency = characteristics.latency;
double packetLoss = characteristics.packetLoss;
int packetLoss = characteristics.packetLoss;
/*
* Find the nodes in the existing data structures
......
......@@ -479,11 +479,17 @@ bool populate_link (DOMElement* elt,
*/
struct link_characteristics characteristics
= rspecParser->readLinkCharacteristics(elt, count);
if (count != 1) {
cout << "*** Incorrect number of link properties specified ("
<< count << " on " << virtualId <<". Allowed 1 " << endl;
if (count == RSPEC_ASYMMETRIC_LINK) {
cout << "*** Disallowed asymmetric link specified on " << virtualId
<<". Links must be symmetric" << endl;
return false;
}
else if (count > 2) {
cout << "Too many link properties found on " << virtualId
<< ". Max. allowed: 2" << endl;
return false;
}
int bandwidth = characteristics.bandwidth;
int latency = characteristics.latency;
double packetLoss = characteristics.packetLoss;
......
......@@ -30,6 +30,8 @@
#define RSPEC_ERROR_UNSEEN_NODEIFACE_SRC -2
#define RSPEC_ERROR_UNSEEN_NODEIFACE_DST -3
#define RSPEC_ASYMMETRIC_LINK -1
struct node_type
{
std::string typeName;
......
......@@ -96,27 +96,66 @@ rspec_parser_v2 :: readLinkCharacteristics (const DOMElement* link,
DOMNodeList* properties = link->getElementsByTagName(XStr("property").x());
string strBw = "", strLat = "", strLoss = "";
int bandwidth = 0, latency = 0;
float packetLoss = 0.0;
bool isOk = false;
bool hasBandwidth, hasLatency, hasPacketLoss;
count = properties->getLength();
if (count > 0) {
// Read only from the first property and ignore the rest
DOMElement* property = dynamic_cast<DOMElement*>(properties->item(0));
strBw = this->getAttribute(property, "capacity", hasBandwidth);
strLat = this->getAttribute(property, "latency", hasLatency);
strLoss = this->getAttribute(property, "packet_loss", hasPacketLoss);
int bandwidth = 0, latency = 0;
float packetLoss = 0.0;
if (!hasBandwidth)
if (!hasBandwidth) {
bandwidth = defaultBandwidth;
else if(strBw == "unlimited")
}
else if(strBw == "unlimited") {
bandwidth = unlimitedBandwidth;
else
}
else {
bandwidth = atoi(strBw.c_str());
}
latency = hasLatency ? atoi(strLat.c_str()) : 0 ;
packetLoss = hasPacketLoss ? atof(strLoss.c_str()) : 0.0;
if (count > 1) {
int revBandwidth = 0, revLatency = 0;
float revPacketLoss = 0.0;
DOMElement* property = dynamic_cast<DOMElement*>(properties->item(1));
strBw = this->getAttribute(property, "capacity", hasBandwidth);
strLat = this->getAttribute(property, "latency", hasLatency);
strLoss = this->getAttribute(property, "packet_loss", hasPacketLoss);
if (!hasBandwidth) {
revBandwidth = defaultBandwidth;
}
else if(strBw == "unlimited") {
revBandwidth = unlimitedBandwidth;
}
else {
revBandwidth = atoi(strBw.c_str());
}
revLatency = hasLatency ? atoi(strLat.c_str()) : 0 ;
revPacketLoss = hasPacketLoss ? atof(strLoss.c_str()) : 0.0;
if (bandwidth == revBandwidth
&& latency == revLatency
&& packetLoss == revPacketLoss) {
isOk = true;
}
}
}
if (!isOk) {
count = RSPEC_ASYMMETRIC_LINK;
}
struct link_characteristics rv = {bandwidth, latency, packetLoss};
return rv;
}
......
......@@ -7722,6 +7722,14 @@ sub processLinkRspec ($$$$)
$property->setAttribute('capacity', $link->{'capacity'});
$property->setAttribute('latency', $link->{'latency'});
$property->setAttribute('packet_loss', $link->{'packet_loss'});
# The reverse link
$property = addNodeRspec($doc, $rspeclink, 'property');
$property->setAttribute('source_id', $link->{'interface_ref'}->[1]);
$property->setAttribute('dest_id', $link->{'interface_ref'}->[0]);
$property->setAttribute('capacity', $link->{'capacity'});
$property->setAttribute('latency', $link->{'latency'});
$property->setAttribute('packet_loss', $link->{'packet_loss'});
}
sub processVClassRspec($$$$)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment