Commit cab46455 authored by Leigh B. Stoller's avatar Leigh B. Stoller
Browse files

Minor changes to convert delays from ints to floats in the DB. Chris

did the lanlink change. assign_wrapper does not really need any
changes at all, but I dropped a comment in. The only real change is
needed in the client side to convert a floating point from tmcd, into
an int to give to ipfw. Rather cheesy too, given that Perl does not
have a real conversion function (int() truncates).
parent 236c99cf
......@@ -14,6 +14,7 @@
# Settings
# delaythresh is the maximum delay in ms above which a delay node is needed.
# (Note that the DB represents delays as floating point numbers)
# maxrun is maximum number of times we run assign.
# delaywithswitch if 1 will use the switch to delay when possible. Currently
# this only works for 10mbit links.
......@@ -27,7 +27,7 @@ LanLink instproc init {s nodes bw d} {
foreach node $nodes {
set nodepair [list $node [$node add_lanlink $self]]
set bandwidth($nodepair) $bw
set delay($nodepair) [expr $d / 2]
set delay($nodepair) [expr $d / 2.0]
set loss($nodepair) 0
lappend nodelist $nodepair
......@@ -271,13 +271,13 @@ sub dodelays ()
$count = 69;
foreach $delay (@delays) {
$pat = q(DELAY INT0=([\d\w]+) INT1=([\d\w]+) );
$pat .= q(PIPE0=(\d+) DELAY0=(\d+) BW0=([\d\.]+) PLR0=([\d\.]+) );
$pat .= q(PIPE1=(\d+) DELAY1=(\d+) BW1=([\d\.]+) PLR1=([\d\.]+));
$pat .= q(PIPE0=(\d+) DELAY0=([\d\.]+) BW0=(\d+) PLR0=([\d\.]+) );
$pat .= q(PIPE1=(\d+) DELAY1=([\d\.]+) BW1=(\d+) PLR1=([\d\.]+));
$delay =~ /$pat/;
# tmcd returns the INTs as MAC addrs.
# tmcd returns the interfaces as MAC addrs.
my $iface1 = libsetup::findiface($1);
my $iface2 = libsetup::findiface($2);
......@@ -290,6 +290,15 @@ sub dodelays ()
$bandw2 = $9;
$plr2 = $10;
# Delays are floating point numbers (unit is ms). ipfw does not
# support floats, so apply a cheesy rounding function to convert
# to an integer (since perl does not have a builtin way to
# properly round a floating point number to an integer).
$delay1 = int($delay1 + 0.5);
$delay2 = int($delay2 + 0.5);
print DEL "ifconfig $iface1 media 100baseTX mediaopt full-duplex";
print DEL "\n";
print DEL "ifconfig $iface2 media 100baseTX mediaopt full-duplex";
Supports Markdown
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