CS 455/555 - Intro to Networks and Communication
Spring 2013: Tues/Thurs 11am-12:15pm, Const 1009

Print - Admin

Announcements

Staff

  • Dr. Michele Weigle
  • mweigle at cs.odu.edu
  • E&CS 3214
  • Office Hours:
    M 1:30-3pm
    Th 9:30-10:45am

Schedule

Syllabus

Links

Program 4: Alternating Bit Reliable Transport

Assigned: Tuesday, April 9, 2013
Due: Tuesday, April 23, 2013 before 11:59pm

Description

The goal of this assignment is to implement an alternating bit reliable transport protocol over UDP. This is based off of the RDT 3.0 reliable transport protocol from Chapter 3. You will implement both a sender and a receiver.

Sender

  • Name the sender AbrtSender.java or AbrtSender.py (this stands for Alternating Bit Reliable Transport)
  • The sender accepts three command-line arguments: receiver hostname, receiver port, number of unique messages to send
    • As with the previous programs, if any of the arguments is invalid, print ERR - arg x and exit
    • port - must be an integer between 10001-11000
    • msgs - must be an integer
  • The sender uses a single UDP socket to send messages with the following format: SEQNO DATA MSGS
    • SEQNO starts at 0 (since this is an alternating bit protocol, SEQNO can be either 0 or 1)
    • DATA starts at 0 and increases by 1 for each new unique message
    • MSGS is the total number of unique messages that will be sent
  • Since this is an alternating bit protocol, the sender cannot send the next message until the previous one has been acknowledged by the receiver.
  • If an ACK is not received before the timer expires, the previous message must be re-sent.
    • Set the timeout to 1 second (1000 ms). You must use the socket timeout mechanism.
  • The sender program should exit when the ACK for the last message has been received.
  • Output format (see examples):
SENT: message that was sent
RECV: message that was received OR timeout!
blank line

Receiver

  • Name the receiver AbrtReceiver.java or AbrtReceiver.py (this stands for Alternating Bit Reliable Transport)
  • The receiver accepts three required command-line arguments: listening port, average delay, and loss percentage. The receiver also accepts an optional fourth command-line argument: seed.
    • As with the previous programs, if any of the arguments is invalid, print ERR - arg x and exit
    • port - must be an integer between 10001-11000
    • delay - must be an integer
    • loss - must be a number (integer or float) between 0-1 (0 and 1 are allowed)
    • seed - must be an integer
  • Each time the receiver gets a message from the sender, it will respond with an ACK. The format of the ACK is ACK ackno, where ackno is the seqno that is being acknowledged (as in the RDT 3.0 protocol).
  • Before sending an ACK, the server will delay or drop the ACK as in Program 2.
    • The ACK for the last message should not be dropped.
    • To get loss and delay like the examples, make sure that you create the Random object only once, decide if the packet should be dropped first, and only choose delays for packets that will not be dropped.
    • For the last ACK, don't check to see if you need to drop it (because you won't) before finding its delay. Otherwise, you'll get different delay numbers than in the examples.
  • The receiver should determine the number of unique messages that will be sent by parsing the first message sent by the sender.
  • The receiver will print the contents of each message received from the sender. As done previously, your program will be tested using a script, so make sure that your output matches the examples exactly.
  • The receiver program should exit when it has sent the ACK for the last message.
  • The receiver only needs to handle messages from one sender at a time.
  • Output format (see examples):
RECV: message that was received
SENT: message that was sent - delayed xx ms OR nothing!
blank line

Rules

  • As with all projects, you are not permitted to work with anyone else (even students not in the class) - all of the coding and documentation must be your own.
  • If you use a code snippet from the web, include a comment before the snippet that indicates the URL of your source
  • Your programs must compile and run on the CS Linux machines.
  • You must write neat code and document it well. You will lose points for sloppy programs that contain little or no comments.

Testing

A large part of your program's grade will be determined by how well it handles a set of inputs. You should test your program rigorously before submitting. Because your programs will be run and tested using a script, you must format your output exactly as I have described or you will lose points.

In all of these examples, the packets dropped and the amount of delays should be exactly as in this example since a seed was specified on the command-line. Note that I'm provided separate examples for Java and Python since the same seed produces different results.

Example Set 1 - usage statements

java AbrtReceiver
Usage: java AbrtReceiver port delay lossRate [seed]
         port - listening port (10001-11000)
         delay - avg delay (ms)
         lossRate - loss percentage [0-1]
         seed - RNG seed (optional)
java AbrtSender 
Usage: java AbrtSender host port msgs
         host - receiver hostname
         port - receiver port (10001-11000)
         msgs - number of unique messages to send
python AbrtReceiver.py
Usage: python AbrtReceiver.py port delay lossRate [seed]
         port - listening port (10001-11000)
         delay - avg delay (ms)
         lossRate - loss percentage [0-1]
         seed - RNG seed (optional)
python AbrtSender.py
Usage: python AbrtSender.py host port msgs
         host - receiver hostname
         port - receiver port
         msgs - number of unique messages to send

Example 2

java AbrtReceiver 10005 4 40
ERR - arg 3

Example 3 - Java only

atria> java AbrtReceiver 10005 500 0.1 7777
RECV: 0 0 4
SENT: ACK 0 - delayed 425 ms

RECV: 1 1 4
SENT: nothing!

RECV: 1 1 4
SENT: ACK 1 - delayed 577 ms

RECV: 0 2 4
SENT: ACK 0 - delayed 701 ms

RECV: 1 3 4
SENT: ACK 1 - delayed 872 ms

sirus> java AbrtSender atria 10005 4
SENT: 0 0 4
RECV: ACK 0

SENT: 1 1 4
RECV: timeout!

SENT: 1 1 4
RECV: ACK 1

SENT: 0 2 4
RECV: ACK 0

SENT: 1 3 4
RECV: ACK 1

Example 4 - Java only

atria> java AbrtReceiver 10005 150 0.2 7890
RECV: 0 0 4
SENT: nothing!

RECV: 0 0 4
SENT: nothing!

RECV: 0 0 4
SENT: ACK 0 - delayed 197 ms

RECV: 1 1 4
SENT: ACK 1 - delayed 131 ms

RECV: 0 2 4
SENT: nothing!

RECV: 0 2 4
SENT: ACK 0 - delayed 270 ms

RECV: 1 3 4
SENT: ACK 1 - delayed 145 ms

sirius> java AbrtSender atria 10005 4
SENT: 0 0 4
RECV: timeout!

SENT: 0 0 4
RECV: timeout!

SENT: 0 0 4
RECV: ACK 0

SENT: 1 1 4
RECV: ACK 1

SENT: 0 2 4
RECV: timeout!

SENT: 0 2 4
RECV: ACK 0

SENT: 1 3 4
RECV: ACK 1

Example 5 - Python only

atria> python AbrtReceiver.py 10005 500 0.1 1234
RECV: 0 0 4
SENT: ACK 0 - delayed 440 ms

RECV: 1 1 4
SENT: nothing!

RECV: 1 1 4
SENT: ACK 1 - delayed 939 ms

RECV: 0 2 4
SENT: ACK 0 - delayed 671 ms

RECV: 1 3 4
SENT: ACK 1 - delayed 83 ms

sirus> python AbrtSender.py atria 10005 4
SENT: 0 0 4 
RECV: ACK 0

SENT: 1 1 4 
RECV: timeout!

SENT: 1 1 4 
RECV: ACK 1

SENT: 0 2 4 
RECV: ACK 0

SENT: 1 3 4 
RECV: ACK 1

Example 6 - Python only

python AbrtReceiver.py 10005 150 0.5 5679
RECV: 0 0 4
SENT: nothing!

RECV: 0 0 4
SENT: ACK 0 - delayed 137 ms

RECV: 1 1 4
SENT: ACK 1 - delayed 194 ms

RECV: 0 2 4
SENT: nothing!

RECV: 0 2 4
SENT: ACK 0 - delayed 15 ms

RECV: 1 3 4
SENT: ACK 1 - delayed 206 ms

python AbrtSender.py atria 10005 4
SENT: 0 0 4 
RECV: timeout!

SENT: 0 0 4 
RECV: ACK 0

SENT: 1 1 4 
RECV: ACK 1

SENT: 0 2 4 
RECV: timeout!

SENT: 0 2 4 
RECV: ACK 0

SENT: 1 3 4 
RECV: ACK 1

Example 7

I'm not giving the results here, but try this:

atria> java AbrtReceiver 10005 660 0.4 5678
sirius> java AbrtSender atria 10005 4

It should produce two premature timeouts in a row (on data 1 and the retransmission of data 1) by delaying the ACKs by 1015ms and 1285ms. Convince yourself that the operation of your program is correct.

I haven't found a similar case for Python yet. If I do, I'll post it here.

Submission

You must name your source files AbrtSender.java and AbrtReceiver.java or AbrtSender.py and AbrtReceiver.py (note the capitalization). Make sure that you submit all files necessary to compile your program. But, do not submit compiled files (.class files).

Directions for submitting your assignment through Blackboard