160 likes | 240 Views
The Project. Please read the project’s description first. Each router will have a unique ID, with your router’s ID of 0 Any two connected routers will have an associated cost between them. Server. R 2. R 5. R 4. R 0. R 3. R 7. R 8. R 1. R 6. Your Router. R 0.
E N D
The Project • Please read the project’s description first. • Each router will have a unique ID, with your router’s ID of 0 • Any two connected routers will have an associated cost between them Server R2 R5 R4 R0 R3 R7 R8 R1 R6
Your Router R0 • Your router is always Router 0. • Your router should have a socket, which connects to the test program. • The test program will send you two kinds of messages. LAN
Phases The project will be completed in two phases: • You will receive an update message from the server, based on which you will construct your routing table using Dijkstra algorithm. • After the first phase is done, you move into phase II.
Phase I In Phase I, you will do the following: • Using the socket, you will receive a routing update from the server which will contain the number of networks, the costs of the links (cost matrix) and the IP range for each router. • Based on the cost matrix and the routers directly connected to router 0, using Dijkstra’s algorithm, you will construct the routing table: the next-hop to reach any other router in the network.
First step first • As the first step, you will be provided with example networks to practice how Dijkstras algorithm works based on which you can code the algorithm (which is an essential part of the project). • Here we provide one example. It is also one of the two test cases.
Format of routing update Based on the project description, using the socket, the server will send you three strings, respectively. • The first string is a number (but it is still a string), telling you how many routers there are in the network (including yourself). • Example: “3”. • The second string is an NxNmatrix. All valid costs will be positive integers (or zero), determining thecostto get from Router i to Router j. • Example: “0, 1, 2, 3, 0, 4, 5, 6, 0”.
The third string is a denition of IP range, telling you which router is serving what range of IP addresses. • Example: “0.0.0.0-1.1.1.1 1.1.1.1-2.2.2.2 2.2.2.2-3.3.3.3”.
An Example • In the next few slides, we will go through an example of how to construct the routing table. • Assuming that the server sends the routing update as shown in the next slide. • We show in the subsequent slide the connections and costs for the first 3 rows. • Can you complete the rest of the network?
Example routing update “8” “0, 1, 12, -1, -1, 18, -1, 63, -20, 0, 28, -12, -24, 12, 64, 62, -11, 68, 0, -15, 17, 10, 47, -24, 75, 33, 50, 0, 70, 54, 66, -19, 6, 17, 56, 56, 0, 65, 68, 0, 18, -1, 30, 5, -13, 0, 28, 12, 27, -4, 72, 32, 43, 6, 0, 6, 9, 63, 32, -11, 13, -3, 17, 0” “0.0.0.0-32.0.0.0 32.0.0.0-64.0.0.0 64.0.0.0-96.0.0.0 96.0.0.0-128.0.0.0 128.0.0.0-160.0.0.0 160.0.0.0-192.0.0.0 192.0.0.0-224.0.0.0 224.0.0.0-255.255.255.255”
Cost matrix (re-written) [0, 1, 12, -1, -1, 18, -1, 63, -20, 0, 28, -12, -24, 12, 64, 62, -11, 68, 0, -15, 17, 10, 47, -24, 75, 33, 50, 0, 70, 54, 66, -19, 6, 17, 56, 56, 0, 65, 68, 0, 18, -1, 30, 5, -13, 0, 28, 12, 27, -4, 72, 32, 43, 6, 0, 6, 9, 63, 32, -11, 13, -3, 17, 0]
Connection and cost for the first 3 rows R5 R3 10 18 R7 63 62 R0 R4 12 R2 17 1 12 68 28 47 R1 64 R6
Dijkstra Algorithm • The running result for the algorithm. • How can we construct next hop table from this?
Phase II • In this phase, the test program will send you several IP addresses. One at a time. • You need to first check which router you should forward it to, and then choose the correct next hop. • You router can exit after receiving “END”.
One more thing… • How to determine which router an IP address belongs to?