Project 2 bug fixes
The files here have real honest-to-goodness bug fixes in them. You
should grab them and update your project.
Fix 1: file error message and proper synchronization for
This revised project2.java fixes three problems:
The updated file is here. It goes in the network package
- The code that built the network (from reading the config file)
was not synchronized into the timer, so that anybody who tried to do
timer-related things (like sending messages) when AddLink was
called got into trouble with the timer. This version builds the
network in a registered and synchronized thread.
- The code that built the network wasn't very careful about the
order in which things went together. This version makes sure that the
link knows about both of the nodes before the nodes are told about the
link, so that it should be fine to immediately transmit a message
across a link when AddLink is called. Note however that the
receiver of this message might get a little confused, becuase
they might see the packet from the first node to get added (via a call
to PacketArrived) before they see the link that it arrived on
being added (view AddLink). It is possible to figure out
what is going on since PacketArrived tells you the link that
it arrived on.
- The error message for failure to open the file was less than
useful (silent failure). This version complains more loudly if it
fails to open/read the file.
Fix 2: proper measurement in the receiver
This is a tiny bug in the receiver application that was causing it to
give erroneous bandwidth computations. It's a one-liner fix (look for
the comment "FIX"), but you might as well grab the whole file. It
goes in the application package. Don't forget to recompile
that package after you grab it.
Project 2 patches
It should not be necessary to use any of the patched files here. So
far these are simply enhancements that may make things easier, rather
than real bug fixes.
The following three files together give you three new functions on
links that you can use:
The first two are provided so that you can figure out how to weight
routes for best performance, rather than just optimizing hop count.
The third is provided because the algorithms in the book assume that
you can have this information, and I'd rather not have people hacking
the setup code to get this information. You could just as easily send
a "Who are you/I am me" message across the link to find out who is at
the other side, but adding this function doesn't bother me either.
- double Bandwidth (); returns the average bandwidth in Mb/s
- double Latency (); returns the average latency in ms
- String OtherNodeNames (Node n);
returns a list of the names of the other node(s) on the link
To apply these changes, you need to grab all three of the following
files. They all go in the link package. You will then need to
recompile the link package.
In addition, you will want to change the toString function in
RoutingNetworkEdge.java to read:
So that the string that you get from OtherNodeNames will
match the address of the sender/receiver in the case where the node is
the edge. The names for routers have "Router:" built into them, but
that isn't a problem because those names are arbitrary anyhow.
public String toString ()
return "" + address;
More robust sliding window baseline
The following version of the sliding window sender implements two
enhancements that will make it more stable and make it easier to
adjust the sliding window size:
The code is here. It goes in the reliability package.
- Round-trip time estimation is in place, and the timeout value is
set to 1.5 times the rtt estimate. The transmit time is maintained in
the window structure for each packet.
- The window data structure has been changed to one with separate
add and remove operations that allow the size to vary (up to a maximum
size). The algorithm sends up to the minimum of WINDOW_SIZE
and congestionWindowSize (currently set to the same) packets.