Computer Communications and Networks (COMN) 2022/23, Semester 1 Assignment 2
联系我们: 手动添加方式: 微信>添加朋友>企业微信联系人>13262280223 或者 QQ: 1483266981
Computer Communications and Networks (COMN)
2022/23, Semester 1
Assignment 2
Please carefully read this whole document before ge迁ing started on this assignment.
Overview
The overall goal of this assignment is to implement and evaluate di erent protocols for achieving end-to-end reliable data transfer at the application layer over the unreliable datagram protocol (UDP) transport protocol. In particular, you are asked to implement three di erent sliding window protocols – Stop-and-Wait, Go Back N and Selective Repeat – at the application layer using UDP sockets in Python. Note that the stop-and-wait protocol can be viewed as a special kind of sliding window protocol in which sender and receiver window sizes are both equal to 1. For each of these three sliding window protocols, you will need to implement the two protocol endpoints referred henceforth as sender and receiver respectively; these endpoints also act as application programs. Data communication is unidirectional, requiring transfer of a large le from the sender to the receiver over a link as a sequence of smaller messages. The underlying link is assumed to be symmetric in terms of bandwidth and delay characteristics.
To test your protocol implementations and study their performance in a controlled environment, you will need to use your COMN coursework virtual machine (VM) [1]. Speci cally, the sender and receiver processes for each of the three protocols will run within the same VM and communicate with each other over a link emulated using Linux Tra c Control (TC) [2]. For this assignment, you only need the basic functionality of TC to emulate a link with desired characteristics in terms of bandwidth, delay and packet loss rate.
Since the coursework VM does not include a graphical text editor, we suggest you develop your protocol implementations outside of it in the directory/folder containing the ‘Vagrant le’ . These les would appear under “/vagrant” within your VM, from where you can compile and run them.
Link Emulation using TC
Within your COMN coursework VM, you can con gure and use the TC utility to realize an emulated link between two communicating processes (e.g., your sender and receiver programs). TC is a very useful tool that allows you to con gure the kernel packet scheduler to emulate packet delay and loss, and limit bandwidth for UDP or TCP applications. Because sender and receiver processes for this assignment are going to be within the same VM, they would communicate with each other through the loopback interface (lo).
The following outlines how the sender receiver link via lo can be con gured using TC to emulate di erent link conditions. For example, the following tc command adds a rule to the loopback interface scheduler to realize a link with 10ms one-way propagation delay (equivalently, 20ms round-trip propagation delay given our symmetric link assumption), 0.5% packet loss rate and 5 Mbit/s bandwidth limit in each direction:
% sudo tc qdisc add dev lo root netem loss 0.5% delay 10ms rate 5mbit You can verify the e ect of the above rule by running the following command: % ping 127.0.0.1
You will nd that ping reports an average RTT of 20ms and a packet loss that is approximately 1%.
Note that using the loopback interface and con guring it with tc as above allows emulation of a symmetric link between sender and receiver. A packet sent from sender to receiver goes through the loopback interface once; and one more time for the return (receiver to sender) communication, essentially resulting in round-trip propagation delay and total packet loss rate that are double that of the se计ings used in the tc command for con guring these two parameters (as shown in the example above).
You can use the following command to ush all previous con guration rules: % sudo tc qdisc del dev lo root
We assume that packets are not corrupted in transit (i.e., no bit errors). So there is no need to implement error detection functionality such as checksum at the endpoints.
Whole packets, however, can be lost over the emulated link over the loopback interface, as determined by the packet loss rate se迁ing when con guring it with the tc command. For more information on TC, please refer to [2].
Besides TC, the coursework VM comes with other networking utilities that you may nd useful while working on this assignment. These include:
● tcpdump
● iperf
● netcat
Note that these tools are explicitly mentioned so that you know they are available to use. The tcpdump tool is very useful to verify the correctness of the implemented protocols, whereas you’ll need iperf for part 4 of this assignment.
Note that each part of this assignment speci cation (detailed below) states the TC con guration parameters to be used. It is important to set the parameters as speci ed in order to correctly do this assignment. Also note that TC delay and loss rate con guration se迁ings are only approximately realized and as such results may vary. So we encourage students to repeat each experiment multiple times and use the average result.
Detailed Assignment Speci cation
This assignment is divided into four parts. These parts are related but distinct as detailed below.
Part 1: Basic framework (large le transmission under ideal conditions)
Implement sender and receiver endpoints for transferring a large le given at [3] from the sender to the receiver on localhost over UDP as a sequence of small messages with 1KB maximum payload (NB. 1KB = 1024 bytes) via the loopback interface, con gured with 10Mbps bandwidth, 5ms one-way propagation delay and 0% packet loss rate (i.e., no packet loss). In this con guration, the total round-trip propagation delay is 10ms.
Each data message from sender to receiver would have to be 1027 bytes long – 3 bytes for the “header” and 1024 bytes of data. The header in turn consists of 2 bytes of sequence number (for duplicate detection at the receiver) and 1 byte end-of- le (EoF) ag to indicate the last message. Note that the header must be at the beginning of each packet.
Name the sender and receiver developed in this part, respectively, as Sender1.py and Receiver1.py. The receiver should store the transmi计ed data (after removing header from packet) into a local le.
● Sender program must be named as speci ed above and must accept the following options from the command line:
python3 Sender1.py
speci ed as either 127.0.0.1 or localhost.
For example: python3 Sender1.py localhost 54321 sfile
● Receiver program must be named as speci ed above and must accept the following options from the command line:
python3 Receiver1.py
● Expected output: A successfully transferred le to the receiver; both sent and received les must be identical at a binary level when checked using the diff command.
Part 2: Stop-and-Wait
Extend sender and receiver applications from Part 1 to implement a stop-and-wait protocol described in section 3.4.1 in [4], speci cally rdt3.0. [Hint: You need two nite state machines (FSMs) — one for rdt3.0 sender and the other for rdt3.0 receiver. While the sender FSM is presented in [4], there is no rdt3.0 receiver FSM. The rdt3.0 receiver FSM is the rdt2.2 receiver FSM in [4]. Convince yourself why the rdt2.2 receiver FSM is su cient before you begin to implement the rdt3.0 protocol.] Call the resulting two applications Sender2.py and Receiver2.py, respectively. This part requires you to de ne an acknowledgement (ACK) message that the receiver will use to inform the sender about the receipt of a data message. Discarding duplicates at the receiver end using sequence numbers put in by the sender is also required. You can test the working of duplicate detection functionality in your implementation by using a small retransmission timeout on the sender side. ACK messages have to be 2 bytes each to hold the sequence number.
● Sender program must be named as speci ed above and must accept the following options from the command line:
python3 Sender2.py
For example: python3 Sender2.py localhost 54321 sfile 10
● Receiver program must be named as speci ed above and must accept the following options from the command line:
python3 Receiver2.py
● Expected output: (1) A successfully transferred le to the receiver. Note that both sent and received les must be identical at a binary level; and (2) the sender must output the number of retransmissions and throughput (in Kbytes/second) only in a single line; no other terminal output should be displayed; the following output implies that the number of retransmissions is 10 and the throughput is 200 Kbytes/second:
10 200
Using a 5% packet loss rate while leaving the rest of TC con guration parameters as before (i.e., 10Mbps bandwidth and 5ms one-way propagation delay), experiment with di erent retransmission timeouts to measure the corresponding number of retransmissions and throughput. Tabulate your observations in the space provided under Question 1 in the results sheet [5]. For this, your sender implementation should count the number of retransmissions and measure average throughput (in KB/s), which is de ned as the ratio of le size (in KB) to the transfer time (in seconds). Transfer time in turn can be measured at the sender as the interval between rst message transmission time and acknowledgement receipt time for last message. Before the sender application nishes and quits, print the average throughput value to the standard output.
Then for Question 2 in the results sheet [5], discuss the impact of retransmission timeout on the number of retransmissions and throughput. Also indicate the optimal timeout value from a communication e ciency viewpoint (i.e., the timeout that minimizes the number of retransmissions while ensuring a high throughput). Please clearly explain your observations.
Part 3: Go-Back-N
Extend Sender2.py and Receiver2.py from Part 2 to implement the Go-Back-N protocol as described in section 3.4.3 of [4], by allowing the sender window size to be greater than 1. Name the sender and receiver implementations from this part, respectively, as Sender3.py and Receiver3.py.
● Sender program must be named as speci ed above and must accept the following options from the command line:
python3 Sender3.py
speci ed as either 127.0.0.1 or localhost.
For example: python3 Sender3.py localhost 54321 sfile 10 5
● Receiver program must be named as speci ed above and must accept the following options from the command line:
python3 Receiver3.py
● Expected output: (1) A successfully transferred le to the receiver. Note that both sent and received les must be identical at a binary level; and (2) the sender must output throughput (in Kbytes/second) only in a single line. No other terminal output should be displayed. For example, the following output implies that the throughput is 200 Kbytes/second:
200
Experiment with di erent window sizes at the sender (increasing in powers of 2 starting from 1) and di erent one-way propagation delay values (5ms, 25ms and 100ms). For the 5ms case, use the “optimal” value for the retransmission timeout identi ed from part 2. The timeout values for the other two cases should be justi ed clearly. Across all these experiments, use the following values for the other TC parameters: 10Mbps bandwidth and 5% packet loss rate in each direction. Tabulate your results under Question 3 and answer Question 4 in the results sheet [5].
Part 4: Selective Repeat
Extend Sender3.py and Receiver3.py to implement the selective repeat protocol as described in section 3.4.4 of [4]. Call the resulting two applications, respectively, as Sender4.py and Receiver4.py.
● Sender program must be named as speci ed above and must accept the following options from the command line:
python3 Sender4.py
speci ed as either 127.0.0.1 or localhost.
For example: python3 Sender4.py localhost 54321 sfile 10 5
● Receiver program must be named as speci ed above and must accept the following options from the command line:
python3 Receiver4.py
For example: python3 Receiver4.py 54321 rfile 10
● Expected output: (1) A successfully transferred le to the receiver. Note that both sent and received les must be identical at a binary level; and (2) The sender must output throughput (in Kbytes/second) only in a single line. No other terminal output should be displayed. The following output implies that the throughput is
200 Kbytes/second: 200
By con guring the TC link with 10Mbps bandwidth, 25ms one-way propagation delay and 5% packet loss rate, experiment with di erent window size values and complete the table under Question 5 and answer Question 6 in [5].
As another step in this part, also carry out an equivalent experiment using iperf with TCP within your COMN coursework VM, i.e., both iperf client and server running inside it. Use –M option in iperfto set the maximum segment size to 1KB and vary the TCP window sizes using the –w option. Note that iperf actually allocates twice the speci ed value, and uses the additional bu er for administrative purposes and internal kernel structures. But this is normal because e ectively TCP uses the value speci ed as the window size for the session, which is the parameter to be varied in this experiment. You also need to specify the le to be transferred (i.e., the one given at [3]) as one of the parameters to iperf on the client side (-F option). In addition, you should use the –t option as well. Use the results of this experiment to complete the table under Question 7 and answer Question 8 in [5].
Implementation Guidelines
Your programs must adhere to the following standard with both sender and receiver application programs to be run inside the COMN coursework VM.
● Note that this assignment will be marked using a fresh installation of COMN coursework VM [1]. This means that any extra package that you install within your VM and use in your code will produce an exception during marking, and in turn would negatively a ect your mark. So, please do not install any additional Python package or library.
● Please make sure to test your code before submi迁ing to avoid issues during marking.
● You need to take appropriate measures for terminating your sender applications by considering cases where the receiver nishes while the sender keeps waiting for acknowledgements.
● You can choose to have common les with functions used in di erent parts but you are required to submit such common les along with the necessary documentation.
● Please use comments in your code!
● Please start each source le with the following comment line: # Forename Surname MatriculationNumber
For example: # John Doe 1234567
● As a general guideline, clearly explain any observations related to the results.
Assessment
This assignment is worth 35% of the overall course mark. Distribution of marks among the di erent parts (as percentage of the course mark) is as given below:
● Part 1 (5%)
● Part 2 (10%)
● Part 3 (10%)
● Part 4 (10%)
Submission
Deadline: This assignment is due by 12 noon GMT on Monday, 21st November 2022.
You must submit an electronic version of your implementations for parts 1-4 (i.e., Sender1.py, Receiver1.py, Sender2.py, Receiver2.py, Sender3.py, Receiver3.py, Sender4.py, Receiver4.py and any common les). Along with these implementations, include the completed version of the results sheet [5] as PDF. Submit a gzipped tar le named cw2.tar.gz of the directory containing the above les. To prepare the submission le, use the following command in your coursework VM just outside (i.e., one level above) the directory containing those les:
tar czf cw2 .tar .gz
Further instructions on the submission procedure will be made available via the Assessment page of the COMN Course Website.
Late submissions of coursework will be dealt with as per Rule 1 of the School of Informatics policy on late submission of coursework .
You are expected to work on this assignment on your own. Or else, you will be commi计ing plagiarism (see School of Informatics guidelines on academic misconduct).
References
1. COMN Coursework Virtual Machine Setup
2. Linux Tra c Control (TC)
3. Test le
4. J. F. Kurose and K. W. Ross, Computer Networking: A Top-Down Approach (8th Edition), Pearson Education, 2021.
5. Results Sheet


发表回复