Network Programming
Final project dr inż. Radosław Wajman
UDP/TCP transmission speed tester
Aim of the work:
The aim of this work is to implement the client-server computer program for measuring the data transmission speed in unicast mode using two protocols: UDP and TCP. The example of this program may be find under this link.
Conditions:
In order to complete this project it is required to implement two parallel data transmissions. Both transmissions should be in unicast mode but in basis of two different network protocols i.e. TCP and UDP. In a frame of these transmissions from the client to the server module the same data set must be sent. Therefore, two separate applications have to be developed.
The server application:
0 immediately after start-up (or after an user request) asks about:
o the communication port number (the same for TCP and UDP protocols), and creates:
o a thread #1 responsible for TCP listening on user defined port number waiting for the client connection requests,
o a thread #2 responsible for looped UDP messages listening on user defined port,
o a thread #3 responsible for the multicast DISCOVERY requests listening, which right after receiving such request sends to the multicast group the response OFFER:PORT with the TCP/UDP listening port number,
additionally:
0 the thread #1 is able to handle only one client in the same time, therefore after accepting the incoming connection with one client it sends to the others the BUSY command,
0 the thread #1 in a separate child-thread #4 starts (in a loop) waiting for the messages from the connected client and terminates the thread #4 after client disconnect,
0 the threads #1 and #2 create the data buffer of size agreed with the client; the client as a first message sends the command SIZE:xyz with the buffer size value given in bytes,
0 the threads #1 and #2 separately count the amount of data received from the client and prepare the
report to show it in a form e.g.:
Thread (TCP or UDP): received ???kb in time ???sec with the speed ???kb/sec
0 the transmission time is triggered with the first message (in both threads independently).
0 the thread #2 may have implemented the statistic mechanism for lost data analysis in comparison to the data pattern (e.g. the same method for data generation in both client and server modules) and
should print the analysis results in a form:
Thread UDP: the transmission error: ???%
0 the transmission (especially in case of the thread #2) should be stopped after the last command e.g. FINE,
0 the user should be allowed to stop all threads and to close application.
The client application:
0 after start-up:
o in order to find the server creates the thread #1 for sending in a multicast mode the DISCOVER command and waits for the OFFER:PORT response and finally prints the list of found servers,
o provides to the user the possibility to manually input the server IP address and the TCP/UDP communication port number,
o asks the user about the size of the data set (in bytes),
o asks the user about including/excluding the Nagle algorithm:
for C# see (https://msdn.microsoft.com/pl-pl/library/system.net.sockets.socket.nodelay(v=vs.110).aspx),
and then:
0 prepares the data to be sent as the n-elements array of bytes filled with any values (e.g. ascending order),
0 creates two threads:
o (#2) for establishing the TCP connection and continuous data sending (in a loop), o (#3) for continuous data sending (in a loop) using UDP protocol,
additionally:
0 the data sending process within both threads (#2 and #3) should be performed as quick as possible without any additional delays (e.g. acceptable sleep(10) for better threads management),
o please do not forget initially to send the data size synchronization message for both transmissions,
0 the user should be allowed to stop data transmissions closing the TCP sockets and sending the final UDP message e.g. FINE, and next to close the application.
Both applications must be robust to the incorrect date provided by the user.
Please note that the project should be tested only between to computers (in addition connected to different LAN networks in order to enforce the network traffic through the router(s)). Only under this condition it is possible to obtain the differences in a transmission speed.
Other remarks
1. The project should meet all conditions mentioned above written with:
0 the black colour for assessment 3,
0 the blue colour for assessment 4,
0 the green colour for assessment 5;
the functionality defined for assessments 4 and 5 may be considered alternate,
2. The errors and exceptions handling,
3. The readable and clean code.
References
1. C#: https://msdn.microsoft.com/pl-pl/library/tst0kwb1(v=vs.110).aspx
2. JAVA: https://docs.oracle.com/javase/tutorial/networking/datagrams/clientServer.html
案例JAVA Network Programming编程网络计算:UDP/TCP trans
2019-02-19