Project Requirements
In this project, students will learn hands-on experience on both TCP and UDP socket programming. Students are required to write a program (STUDENT) to interact with the provided program (ROBOT). You are allowed to use the ROBOT source codes given (written in C/C++ and Python) in the project package to complete this project. All students should finish steps 1 to 8. Steps 1 to 6 give you a taste of basic programming. Steps 7 to 8 ask you to do som e sim ple experim ents using the programs. You must do this project by yourself. However, you are allowed to discuss with your friends or fellow students, but DO NOT copy others’ code. We will do code-similarity-checking after submission.
Basic Programming Part:
Your program has to interact with ROBOT according to the following steps:
- Start the ROBOT by running “robot.exe” in a command prompt.
- When the ROBOT is started, a message “ROBOT IS STARTED” will be printed, indicating that the ROBOT is now listening on TCP Port 3310. STUDENT has to connect to the ROBOT TCP Port 3310 and send your 10 char student ID string via the connection established.
- The ROBOT will then send a 5 char string ddddd to the STUDENT. STUDENT will need to create a TCP socket s_2 at port ddddd to accept a new connection. The ROBOT will initiate the new connection 1 second later after sending ddddd.
Upon accepting the connection, a new socket s2 will be returned.
Page1of6
4. ROBOT will then send a 12 char string “fffff,eeeee.” to the STUDENT using the new connection. STUDENT needs to decode the message and create a UDP socket s3 to send a randomly generated variable num ( 5 < num < 10) to ROBOT on port fffff. Then ROBOT will send a char string xxx with length num * 10 to STUDENT one second after receiving num and STUDENT will receive the string using s3 on port eeeee .
STUDENT
ROBOT
UDP port: fffff
After receiving num, wait for 1 second to send char string xxx
SOCKET s2
SOCKET s3 on port: eeeee
Recv 12 char string fffff,eeeee.
Sendto variable num
Recv num* 10 char string xxx.
ROBOT will send the string xxx 5 times, once every 1 second. STUDENT only needs to receive any one of them.
5. When the STUDENT received the char string xxx, it will send back the string to the ROBOT at UDP port fffff. Similar to the ROBOT, the string will be sent 5 times, once every 1 second. The ROBOT will check if the two strings are the same.
STUDENT ROBOT Sendto num*10 char string 5 times
SOCKET s3
num*10 charstring
6. In this step, you need to run ROBOT and STUDENT on 2 different machines and make sure all the steps above can be successfully executed. You may need to use Wireshark on the machines for network level debugging if necessary, e.g., if there is a firewall on either of the machine and/or along their end-to-end path, the programs may fail.
Page2of6
UDP port: fffff
It is then your responsibility to fix it, e.g. by choosing a different pair of machines elsewhere and/or configure them properly.
(Forsteps1to6,theoriginalprovidedROBOTwillbeusedtotestyourSTUDENTprogram.)
Experiment Part:
7. In this step, you will study the effect of the receiver buffer size for the TCP socket s2 on port ddddd by modifying the codes for both ROBOT and STUDENT.
Firstly, you get the existing receiver buffer size of s2 on STUDENT and print it out. Then you must inform ROBOT of this receiver buffer size on TCP Port 3310 by modifying both the STUDENT as well as ROBOT code: STUDENT will need to include some keywords in the string to signal ROBOT that the value is the buffer-size information (e.g. the string can be “bsxxx”, where xxx is the size of your buffer). Modify the source code of ROBOT, so that when it receives the buffer- size information from the STUDENT, it will send a large number of packets to STUDENT’s s2 port as quickly as possible for a period of 30 seconds. STUDENT should be modified so that it can count the size and number of packets actually received in this period and printout the total number of packets STUDENT receives, together with . In addition,
An example printout can be:
[STUDENT] Numberofreceivedpackets:xxx xxx.
total received bytes
every ten seconds or after receiving all packets.
you could either printout the statistics
Remark:
1) The receiver buffer size we discussed here is the internal buffer size, which will
be allocated for each individual connection. Don’t confuse it with the
parameters in recv().
2) The packet size can be any value, but we encourage you to set it equals to the
receiving buffer size.
Important:
8. Design the code for STUDENT and ROBOT for Step 7 so that they will repeat the entire procedure in Step 7 after STUDENT changes its receiver buffer size over a wide range of values, e.g. [1, 5, 10, 25, 50, 200, 500 or even 1000] % of 1000 bytes. Compare the corresponding TCP throughput from ROBOT to STUDENT as the latter’s receiver buffer size changes. The results should be written in the report. The result should contain the graph showing the relation between the receiver buffer size and the system throughput, as well as your interpretation.
An additional question to be answered in the Lab report: What is the limitation of the experiment set-up since we do it in IE Common Lab? (Hint: What if the network is a low-speed one? )
Page3of6
, total received bytes:
Please argue how and why the receiver buffer size affects the performance in your
report.
Remark: System throughput = total received bytes / duratio
Page4of6
Page5of6