In this assignment you will implement a sender for a TCP-like protocol called NQTCP. A receiver is provided that intentionally loses packet and acknowledgements, but otherwise implements the reliable protocol. The underlying protocol is UDP. A framework for the sender is provided that manages the user input and multi-threading concerns.
NQTCP messages consist of an 8 byte header followed by data of up to 10 bytes. Note the value of packet length can be much bigger, but you will only be sending up to 10 at a time.
Numbers are stored in Big-Endian format meaning the high order byte of the number is first. For example, if the sequnce number is 522 (0x020A in hex) then the value at data[0] is 2 (0x02) and the value in data[1] is 10 (0x0A).
| Header Bytes | Data Bytes | |||
|---|---|---|---|---|
| 0..1 | 2..3 | 4..5 | 6..7 | 8..17 |
| Sequence Number | Acknowledgement Number | Packet Length in bytes (including the header) | Unused | Data (optional) |
Like TCP, the sequence number represents the location in the data stream for the data carried in the packet. The acknowledgement number indicates the next expected sequence number we will receive from the other end of the communication. Unlike TCP both values start at 1.
Since only the sender will be sending data, the acknowledgement numbers of the packets you send and the sequence numbers of the packets you receive will be 1.
The following table lists the events related to the program receiving data and the actions the receiver takes when the events occur.
| Event | Actions |
|---|---|
| Segment received with expected sequence number. No out-of-order packets or delayed ACKs. |
|
| Segment received with expected sequence number and one delayed ACK. |
|
| Segment received with expected sequence number and there are waiting out-of-order packets. |
|
| Receive out-of-order new segment. |
|
| Receive duplicate segment. |
|
The following table described the events that occur in the sender and the actions that the sender should take. The "Method" column refers to the methods that handle the events as required by the assignment.
| Method | Event | Actions |
|---|---|---|
| sendPacket | App provides data to be transmitted. |
|
| receivePacket | Receive an ACK from the network (special case below) |
|
| Receive three ACKs with the same ACK number in a row. (Fast Retransmit) |
|
|
| timeout | Timer times out. |
|
For this assignment you will complete the implementation of MyNQTCPSender.java. Several files are provided for your use. You can find the files in http://cs.gettysburg.edu/~cpresser/cs322/NQTCP/
| FIle | Description |
|---|---|
| NQTCPReceiver.jar | The NQTCPReceiver program. You can run this with the command line
java -jar NQTCPReceiver.jar
See the NQTCPReceiver section for instructions on how this program works.
|
| NQTCPSender.java | An abstract class containing the framework for sending data. It manages user input as well as additional threads and timers. It also creates the DatagramSocket that is to be used in the subclass MyNQTCPSender. This is the sender's main program. Run this to execute your sender (kill the messanger?) in eclipse or with the command line:
java NQTCPSender
It optionally takes a hostname on the command line if you prefer running across a network. |
| MyNQTCPSender.java | A subclass of NQTCPSender with an empty constructor and methods. Your job is to add code to this to make a correct sender. |
| SampleRun.pdf | Two sample runs with explanations. |
To complete the file MyNQTCPSender.java and implement the reliable protocol, you must do the following.