Packet Passaround 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 passaround server listens on the given port for a UDP packet that contains a colon-separated list of IP address (or host names). It passes on the packet to the IP (or hostname) appearing at the head of the list, with message the remainder of the list.

If the list is empty, then there is nothing to forward. If the -m option is used, the server acts one time as a client by sending the message provided, as if it had received it on its listening socket.

The foo-socket can be used with one socket, bound to the given port. It receives packets using the socket_recvfrom method, and sends using the socket_sendto method. The reply action is not used in this project.

You should work in groups, up to size four. And pass the packet around all of your code. Submit your own work, but there will be in an-class backoff counting as a quiz, in which the passaround chains are extended, with points as we extend the chain, to see if we can't pass the packet around all of our codes. More about this later.

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

   Packet-passaround first appeared in csc424-152.

Implementation Notes

As our code must interoperate, the format of the payload must be followed exactly.

The message is NOT a string. There will be no trailing null byte. You might add one if you wish, for the purposes of your code, however it is wrong to expect a trailing null byte and it is wrong to send a trailing null byte.

The hostnames can either be IP address or names. The hostlookup call in the inet library accepts either. The port given will be shared by all servers. It is not required that you send from that port, but you must listen on that port. If you use just a single socket, then it will listen and send on the same port. There is no pressing reason to do otherwise.

The -n is an option to help with automated testing. Usually a server with either loop forever or serve one packet and exit. The number here sets the number of packets that the server will forward before exiting. One of the tests is to bounce a package back and forth three times. Setting -n to 3 means that when the test is completed, the server exists, and the result status can be evaluated.

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: 6 February 2023