Commit f0cc1b90 authored by Robert Ricci's avatar Robert Ricci
Browse files

Handle the case of links between a switch and a node - I thought

I had disallowed this in the parser, but I hadn't thought about
LAN nodes, which typically get assigned to switches. So, handle
this case correctly.

We still do *not* handle links between two switches (eg. directly
between two LANs). However, what the semantics of this should be
is totally unclear - do we use the *whole* interswtich bandwidth?
Since we are not likely to hit this in our regular usage, we punt
for now with an error if it happens.

Also, remove the parser check, since we now handle correctly the
case it was trying to disallow.
parent eac6b811
......@@ -321,13 +321,6 @@ int parse_top(tb_vgraph &vg, istream& input)
top_error("Auto-assigning bandwidth on trivial or emulated links"
" not allowed!");
// Some sanity checks: this is also illegal, but would be easier to fix
// Also: nasty harcoding of "switch"
if (l->delay_info.adjust_to_native_bandwidth &&
(vnode1->type == "switch" || vnode2->type == "switch")) {
top_error("Auto-assigning bandwidth on links to switches"
" not allowed!");
} else if (command == string("make-vclass")) {
......@@ -382,17 +382,40 @@ float find_link_resolutions(resolution_vector &resolutions, pvertex pv,
// interface, we have to look up interface speeds on both ends.
int bandwidth;
if (vlink->delay_info.adjust_to_native_bandwidth) {
// Note: It shouldn't be possible to get here without first or second
// being set - the parser disallows links to switches from using
// auto-adjusting bandwidths.
// Grab the actual plink objects for both pedges
tb_plink *first_plink = get(pedge_pmap,first);
tb_plink *second_plink = get(pedge_pmap,second);
// We use the minimum bandwidth of both endpoints
bandwidth = min(first_plink->delay_info.bandwidth,
// Grab the actual plink objects for both pedges - it's possible for
// one or both to be missing if we're linking directly to a switch
// (as with a LAN)
tb_plink *first_plink = NULL;
tb_plink *second_plink = NULL;
if (first_link) {
first_plink = get(pedge_pmap,first);
if (second_link) {
second_plink = get(pedge_pmap,second);
if (first_plink != NULL && second_plink != NULL) {
// If both endpoints are not switches, we use the minimum
// bandwidth
bandwidth = min(first_plink->delay_info.bandwidth,
} else if (first_plink == NULL) {
// If one end is a switch, use the bandwidth from the other
// end
bandwidth = second_plink->delay_info.bandwidth;
} else if (second_plink == NULL) {
bandwidth = first_plink->delay_info.bandwidth;
} else {
// Both endpoints are switches! (eg. this might be a link between
// two LANs): It is not at all clear what the right semantics
// for this would be, and unfortunately, we can't catch this
// earlier. So, exiting with an error is crappy, but it's
// unlikely to happen in our regular use, and it's the best we
// can do.
cerr << "*** Using bandwidth adjustment on virutal links " <<
"between switches not allowed " << endl;
} else {
// If not auto-adjusting, just use the specified bandwidth
bandwidth = vlink->delay_info.bandwidth;
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