Commit af58871e authored by Leigh Stoller's avatar Leigh Stoller

The last of the Kbps changes. We operate in terms of Kbps now, both in

the virtual topology and the physical topology. See equiv changes to
constants in ptopgen. The interface_types table is also changed to
reflect Kbps instead of Mbps.
parent a022a3eb
...@@ -17,10 +17,35 @@ ...@@ -17,10 +17,35 @@
# maxrun is maximum number of times we run assign. # maxrun is maximum number of times we run assign.
# delaywithswitch if 1 will use the switch to delay when possible. Currently # delaywithswitch if 1 will use the switch to delay when possible. Currently
# this only works for 10mbit links. # this only works for 10mbit links.
$delaythresh = 3; $delaythresh = 2;
$maxrun = 20; $maxrun = 20;
$delaywithswitch=0; $delaywithswitch=0;
#
# Some handy constants. Speed in Mbits/sec and Kbits/sec units.
# The conversion routine is to make explicit that we operate with two
# different sets of units. One is the topology, which is in Kbps now.
# The second is the physical description, which has been changed to
# Kbps in the DB (and in ptopgen).
#
# Its probably a good idea to leave portbw (current_speed) in Mbs, since
# those numbers are used at the switch and the interfaces, which really
# only think in Mbps.
#
my $S10Mbs = 10;
my $S100Mbs = 100;
my $S10Kbs = 10000;
my $S100Kbs = 100000;
sub BWConvert($) {
#
# Use this if physical units are in Mbs (used to be).
#
#my $bw = $_[0] / 1000;
my $bw = $_[0];
return $bw;
}
$DELAYCAPACITY = @DELAYCAPACITY@; $DELAYCAPACITY = @DELAYCAPACITY@;
$TBROOT = "@prefix@"; $TBROOT = "@prefix@";
$ENV{'PATH'} = "/usr/bin:$TBROOT/libexec:$TBROOT/sbin:$TBROOT/bin"; $ENV{'PATH'} = "/usr/bin:$TBROOT/libexec:$TBROOT/sbin:$TBROOT/bin";
...@@ -105,9 +130,10 @@ sub printdb { ...@@ -105,9 +130,10 @@ sub printdb {
# interfacespeed is indexed by type and contains the bandwidth. # interfacespeed is indexed by type and contains the bandwidth.
# delaynodes is indexed by link name and contains [delay,bw,loss] # delaynodes is indexed by link name and contains [delay,bw,loss]
# portbw is indexed by virtual nodeport and contains the bandwidth # portbw is indexed by virtual nodeport and contains the bandwidth
# of that port. Note that the bandwidth of a port is one of 100000 (100Mbs) # of that port. Note that port bandwidth in the interfaces table is
# or 10000 (10 Mbs). For LANs with other bandwidths the port speed will be # left in Mbps units for now. Thats inconsistent, I know. For LANs with
# 100 and a delay node will be inserted. # other bandwidths the port speed will be 100 and a delay node will
# be inserted.
# #
# Delay node names: # Delay node names:
# delay nodes are named tbdelayXX N > 2 # delay nodes are named tbdelayXX N > 2
...@@ -175,10 +201,20 @@ while (($vname,$member,$delay,$bandwidth,$lossrate) = $result->fetchrow_array) { ...@@ -175,10 +201,20 @@ while (($vname,$member,$delay,$bandwidth,$lossrate) = $result->fetchrow_array) {
push(@{$lans{$vname}},$member); push(@{$lans{$vname}},$member);
$delayinfo{"$vname:$member"} = [$delay,$bandwidth,$lossrate]; $delayinfo{"$vname:$member"} = [$delay,$bandwidth,$lossrate];
($node,$port) = split(":",$member); ($node,$port) = split(":",$member);
if ($bandwidth == 10000) { #
$portbw{$member} = 10; # XXX - Whenever a delay node is inserted, port speeds are set to
# 100Mbs, even if they requested exactly 10Mbs. This is a
# simplification. At some point we might want to force all the
# ports along the way to 10Mbs, and have the delay node worry
# about delay only, and not bandwidth. That will be harder to
# to do in this mess. See companion XXX below where the delays
# table is initialized. Initially, we set the speed to 10Mbs,
# if a delay node is insterted below, it resets this to 100Mbs.
#
if ($bandwidth == $S10Kbs && $delaywithswitch) {
$portbw{$member} = $S10Mbs;
} else { } else {
$portbw{$member} = 100; $portbw{$member} = $S100Mbs;
} }
push(@{$nodelans{$node}},"$port:$vname"); push(@{$nodelans{$node}},"$port:$vname");
printdb " portbw of $member = $portbw{$member}\n"; printdb " portbw of $member = $portbw{$member}\n";
...@@ -207,7 +243,7 @@ foreach $lan (keys(%lans)) { ...@@ -207,7 +243,7 @@ foreach $lan (keys(%lans)) {
join(" ",@$sharks) . ")\n"; join(" ",@$sharks) . ")\n";
$sharkshelfid++; $sharkshelfid++;
$sharkshelves{$shelfid} = $sharks; $sharkshelves{$shelfid} = $sharks;
$delayinfo{"$lan:$shelfid:uplink"} = [0,100000,0.0]; $delayinfo{"$lan:$shelfid:uplink"} = [0,$S100Kbs,0.0];
push(@$realmembers,"$shelfid:uplink"); push(@$realmembers,"$shelfid:uplink");
$nodes{$shelfid} = "shark-shelf"; $nodes{$shelfid} = "shark-shelf";
} }
...@@ -216,7 +252,7 @@ foreach $lan (keys(%lans)) { ...@@ -216,7 +252,7 @@ foreach $lan (keys(%lans)) {
# End shark hack # End shark hack
# Open the TOP file # Open the TOP file
$topfile = "$pid-$eid-$$.top"; $topfile = "$eid.top";
open(TOPFILE,"> $topfile") || do { open(TOPFILE,"> $topfile") || do {
print STDERR "$0: *** Could not open $topfile.\n"; print STDERR "$0: *** Could not open $topfile.\n";
exit(1); exit(1);
...@@ -261,10 +297,10 @@ foreach $lan (keys(%lans)) { ...@@ -261,10 +297,10 @@ foreach $lan (keys(%lans)) {
$loss = 1-(1-$loss0)*(1-$loss1); $loss = 1-(1-$loss0)*(1-$loss1);
$bw = &min($bw0,$bw1); $bw = &min($bw0,$bw1);
$bandwidth = &getbandwidth(&min($bw0,$bw1)); $bandwidth = &getbandwidth(&min($bw0,$bw1));
if (($delay > $delaythresh) || if (($delay >= $delaythresh) ||
(($bw != 100000) && ($bw != 10000)) || (($bw != $S100Kbs) && ($bw != $S10Kbs)) ||
(($delaywithswitch == 0) && (($delaywithswitch == 0) &&
(($bw != 100000) && (($sharks == 0) || ($nonsharks > 1)))) || (($bw != $S100Kbs) && (($sharks == 0) || ($nonsharks > 1)))) ||
($loss != 0)) { ($loss != 0)) {
$delayname = "tbsdelay$delayid"; $delayname = "tbsdelay$delayid";
$delaynodes{"linksdelaysrc/$lan"} = [$delay,$bw,$loss]; $delaynodes{"linksdelaysrc/$lan"} = [$delay,$bw,$loss];
...@@ -277,6 +313,14 @@ foreach $lan (keys(%lans)) { ...@@ -277,6 +313,14 @@ foreach $lan (keys(%lans)) {
. " $bandwidth\n"; . " $bandwidth\n";
print TOPFILE "link linksdelaydst/$lan $node1 $delayname" print TOPFILE "link linksdelaydst/$lan $node1 $delayname"
. " $bandwidth\n"; . " $bandwidth\n";
#
# Ports are set to 100Mbs when a link gets a delay node.
# This can override initialization above cause we could not
# tell earlier if the link was going to get a real delay node
# or just a delaywithswitch.
#
$portbw{$nodeport0} = $S100Mbs;
$portbw{$nodeport1} = $S100Mbs;
} else { } else {
print TOPFILE "link linksimple/$lan $node0 $node1 $bandwidth\n"; print TOPFILE "link linksimple/$lan $node0 $node1 $bandwidth\n";
} }
...@@ -289,10 +333,11 @@ foreach $lan (keys(%lans)) { ...@@ -289,10 +333,11 @@ foreach $lan (keys(%lans)) {
($node) = (split(":",$member))[0]; ($node) = (split(":",$member))[0];
# XXX The expression below should be modified for better bandwidth support. # XXX The expression below should be modified for better bandwidth support.
# Probably needs to happen post assign somehow. # Probably needs to happen post assign somehow.
if (($delay > $delaythresh) || if (($delay >= $delaythresh) ||
(($bw != 100000) && ($bw != 10000)) || (($bw != $S100Kbs) && ($bw != $S10Kbs)) ||
(($delaywithswitch == 0) && (($delaywithswitch == 0) &&
(($bw != 100000) && (($sharks == 0) || ($nonsharks > 1)))) || (($bw != $S100Kbs) && (($sharks == 0) ||
($nonsharks > 1)))) ||
($loss != 0)) { ($loss != 0)) {
$delayname = "tbdelay$delayid"; $delayname = "tbdelay$delayid";
$delaynodes{"linkdelaysrc/$lan/$member"} = [$delay,$bw,$loss]; $delaynodes{"linkdelaysrc/$lan/$member"} = [$delay,$bw,$loss];
...@@ -305,6 +350,13 @@ foreach $lan (keys(%lans)) { ...@@ -305,6 +350,13 @@ foreach $lan (keys(%lans)) {
" $node $delayname $bandwidth\n"; " $node $delayname $bandwidth\n";
print TOPFILE "link linkdelaydst/$lan/$member" . print TOPFILE "link linkdelaydst/$lan/$member" .
" lan/$lan $delayname $bandwidth\n"; " lan/$lan $delayname $bandwidth\n";
#
# Port is set to 100Mbs when the link gets a delay node.
# This can override initialization above cause we could not
# tell earlier if the link was going to get a real delay node
# or just a delaywithswitch.
#
$portbw{$member} = $S100Mbs;
} else { } else {
print TOPFILE "link linklan/$lan/$member $node lan/$lan" . print TOPFILE "link linklan/$lan/$member $node lan/$lan" .
" $bandwidth\n"; " $bandwidth\n";
...@@ -759,7 +811,23 @@ foreach $delay (keys(%delays)) { ...@@ -759,7 +811,23 @@ foreach $delay (keys(%delays)) {
" values ('$pid','$eid','$pnode','$vname','$int0','$int1'". " values ('$pid','$eid','$pnode','$vname','$int0','$int1'".
",$pipe0,$delay,$bandwidth,$lossrate". ",$pipe0,$delay,$bandwidth,$lossrate".
",$pipe1,$delay,$bandwidth,$lossrate)"); ",$pipe1,$delay,$bandwidth,$lossrate)");
#
# XXX - Whenever a delay node is inserted, port speeds are set to
# 100Mbs on the delay node ports. This is to ensure that
# they get a valid number instead of something left over, but
# also because this is a simplification.
# At some point we might want to force all the
# ports along the way to 10Mbs, and have the delay node worry
# about delay only, and not bandwidth. That will be harder to
# to do in this mess. See companion XXX above where portbw hash
# is set.
#
DBQueryFatal("update interfaces set " .
"current_speed='$S100Mbs' " .
"where node_id='$pnode' and ".
"(iface='$int0' or iface='$int1')");
} }
DBQueryFatal("delete from portmap where pid=\"$pid\" and eid=\"$eid\""); DBQueryFatal("delete from portmap where pid=\"$pid\" and eid=\"$eid\"");
foreach $vnodeport (keys(%portmap)) { foreach $vnodeport (keys(%portmap)) {
($vnode,$vport) = split(":",$vnodeport); ($vnode,$vport) = split(":",$vnodeport);
...@@ -886,11 +954,8 @@ sub min { ...@@ -886,11 +954,8 @@ sub min {
# getbandwidth(bw) # getbandwidth(bw)
# Returns the lowest ok bandwidth that is greater than or equal to # Returns the lowest ok bandwidth that is greater than or equal to
# the one passed. # the one passed.
#
# XXX The targetbandwidth is in Kbs, but interface types in Mbs.
#
sub getbandwidth { sub getbandwidth {
my $targetbandwidth= $_[0] / 1000; my $targetbandwidth= BWConvert($_[0]);
my $bandwidth; my $bandwidth;
my $best = 10000000000; my $best = 10000000000;
foreach $bandwidth (keys(%okbandwidths)) { foreach $bandwidth (keys(%okbandwidths)) {
......
...@@ -2,11 +2,6 @@ ...@@ -2,11 +2,6 @@
use English; use English;
use Getopt::Std; use Getopt::Std;
# Settings - Change these to your particular network.
# Switch interface speed - In Mbps
$switch_speed = 100;
sub usage() sub usage()
{ {
print STDOUT "Usage: ptopgen [-s switch]\n"; print STDOUT "Usage: ptopgen [-s switch]\n";
...@@ -14,6 +9,32 @@ sub usage() ...@@ -14,6 +9,32 @@ sub usage()
} }
my $optlist = "s:"; my $optlist = "s:";
# Settings - Change these to your particular network.
#
# Explanation from Mac:
#
# These are for the imaginary "lan nodes". Internally the way we map
# lans is as a bunch of machines connected in a star to a "lan node"
# that has infinite bw basically, and an infinite number of connections
# available to it. So the first big number is BW (100Gbps), and the
# 1000 means it has 1000 connections to the switch. That number is
# plenty high as it is, since our limit on one switch is under 400.
#
# Speed in in Kbs!
#
my $lannode_switch2switch_speed = 100000000;
my $lannode_switch2switch_links = 1000;
#
# Also bogus. The interfaces table does not hold entries for the switch
# side of each link. It will have to at some point, when we have something
# other than 100Mbs ports (say, gbit ports).
#
# Speed in in Kbs!
#
my $default_switchport_speed = 100000;
###################################################################### ######################################################################
my $TBROOT = "@prefix@"; my $TBROOT = "@prefix@";
...@@ -165,8 +186,9 @@ print $sharklinks; ...@@ -165,8 +186,9 @@ print $sharklinks;
foreach $switch (keys(%used_switches)) { foreach $switch (keys(%used_switches)) {
for ($i = 0;$i <= 20;$i++) { for ($i = 0;$i <= 20;$i++) {
print "node lan-$switch-$i lan:1\n"; print "node lan-$switch-$i lan:1\n";
print "link link-lan-$switch-$i lan-$switch-${i}:lan-$switch-$i" . print "link link-lan-$switch-$i lan-$switch-${i}:lan-$switch-$i " .
" $switch 100000 1000\n"; "$switch ".
"$lannode_switch2switch_speed $lannode_switch2switch_links\n";
} }
} }
...@@ -192,7 +214,8 @@ sub get_ifacebw { ...@@ -192,7 +214,8 @@ sub get_ifacebw {
($node,$card,$port) = @_; ($node,$card,$port) = @_;
if (defined($interfacetypes{"$node:$card:$port"})) { if (defined($interfacetypes{"$node:$card:$port"})) {
return $interfacespeeds{$interfacetypes{"$node:$card:$port"}}; return $interfacespeeds{$interfacetypes{"$node:$card:$port"}};
} else { }
return $switch_speed; else {
return $default_switchport_speed;
} }
} }
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