IP Lab


Background:
The IP lab deals with fragmentation and reassembly. In this lab, you will be passed a large segment and will fragment it into several packets and then reassemble it at the receive end.  You should study the material on pages 248-263 in order to complete this laboratory.

The IP header corresponds to Figure 4.3 in the text.  The version field should be 4 for IPv4.  We will not be supporting options, so the HLen field should be 20 bytes (the value 5 should go in this field since it counts 4 byte quantities).  The TOS field can be set to zero for this lab.  The Length field is the number of bytes in the whole packet, including the header (remember big endian byte order for multi-byte entities). You should pick a unique Ident for each push command you receive from the higher layer (start with zero).  When that push has been completed (by sending smaller pushes to the next lower layer) you will select a new Ident parameter.
Version(4 bits) Hlen(4 bits) TOS(8 bits) Length (16 bits)
Ident (16 bits) Flags(3 bits) Offset(13 bits)
TTL(8 bits) Protocol (8 bits) Checksum (16 bits)
SourceAddr (32 bits)
DestinationAddr (32 bits)
Options (variable) Pad(variable to 32 bit boundary)
Data (payload up to ~64KBytes)
You can set the TTL field to 1 in your packets since your packets won't pass through a router.  It may be easier for you to look at the combination of Flags and Offset as a single 16 bit entity.  It will be harder if you try to declare a data structure for the 3 bits of flags.  If you view the 16 bit Flag/Offset field together, then the M (more fragments) bit is 0x2000 (bit #50 in the header).  You will want to turn this bit on when there are more fragments.  The Protocol field will define which higher layer protocol to pass the data to.  Protocols are defined as:

You should use IPT_TCP for your packets since that is the protocol that will be implemented above you.  If you receive something else, you should discard the packet.

You should generate the checksum and fill in the field using the checksum algorithm we reviewed earlier (page 95) (remember byte order when computing the checksum). The checksum is computed over the entire IP header, not the payload.

The source address and destination address will be the specified 32 bit IP addresses.

The Offset field will contain the offset of the current packet in the higher layer large segment (remember that it counts in 8 byte units of data).  You should send the fragments in order, but may receive them out of order and should be able to reassemble them into the correct order before passing the segment up to the next higher layer.

You may also receive fragments from different segments and you will need to reassemble them into their correct segments before passing them up to the next layer. You can assume that there will be at most 3 segments active at any time and the maximum segment size will be at most 1000 bytes.

Specifications:

The IP layer object will be similar to the other objects you have written in prior labs.  The IP layer object must support the following methods:

Tips:

Example:

The arguments to the binary are the same as ARP. The arguments are (host where daemon is running[this machine]) (port daemon is listening to[1234]) (src IP address) (src ETH address)  (dst IP address) (dst ETH address) (-c or -s) (-v optional debug flag)(0xff debug level). The additional arguments were included so that you can run your code without interfering with other students.  Pick IP addresses and Ethernet addresses with the same top bytes as this example, then change the bottom byte to a value between 0 and 200.

On the machine cs460-7 run

./ip cs460-7 1234 192.168.102.7 00:a0:cc:66:99:33 192.168.102.2 00:a0:cc:66:99:35 -c -v 0xff
On the machine cs460-5 run with exactly the same arguments, except for the hostname and client flag.
./ip cs460-5 1234 192.168.102.7 00:a0:cc:66:99:33 192.168.102.2 00:a0:cc:66:99:35 -s -v 0xff
You will always connect to the daemon on port 1234.  The daemon is "ether_service" and you can use "ps -ef | grep service" to make sure it is running on  the machine you are working on. 

While you are getting your code working, you will probably want to turn on some serious debug statements.  If you run the lab code with something like "./ip cs460-7 1234 192.168.102.1 00:a0:cc:66:99:33 192.168.102.2 00:a0:cc:66:99:35 -c -v 0xff" it will turn on a lot of debug in the lower layers.  Bit 0 turns on the physical layer printfs.  Bit 1 (0x2) turns on the ethernet debug.  Bit 2 (0x4) turns on a printf when something is not destined for your ethernet address.  Bit 3 (0x8) turns on the basic arp debug.  Bit 4 (0x10) just shows what is being put into the arp table.

Passoff:

We will provide you with the framework at ~cs460ta/labs/ip_template on one of the 460 lab machines to help you to test your IP layer.  The passoff procedure will test the following specific items

Run your code using the framework and the lab version of the code from ~cs460ta/labs/ip on another machine in order to pass off your program for the TA during his office hours. This lab code will basically do the same thing as the framework code, but may run some different tests. It will first receive all of the packets you send from main. When you hit the ENTER key on the server window, it will send you frames to test your responses. 

The following passoff levels will apply to this lab:
 
 
Passoff Level Behavior Points
Minimal Passoff At least one IP packet is successfully sent to the server 2 Points
Fragmentation  You are able to correctly fragment all of the packets sent to the server  3 Points 
Minimal Reassembly  You are able to receive a short packet from the server correctly  1 Point
Perfect behavior Passes all tests and correctly reassembles all long packets 4 Points