Packet Pass Around Project

by: burt rosenberg
at: university of miami


The luggage is a UDP packet;
the carrier an L2 frame for transport

Objectives

This project will familiarize you with sockets and the IP/UDP communication protocol.

The previous project was a simple one packet send. In this project, packets have a list of IP address, and the program acts as both server and client, alternating in those roles, to route the packet along that list.

The program listens for an incoming packet. When a packet is received it decodes the list of IP address. If the list is not empty, the program takes the first IP off the list, and forward the packet to this IP, with the packet payload being the remaining addresses on the list.

The list will be an ASCII sequence of host names separated by the colon ":". The hostnames can be IP address written in dotted notation.

While this is an ASCII sequence, so you might think it a C-string according to the conventions of string.h, in the packet it is just a sequence of bytes. The null byte, which is used by the string.h library to describe the string length, will not travel in the packet. The length of the packet, as returned by the receive call, will give the number of characters in the packet. An empty list is signaled by a packet of length zero.

In implementation, the same socket can be used for both send and receive. In fact, when sending to localhost, one program will pass the packet back and forth to itself using the socket in alternating receive and send.

When there are several hosts, all will listen and one instance will have the -m option to send first, to get a packet on its way. That suggests a game (see the competition below), where the original sender lists a bunch of IP's and puts its own IP last. If all goes well, the packet will return after visiting each IP on the list of IP's of the originating packet.

Man Page

NAME
   passaround --- listens and forwards UDP packets according to message contents.
      
SYNOPSIS

   passaround [-v] [-n number] [-m message] port

DESCRIPTION

   Passaround listens on the port given in the command line for UDP packets and forwards
   the packet as instructed by the packet contents. Packet content is a character 
   sequence (not a string!) of format: 
   
        host(:host)*
        
    or the empty string. If the empty string, there is nothing to pass on. Else the 
    first host name is removed from the string, and the remainder of the string (properly
    formatted) is sent to the named host.
   
OPTIONS

    -m Take as the "message" the first received message
    -n forward number packets to forward, then exit. Default is 1; 0 for loop forever.
    -v verbose
     
ARGUMENTS

    Port, the port number to listen on, and to send to. The from port can be ephemeral.

OUTPUT
  
    Without the verbose option the output should be strictly one line for each send
    and receive, in the order of occurrence:
  
    R: host:port |message-as-received|
    S: host:port |message-as-sent|
  
    Host and port refer to the send-to, on S, and the received from, on R. For host,
    please print the IP address. Going from IP to hostname is called reverse IP lookup,
    and reverse records are not always available.
    
HISTORY

    Appeared as the Pass-it-on project, in csc524-132,and next as packet-pass-around in 
    csc424-152.

Templates and the Makefile

Copy the template files from class/proj2 into your _username_/proj2 folder. Your folder must be named proj2, and your main program must be named passaround.c.

No project is correct without a correct Makefile. The grader and I expect that we can:

svn update; make clean; make ; make test
Do not check in binaries or other build products! Points off for unnecessary stuff in the repo.

Please be precise in naming of your files and directories — the folder name must be [your-repo]/proj2.

Always put your name and date in the header comments of your code. I will consider that your promise to have sincerely contributed your own work to the project (although you can discuss and collaborate — the final product must be your own.)

Packet Swap Meet

After the due date for the project, in class we will run our instances and attempt to pass a packet around to all the instances.

Participants in the chain get 1 point added to their score.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

Author: Burton Rosenberg
Created: February 3, 2015
Last Update: February 3, 2019