CS-2910 Network Protocols

Dr. Mark Sebern -- Fall quarter 2014-2015

Lab 2: Simple Python program to send/receive UDP/TCP messages

Revised: 26 September 2014

Lab assignment

This is a team assignment; each team should be two members unless a different size is approved by the instructor.


The goal of this lab is to write a short Python program, to send and receive network messages using the UDP and TCP protocols.

The program has at least the following functions; you may add others.

Prompt the user for the network operation to perform and then call the selected function with appropriate argument values
Transmit a single UDP packet to a specified destination host and port
Listen for a single received UDP packet and display the received data
Transmit a single TCP message to a specified destination host and port and receive a response. In this case the "destination" host is referred to as a "server", since messages are sent in both directions.
Listen for a TCP connection on a specified port, receive and display a single received message, and send a one-character response.


  1. Download the skeleton Python template: cs2910-lab-udptcp-template-py.txt
  2. Rename the template file to cs2910-lab02-username1-username2{-username3}.py, where each "usernameN" is the MSOE email username (e.g., "smithj") of a team member, in alphabetical order.
  3. Edit the header of the file to include your team members' names.
  4. Fill in the methods that implement each of the four operations. You may add other helper methods, but do not change the code provided in the template.
  5. If you have time, use Wireshark to view the messages as they travel between nodes.
  6. Finally, add comments at the end of your Python file, with the following information:
    • A description of the functionality you implemented and the results of your testing.
    • Comments on your experience in completing the lab, including any problems you encountered. Briefly explain what you learned.
    • Questions and suggestions.

Additional implementation details will be discussed in class. If you have questions about these requirements, ask in class or lab.

If this base functionality turns out to be too easy, you may experiment with adding additional functions, but be sure the basic requirements are still met.

Try to divide up the primary responsibility for parts of the program in an equitable way. For a two-member team, one member should write the "transmit" side of one protocol and the "listen/receive" part of the other. Put the primary author's name in a comment before each function.

Test your software by running two copies of the program, first on the same system using localhost, and then on two different systems (network nodes). Demonstrate your working software to the instructor.

Submission (Due Monday, 9/22/2014, 9PM)

One team member should submit your Python file by uploading to the CS-2910-031 Submissions folder on box.msoe.edu. If you have questions about this process, consult the instructor well in advance of the submission deadline.

Please follow these submission instructions exactly, including details of the filename, or your submission may be rejected, resulting in a "F" grade.