Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Computer Networking - Assignment 2
School of Informatics
University of Edinburgh
Issued 23 October 2006
The purpose of this assignment is for you to implement and test a simplified version of the common routing
algorithm RIP (Routing Information Protocol) in Java. RIP is a variation of the Belman-Ford algorithm and
is described in detail in RFC1058, available from http://www.faqs.org/rfcs/rfc1058.html. You
should read the RFC before starting to write your code.
Your RIP implementation will be plugged into a simple network simulator designed by David Rees and
later modified by myself. The source code is reachable through links from the course web page: http:
//www.inf.ed.ac.uk/teaching/courses/cn.
File SimEngine.java contains the simulation engine and class definitions for most network compo-
nents. File Router.java contains a skeleton for the router node which you should extend to implement the
RIP algorithm. The main method is found in file TestRIP.java. It creates a small network and tests if the
routing algorithm works. The listings are best viewed with tab stops = 4.
You must not modify any of the code in SimEngine.java. However, you will have to read and under-
stand much of the provided code to find out which methods you need to call and how the simulator works in
general.
The network simulator code and test bench
Most of the provided code should be self-explanatory. The following are a few comments on the features
provided to help with testing aspects of the simulated network.
The purpose of a “Source” object is to inject packets into the network. When a Source is instantiated it is
given a list of (packet, time) pairs. It will schedule the packet transmission at the time provided in the list.
A “Link” object is a unidirectional “wire”. To model faults, when a link is instantiated it gets a list of
“BreakStopStart” pairs (stop, start). Stop signifies the time when the link should stop working, i.e. all packets
will be dropped from then on. Start (greater than stop) is the time when the link should start working again.
When stop is -1, the link is always up. When start is 0, the link (once stopped) never returns to normal operation
again.
The “Packet” object holds a packet. It includes some essential information (source, destination), but most
of the fields are to help test aspects of the network:
• noDrop — means that this packet should reach its destination. If it gets dropped, a warning message is
displayed.
• noLoop —when set to true, it means that there should be no routing loops for this packet.
• hops — the number of hops that should take to reach the destination. A value of 0 means “don’t check
the number of hops”.
• purpose — is a string that describes what this packet is testing. You can use this to make the program
output human readable, so that one can follow what your test-bench does.
• journeyLog — is a list of router IDs (strings) that the packet has visited. It can be used for debugging to
see if the packet has followed the intended (shortest path) route.
Interface
Input
Interface
Output
"faulty"
link
Ra
S1
Rb Rx1Rx0Rc
Link
Rx3Rx4 Rx2RdRe
Figure 1: Network topology for testing RIP.
The network topology used in the provided test harness is shown in figure 1. Five packets are transmitted.
The first is injected before the routers have exchanged enough information, therefore the route to its destination
is not yet known at router Ra, so it gets dropped. The second packet is sent at the earliest possible time that a
route to Rx2, the node which is the furthest away from S1, becomes known to the whole network. The third
packet is sent just after the link between Rb and Rd goes down, so Re will be temporarily unreachable (poisoned
reverse should make all destinations through Rd unreachable, until the network discovers the alternative routes).
The fourth packet is sent at the earliest possible time that an alternative route to Re is found. The fifth packet is
sent after the Rb-Rd link is restored and checks whether the route to Rx3 goes through Rd, which is the shortest
path, or not.
Your test-bench
You should create your own, improved, test-bench in your copy of TestRIP.java. You can keep the network
topology or extend it to create “hard” test cases for the routing protocol. A number of distinct, unconnected
networks could be used, if it helps. You will most probably need to transmit more packets and modify the
specific times when the above five packets are transmitted depending on your topology, link delays etc.
Using your test-bench, you should demonstrate (at least):
• Packets taking the shortest route to a destination (when they have a choice of routes)
• Packets being dropped because a destination is unknown or a link is broken.
• The network protocol finding alternative routes when they exist.
• Routing loops happening even though split horizon with poisoned reverse is implemented.
Make your program output easy to explain, by using the packet “purpose” field and provide any further
explanation you feel is necessary in a separate “readme” file.
Submission
The submission deadline isMonday 6th November.
2
Use the Informatics ‘submit’ command or the equivalent web page. Please submit the whole directory
where your files are located making sure that the source files Router.java, TestRIP.java and a text/PDF
file explaining your test-bench are present.
Assessment
This assignment is marked out of 100. All assignments are equally weighted and, combined, are worth 25% of
the course mark.
As a first test I will compile and run your modified Router.java with the original TestRIP.java to
see if it works. Then I will try the test-bench that you developed. Finally I may use a third test-bench.
Your code should work correctly, efficiently and be easy to understand (good programming practice, rea-
sonable comments, appropriate variable names, . . . ). These are the criteria that will attract the most credit. In
addition, the ‘quality’ of the test harness that you provide will account for 20% of the marks for this assignment,
so you should put some effort into it.
Notes on RIP
Much of the following will make sense only after reading the RFC!
• The packet formats need not be followed exactly. A packet can be a class and its member variables are the
packet’s fields. There is no need to pack the fields in the same way as in the real packet. In reality, the RIP
messages are transmitted using UDP. For this assignment you will just use the outport.schedulePacket
method to transmit a packet.
• The RIP specification defines a number of message types. Only response commands are to be imple-
mented, which should be automatically transmitted every 30 seconds from each router to each of its
neighbours.
• The links connecting the routers are point-to-point, there are no broadcasting,, Ethernet-like links. The
addresses used in the network simulator are simple strings, not IP addresses. No subnetworks or network
names are used, so to do address matching you simply compare the strings for equality.
• Routing algorithm: you should implement split horizon with poisoned reverse, but not triggered updates.
Queries and clarification
If you have any questions or uncertainties please contact the course lecturer, preferably by email (aefthymi).
3