Project 1.2: IP and UDP

CS233/333 - Networks and Distributed Systems
Fall, 1999.

Due Date: Tuesday, October 26, 11:59 p.m.

Note: I'm still cleaning this up a bit, but this is the assignment (more or less).

1. Overview

In this part of the project, you are going to jump into the shark-infested waters of implementing a simple version of IP and a variation of the UDP protocol. You will also be implementing part of the socket interface.

A word of warning: Do not start this part of the project unless you absolutely understand what is going on with the last handin.

2. The Big Picture

When you finish this part of the project, you will have a module 'lsock' that can be used to write simple networked programs using your own implementation of the UDP protocol. For example:
# A simple UDP server
from lsock import *
s = socket(AF_CS333,SOCK_DGRAM)
bind(s,1234)

# Loop forever, waiting for data
while 1:
   data = read(s,1000)
   peer = getpeername(s)
   print "Received a connection from ", peer
   print data


# Send some data to the server
from lsock import *
s = socket
sendto(s,"Hello World", ("192.168.69.4",1234))
...
Of course, a few details are missing here...

3. IP

First, you need to provide support for the IP protocol. Implementing the IP protocol is not much different than what you have done already in implementing the low-level packet module. Only this time, instead of receiving data off of the raw hardware, you code will be receiving data from the packet module. The basic idea of how this module works is as follows: To do all of this, create a file 'ip.py' that defines the following functions: Implementing this part of the project should be fairly straightforward. However, there are a few tricky parts to worry about:

4. UDP

In a file, udp.py, you will be implementing a variation of the UDP protocol. This is *NOT* the same as the regular UDP protocol--in fact, it has an entirely different protocol type so that it won't interfere with normal IP traffic. Your UDP module should do the following: General implementation notes:

5. Sockets

Finally, create a file lsock.py that defines the following functions:

6. Testing

Your code will be tested with a number of simple networked programs that only make use of the 'lsock' module. That is, they will create some sockets and try to communicate with each other in various ways. Because the internals will not be tested explicitly, you have quite a bit of implementation freedom in terms of how you actually implement IP and UDP. Tests will be announced on the mailing list.

Note: Again, you shouldn't be writing thousands of lines of code for this part of the project (my solution was around 400 lines of code). However, it took me a few days to fully wrap my brain around the implementation details. Please don't wait until the last minute to start.