ocket (i.e., supported by UDP) in Python to create a Reliable Datagram Protocol (RDP) transceiver (rdp.py, a combined sender and receiver) running on H1 in PicoNet, to interact with a given echo server running on H2, over an unreliable link at R.
Requirements: A basic RDP design is provided, and you can extend the design as you see fit. RDP follows
HTTP design, using full text, line-by-line control headers to establish (SYN) and release (FIN) connection, and Sequence number in data (DAT) packet of PAYLOAD Length and Acknowledgment number in acknowledgment (ACK) packet to reorder out-of-order packets, acknowledge received packets and identify lost packets for retransmission. To be efficient, RDP cannot use stop-and-wait (i.e., transmit a packet, wait for acknowledgment, and retransmit until it is received), and has to support flow control using Window size (i.e., multiple packets can be transmitted back-to-back within the Window, and lost packets will be recovered through retransmission by timeout or three duplicate acknowledgments). You can model your RDP design after TCP, but you do not need to implement the entire TCP. Congestion control is not needed for RDP in P2. RDP packet format
COMMAND
Header: Value
…
Header: Value
PAYLOAD
where, COMMAND := SYN|FIN|DAT|ACK|RST, and SYN indicates to establish connection, FIN to close connection, RST to reset connection, DATA to send data, and ACK to acknowledge received data.
Header := Sequence|Acknowledgment|Window|Length, and Sequence provides the sequence number associated with the packet (the first byte of the PAYLOAD if any), Acknowledgment the sequence number expected by the receiver (the next byte of the PAYLOAD if any), Window the size of the receiver’s window in bytes, and Length the length of the PAYLOAD in bytes. Note that an empty line indicates the end of headers.
PAYLOAD, if existing, is the actual data sent from the sender to the receiver. PAYLOAD is at most 1024 bytes.
The Echo Server On H2
mkfifo fifo which makes a FIFO (named pipe) called fifo. you only need to run this command once at /home/jovyan Then
cat fifo | nc -u -l 8888 > fifo which runs nc (netcat) in UDP server mode at port 8888, redirects output to fifo, and pipes through fifo to nc. To test the echo server, on H1 nc -u h2 8888 and type any input---it will be echoed back by H2 and shown on H1. Use tcpdump on R tcpdump -n -l -i r-eth1 udp port 8888
to verify it.
Connection Management
PAYLOAD are all case sensitive. For unrecognized or incompatible COMMAND and Headers (e.g., DAT packets missing Sequence number and Length, ACK packets missing Acknowledgment number and Window, and so on), RDP will reset the connection with RST, and there is no ACK for RST.
Data Transfer
Once connected, the RDP sender can send DAT (data) packets to the receiver, each with a Sequence number header indicating the sequence number of the first bytes of the PAYLOAD, and Length indicating the size of the
PAYLOAD in bytes. The RDP receiver will acknowledge the received DAT packets cumulatively, using the
Acknowledgment header indicating the first byte expected in the next PAYLOAD, as well as the Window size.
How to emulate Internet delay On R, tc qdisc add dev r-eth1 root netem delay 100ms will add 100 millisecond delay at the output queue of r-eth1.
Flow Control
The RDP receiver will advertise its receiver window in ACK packets with the Window header. The RDP sender shall respect the Window size and shall not send any data with sequence number equal to or above Acknowledgment+Windows.
How to emulate Internet delay and loss On R
tc qdisc change dev r-eth1 root netem delay 100ms loss 25% after the above command will add 100 millisecond delay and set 25% packet loss at the output queue of r-eth1.
Error Control
on H1 will bind rdp to ip_address and port_number to send or receive UDP packets, and to transfer a file with read_file_name from the RDP sender to receiver saved with write_file_name. After the file transfer is finished, diff read_file_name write_file_name
on H1 can tell you whether the received file is different from the sent file of length greater than 10,240 bytes.
What RDP outputs
How to test and evaluate RDP
Run the echo server on H2, run tcpdump on R to capture the interaction between H1 and H2, and run rdp.py on H1. It is very important to correlate the packet exchange between H1 and H2 and the endpoint reaction at H1 for both the RDP sender and receiver through the RDP log, which can help you debug your code as well.
Although RDP sender and receiver are in the same rdp.py on H1, RDP protocol and logic cannot be bypassed.
What to submit: rdp.py source file, and the tcpdump files on R, showing the interaction between H1 and H2.
Please also copy&paste the content of rdp.py and tcpdump -r the capture file to the text input box on connex.
Questions and answers (Please read P2 Spec carefully first): brightspace => forums => p2
Appendix A: How does PicoNet emulate an Internet with delay and loss?
Appendix B: A basic design for your reference