Question: Programming Assignment 2: UDP Ping Client and Server Using UDP sockets, you will write a client and server program that enables the client to determine

 Programming Assignment 2: UDP Ping Client and Server Using UDP sockets,you will write a client and server program that enables the client

Programming Assignment 2: UDP Ping Client and Server Using UDP sockets, you will write a client and server program that enables the client to determine the round-trip time (RTT) to the server. To determine the RTT delay, the client records the time on sending a ping request to the server, and then records the time on receiving a ping response from the server. The difference in the two times is the RTT. . The ping message contains 2 2-byte integers and must be encoded in network-byte order as follows: 2-byte message type with an integer value of 1 or 2 o Message type = 1 for a ping request (message from client to server) o Message type =2 for a ping response (message from server to client) 2-byte sequence number with a unique integer value starting from 12. In the ping response, the server should echo back the client's sequence number. . Both the client and server program should take the following command-line arguments: IP address of server IP port of server . . The client program will read in the above command-line arguments, and send 10 ping requests consecutively to the server running at the specified IP address and port, waiting for a response each time. After each response is received, the client calculates and prints the RTT for the message. If no response is received within a certain amount of time (one second)3, the client notes that the request timed out and then sends the next request up to the maximum. The program output should print out trace information when data is sent and received, and account for error conditions. Trace output must include: At start of output, print a message indicating the IP address and port of the server being pinged For each ping response received, print RTT along with sequence number of ping message For no ping response, print "Message timed out" along with sequence number of the ping message After completion, print the following statistics (similar to output of UNIX ping utility); Number of packets sent, received, lost (% loss rate) Min and Max RTT for all acknowledged ping packets . O o 1 See struct.pack() and struct.unpack() functions to encode integers into a sequence of bytes in network byte order in https://docs.python.org/3/library/struct.html 2 A message sequence number is a unique identifier for the packet. Start numbering from 1, and increment the number by one for each message sent. For example, the sequence number of the first ping request sent from the client is 1, the second ping request has a sequence number of 2, and so on, up until the last ping request which should have a sequence number of 10. 3 The socket library provides the ability to set a timeout value on a socket. An exception is raised if the timeout value expires before the socket operation has completed. The server will bind to the specified IP address and port, and wait in an infinite loop to receive ping requests from the client. On receiving a ping request, the server program will randomly decide whether to respond to ping requests to simulate network packet loss. In the case that the server responds, it sends a ping response containing the appropriate message type, and client sequence number. In the case that the server decides not to respond, no ping response is sent, and the server waits for another ping request. To implement random "loss, the server should generate a random integer between 0 and 10 and if the result is

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!