This function “closeSocket” allows to close TCP and UDP sockets.
The function “createSocket” allows the creation of a socket UDP or TCP and returns the socket created. It takes 2 arguments : - “addr” : a tuple of the server’s IP address and the port - “protocol” : type of the socket (“SOCK_DGRAM” or “SOCK_STREAM”)
The function “downloadUDP” allows to send data with a random size during the “duration” informed by the user. It sends data with a rate forced every second to the bandwidth given by the user.
The function “parameters” allows to recover parameters from the client (“interval”, “duration”, “bandwidth”, “upload” and “download”). Before recovering parameters, the function does a synchronization with the client sending a start message. This function tests also if the input bandwidth exceeds the maximum buffer of the function “sendto()”.
This function “uploadUDP” allows to count the size of received data during every interval and calculate the bandwidth for each interval It adds every measure of the bandwidth in a list called “listFinal”.