G22.2262: Data Communications and Network Design
Homework 2.
Due Date: Thursday, December 9, 1999
This homework has 4 questions. Question 1 is worth 85 points, question 2 is worth 9 points, and questions 3 and 4 are worth 3 points each.
You will assume you have an IP address of 198.11.109.34 and Ethernet address of 08:00:20:98:A1:35. P>
Your program should take a single parameter, and that parameter is the name of a file. The file contains lines of the following form:
IP:IP_Address:Broadcast_flag:Data
or
Ether:Data
Each line represents data passed down to ARP from IP or up to ARP from Ethernet. After reading each line of the file, you must show the ARP table and any packets that ARP tells Ethernet to send. You must assume that every line arrives 15 seconds apart, and you must delete entries from the ARP table if they have not been accessed IP in 20 minutes.
For example, the file can contain the following lines:
IP:198.11.109.08:0:IPdatagram1
IP:198.11.109.15:0:IPdatagram2
Ether:0001 0800 06 04 0002 08 00 20 11 F1 A6 198.11.109.08 08 00 20 98 A1 35 198.11.109.34
IP:198.11.109.255:1:IPdatagram3
IP:198.11.109.15:0:IPdatagram4
IP:198.11.109.15:0:IPdatagram2
Ether:0001 0800 06 04 0002 08 00 20 15 19 87 198.11.109.15 08 00 20 98 A1 35 198.11.109.34
IP:198.11.109.08:0:IPdatagram1
IP:198.11.109.08:0:IPdatagram5
Ether:0001 0800 06 04 0001 08 00 20 61 73 A4 198.11.109.18 00 00 00 00 00 00 198.11.109.34
Ether:0001 0800 06 04 0001 08 00 20 A1 C3 4F 198.11.109.19 00 00 00 00 00 00 198.11.109.32
IP:198.11.109.19:0:IPdatagram6
Ether:0001 0800 06 04 0001 08 00 20 A1 C3 4F 198.11.109.19 00 00 00 00 00 00 198.11.109.32
Ether:0001 0800 06 04 0002 08 00 20 A1 C3 4F 198.11.109.19 08 00 20 98 A1 35 198.11.109.34
Your program should be invoked as follows:
$ myarp filename
Your program should print the following output:
Arp table:
198.11.109.08 0
Tell Ethernet to send:
FF FF FF FF FF FF 08 00 20 98 A1 35 0806
0001 0800 06 04 0001 08 00 20 98 A1 35 198.11.109.34 00 00 00 00 00 00 198.11.109.08
Arp table:
198.11.109.08 0
198.11.109.15 0
Tell Ethernet to send:
FF FF FF FF FF FF 08 00 20 98 A1 35 0806
0001 0800 06 04 0001 08 00 20 98 A1 35 198.11.109.34 00 00 00 00 00 00 198.11.109.15
Arp Table:
198.11.109.08 08 00 20 11 F1 A6
198.11.109.15 0
Tell Ethernet to send:
08 00 20 11 F1 A6 08 00 20 98 A1 35 0800
IPdatagram1
Arp Table:
198.11.109.08 08 00 20 11 F1 A6
198.11.109.15 0
Tell Ethernet to send:
FF FF FF FF FF FF 08 00 20 98 A1 35 0800
IPdatagram3
Arp Table:
198.11.109.08 08 00 20 11 F1 A6
198.11.109.15 0
Tell Ethernet to send:
Nothing
Arp Table:
198.11.109.08 08 00 20 11 F1 A6
198.11.109.15 0
Tell Ethernet to send:
FF FF FF FF FF FF 08 00 20 98 A1 35 0806
0001 0800 06 04 0001 08 00 20 98 A1 35 198.11.109.34 00 00 00 00 00 00 198.11.109.15
Arp Table:
198.11.109.08 08 00 20 11 F1 A6
198.11.109.15 08 00 20 15 19 87
Tell Ethernet to send:
08 00 20 15 19 87 08 00 20 98 A1 35 0800
IPdatagram2
08 00 20 15 19 87 08 00 20 98 A1 35 0800
IPdatagram4
Arp Table:
198.11.109.08 08 00 20 11 F1 A6
198.11.109.15 08 00 20 15 19 87
Tell Ethernet to send:
08 00 20 11 F1 A6 08 00 20 98 A1 35 0800
IPdatagram1
198.11.109.08 08 00 20 11 F1 A6
198.11.109.15 08 00 20 15 19 87
Tell Ethernet to send:
08 00 20 11 F1 A6 08 00 20 98 A1 35 0800
IPdatagram5
Arp Table:
198.11.109.08 08 00 20 11 F1 A6
198.11.109.15 08 00 20 15 19 87
198.11.109.18 08 00 20 61 73 A4
Tell Ethernet to send:
08 00 20 61 73 A4 08 00 20 98 A1 35 0806
0001 0800 06 04 0002 08 00 20 98 A1 35 198.11.109.34 08 00 20 61 73 A4 198.11.109.18
Arp Table:
198.11.109.08 08 00 20 11 F1 A6
198.11.109.15 08 00 20 15 19 87
198.11.109.18 08 00 20 61 73 A4
Tell Ethernet to send:
Nothing
Arp Table:
198.11.109.08 08 00 20 11 F1 A6
198.11.109.15 08 00 20 15 19 87
198.11.109.18 08 00 20 61 73 A4
198.11.109.19 0
Tell Ethernet to send:
FF FF FF FF FF FF 08 00 20 98 A1 35 0806
0001 0800 06 04 0001 08 00 20 98 A1 35 198.11.109.34 00 00 00 00 00 00 198.11.109.19
198.11.109.08 08 00 20 11 F1 A6
198.11.109.15 08 00 20 15 19 87
198.11.109.18 08 00 20 61 73 A4
198.11.109.19 08 00 20 A1 C3 4F
Tell Ethernet to send:
80 00 20 A1 C3 4F 08 00 20 98 A1 35 0800
IPdatagram6
Arp Table:
198.11.109.08 08 00 20 11 F1 A6
198.11.109.15 08 00 20 15 19 87
198.11.109.18 08 00 20 61 73 A4
198.11.109.19 08 00 20 A1 C3 4F
Tell Ethernet to send:
Nothing
Here are some notes:
You must assume every line in the file comes in 15 seconds apart. So, if an entry is not accessed in 20 minutes, you must delete it from the ARP table. You should reset the timer every time it is accessed by an "IP" line, but not by an "Ether" line.
The the ARP table is completely empty, you should display lines that say:Arp Table:
Empty
If you are waiting for an ARP reply from machine X, and IP asks you to send a datagram to X, only send another ARP request if the IP datagram is in the queue for machine X.
Have your output look exactly like that in the example!