Question

Using python 3 to create the UDP Ping Clien and server. Using UDP sockets, you will...

Using python 3 to create the UDP Ping Clien 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 4-byte integers and must be encoded in network-byte order as follows1:

  • 4-byte message type with an integer value of 1 or 2

    • Message type = 1 for a ping request (message from client to server)

    • Message type =2 for a ping response (message from server to client)

  • 4-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 input parameters:

  • IP address of server

  • IP port of server

The client program will read in the above input parameters, 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, Max, Average RTT for all acknowledged ping packets

The server will read in the input arguments, 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 randomly4 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 < 4, do not respond to the packet.

In a ping request, the application data has the following format:

0 1 2 3 4 (bytes)

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

| Message Type (1= request) |

--------------------------------------------------------------------------------

| Message sequence number (e.g. 5) |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

In a ping response, the application data has the following format:

0 1 2 3 4 (bytes)

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

| Message Type (2 = response) |

--------------------------------------------------------------------------------

| Message sequence number (e.g. 5) |

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Examples of the client program trace output are as follows:

Pinging 127.0.0.1, 12000:

Ping message number 1 timed out

Ping message number 2 RTT: 0.002154 secs

.

Ping message number 10 RTT: 0.000194 secs

Examples of the server program trace output are as follows:

The server is ready to receive on port: 12000

Message with sequence number 1 dropped

Responding to ping request with sequence number 2

Responding to ping request with sequence number 10

Notes:

  1. Timestamp Resolution:

When testing your program, especially when running client and server on the same host, you might find little difference in the timestamp values. The values will depend on the test environment, and timer resolution on your machine. If there are issues, you should simulate longer delays, by adding in a random "wait" or "sleep" function on the server before sending a ping response on receipt of a message.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I hope you understand. I tried my level best to answer this question. Please give me a upvote. Thank You

Add a comment
Know the answer?
Add Answer to:
Using python 3 to create the UDP Ping Clien and server. Using UDP sockets, you will...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Project 4-3: In the following steps, you will learn more about the PING (Packet Internet Grouper)...

    Project 4-3: In the following steps, you will learn more about the PING (Packet Internet Grouper) utility, which can be used on a network running IPv4 to verify that TCP/IP is configured correctly and communicating with the network. A ping test is typically the first thing network professionals try when troubleshooting a TCP/IP connection problem. For this project, you can use any type of workstation that's running TCP/IPv4, preferably one connected to the Internet. The output described in the following...

  • Project Description In this project, you will be developing a multithreaded Web server and a simple...

    Project Description In this project, you will be developing a multithreaded Web server and a simple web client. The Web server and Web client communicate using a text-based protocol called HTTP (Hypertext Transfer Protocol). Requirements for the Web server The server is able to handle multiple requests concurrently. This means the implementation is multithreaded. In the main thread, the server listens to a specified port, e.g., 8080. Upon receiving an HTTP request, the server sets up a TCP connection to...

  • Using the programming language of your choice, write a client application which: Connects to a network...

    Using the programming language of your choice, write a client application which: Connects to a network service, then Asks for version information, then Receives the response, then Disconnects and Prints out the response. Detail: The program will take no input from the user. When your program is executed, it should connect to IP address 64.183.98.170 on port 3800. Upon successful connection, send the string: version\n where \n is an end of line marker. The server will respond with a string...

  • implement the follwing code using command promp or Eclipse or any other program you are familiar with. keep the name of...

    implement the follwing code using command promp or Eclipse or any other program you are familiar with. keep the name of the classes exatcly the same as requested for testing purpose. please follow each instruction provided below Objective of this assignment o get you famililar with developing and implementing TCP or UDP sockets. What you need to do: I. Implement a simple TCP Client-Server application 2. and analyze round trip time measurements for each of the above applications 3. The...

  • Here is the description of the client and server programs that you need to develop in C using TCP: Suppose we have a simple student query system, where the server keeps student's info in an array...

    Here is the description of the client and server programs that you need to develop in C using TCP: Suppose we have a simple student query system, where the server keeps student's info in an array of struct student_info ( char abc123171 char name [101 double GPA; To simplify the tasks, the server should create a static array of 10 students with random abc123, name, and GPA in the server program. Then the server waits for clients. When a client...

  • Assignment One program will be the update server and the other will be the update client....

    Assignment One program will be the update server and the other will be the update client. Here is how the two programs should interact with each other: Server 1. the server starts up and reads the version number in the data.bin file and stores it in memory. 2. The server binds to a port and awaits connections. Client 1. The client starts up and it will first read the version number found within it's own data.bin file. 2. The client...

  • You are to write a Java program using the following instructions to build a bank-ATM server...

    You are to write a Java program using the following instructions to build a bank-ATM server system with sockets. A bank holds accounts that can have deposits, withdrawals, or retrievals of balance. The bank server provides the account for transactions when a client uses and ATM machine. The ATM asks for the type of transaction and the amount (if needed), then creates a socket connection to the bank to send the transaction for processing. The bank performs the transaction on...

  • You can refer chapter 2 and chapter 3 of Computer Networking: A Top-Down approach by Kurose...

    You can refer chapter 2 and chapter 3 of Computer Networking: A Top-Down approach by Kurose and Ross for the following labs. Please read the instructions below for submissions. Upload the shared pcap file (Homework5.pacp) into wireshark. HTTP In this lab, we’ll explore several aspects of the HTTP protocol. Capture packets and filter for http protocol and answer the following questions. (Hint: Apply http filer) What version of HTTP version(1.0 or 1.1) is client running and what is the version...

  • Problem: Implement a FIFO program in which a client sends the server 3 variable names (strings)....

    Problem: Implement a FIFO program in which a client sends the server 3 variable names (strings). A valid variable name is defined for this assignment to be 6 characters or less, consisting only of lower-case letters from a to 'z', inclusive. The server checks the name for validity, and if valid, it counts the number of in the variable name. Each of the original variable names is sent back to the client, along with a message whether it is valid...

  • ANSWER NETWORKS QUESTIONS (MCQS AND CALCULATIONS) QUESTIONS ( 11 - 20) QUESTION 11 1.     Consider the following...

    ANSWER NETWORKS QUESTIONS (MCQS AND CALCULATIONS) QUESTIONS ( 11 - 20) QUESTION 11 1.     Consider the following excerpt from a simple server side UDP program: Server.py from socket import * sName=’127.0.0.1’ sSocket=socket(AF_INET,SOCK_DGRAM) sSocket.bind((sName, 12005)) while True: msg, cAddr =sSocket.recvfrom(2048) newMsg = msg.decode().lower()   sSocket.sendto(*********************) What code could be used to replace the **********’s in line 8? newMsg.encode(), cAddr newMsg.encode() msg.encode(), cAddr msg.encode() none of the above 1 points    QUESTION 12 For a client to obtain an IP address from the local...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT