Home / Expert Answers / Computer Science / project-b-udp-pinger-assignmenttask-descriptionin-this-lab-you-will-learn-the-basics-of-socket-pro-pa891

(Solved): PROJECT B: UDP PINGER ASSIGNMENTTASK DESCRIPTIONIn this lab, you will learn the basics of socket pro ...



PROJECT B: UDP PINGER ASSIGNMENT
TASK DESCRIPTION
In this lab, you will learn the basics of socket programming for UDP in Python. You will learn how to
send and receive datagram packets using UDP sockets and also, how to set a proper socket
timeout. Throughout the lab, you will gain familiarity with a Ping application and its usefulness in
computing statistics such as packet loss rate.
OBJECTIVES
You will first study a simple Internet ping server written in Python, and implement a corresponding
client. The functionality provided by these programs is similar to the functionality provided by
standard ping programs available in modern operating systems. However, these programs use a
simpler protocol, UDP, rather than the standard Internet Control Message Protocol (ICMP) to
communicate with each other. The ping protocol allows a client machine to send a packet of data to
a remote machine, and have the remote machine return the data back to the client unchanged (an
action referred to as echoing). Among other uses, the ping protocol allows hosts to determine round-
trip times (RTT) to other machines.

BRIEF
CODE
You are given the complete code for the Ping server. Your task is to write the Ping client.
SERVER CODE
The following code fully implements a ping server. You need to compile and run this code
before running your client program. You do not need to modify this code. In this server
code, 30% of the client’s packets are simulated to be lost. You should study this code
carefully, as it will help you write your ping client.

The server sits in an infinite loop listening for incoming UDP packets. When a packet comes
in and if a randomised integer is greater than or equal to 4, the server simply capitalises the
encapsulated data and sends it back to the client.
Packet Loss
UDP provides applications with an unreliable transport service. Messages may get lost in the
network due to router queue overflows, faulty hardware, or some other reasons. Because
packet loss is rare or even non-existent in typical campus networks, the server in this lab
injects artificial loss to simulate the effects of network packet loss. The server creates a
variable randomised integer that determines whether a particular incoming packet is lost or
not.
Client Code
You need to implement the following client program.
The client should send 10 pings to the server. Because UDP is an unreliable protocol, a
packet sent from the client to the server may be lost in the network or vice versa. For this
reason, the client cannot wait indefinitely for a reply to a ping message. You should get the
client to wait up to one second for a reply; if no reply is received within one second, your
client program should assume that the packet was lost during transmission across the
network. You will need to set the timeout value on a datagram socket with this code
clientsocket.settimeout(1)
Specifically, your client program should
(1) send the ping message using UDP (Note: Unlike TCP, you do not need to establish a
connection first, since UDP is a connectionless protocol.)
(2) print the response message from the server, if any
(3) calculate and print the round-trip time (RTT), in seconds, of each packet, if server
responses
(4) otherwise, print “Request timed out

During development, you should run the UDPPingerServer.py on your machine, and test
your client by sending packets to localhost (or, 127.0.0.1). After you have fully debugged
your code, you should see how your application communicates across the network with the
ping server and ping client running on different machines.
Message Format
The ping messages in this lab are formatted in a simple way. The client message is one line,
consisting of ASCII characters in the following format:
Ping sequence_number time
where sequence_number starts at 1 and progresses to 10 for each successive ping message
sent by the client, and time is the time when the client sends the message.
Currently, the program calculates the round-trip time for each packet and prints it out
individually. Modify this to correspond to the way the standard ping program works. You will
need to report the minimum, maximum, and average RTTs at the end of all pings from the
client. In addition, calculate the packet loss rate (in percentage).
SUBMISSION
WHAT TO SUBMIT FOR PROJECT 2:
Upload to the Canvas Project B assignment link
1) Project report. The report should explain the UDP Pinger Server python code which was
supplied and, and describe the code you have written for the UDP client together with the
troubleshooting required to get the program running. The suggested word count is 400-
500 words, the report can be in .docx or .pdf format.
2) THE UDPPinger client code. Submit the relevant python file. (.py) make sure to include
your name and student number in the filename.
3) Video - In addition to the written submission, you will create a short video using Canvas
Studio. Your video should verify that your program can :
a) send the ping message using UDP
b) print the response message from server, if any
c) calculate and print the round-trip time (RTT), in seconds, of each packet, if server
responses
d) otherwise, print “Request timed out”


(1) Project B Report
File Format: Word document or pdf
The report should explain the UDP Pinger Server python code which was
UDP_Pinger_Server_Sol.py
I Uoppingerserver, py
We We wilt need the foltowing module to generate randonized lost pockets
inpor
(1) Project B Report File Format: Word document or pdf The report should explain the UDP Pinger Server python code which was supplied and, and describe the code you have written for the UDP client together with the troubleshooting efforts to get the project running Suggested word count 400-500 words Font: 12pt Arial, double spaced. (2) Python file File Format: python file .py UDP_Pinger_Server_Sol.py I Uoppingerserver, py We We wilt need the foltowing module to generate randonized lost pockets inport random from socket inport * serverNane w w input ip address * serverport ' \# Create a UDP socket i* Notice the use of SOCK_DGRAM for UDP pockets serverSocket socket (AF_INET, SOCK_DGRAM) * Assign IP address and port number to socket serversocket. bind((serverNane, 12000)) print ('The server is running on ' +serverNane) while True: \#. Generate random number in the range of to 10 rand random. randint " Receive the client packet along with the address it is coning froi sove as messoge nessage, address = serversocket, recvfron H. Copitotize the messoge from the olient nessage = nessage. upper () " If rand is less is than 4 , we consider the packet lost and do not respond if rand : continue * otherwise, the server responds serversocket. sendto (aessage, address)


We have an Answer from Expert

View Expert Answer

Expert Answer



Here's a detailed step-by-step solution to implement the UDP Pinger client:
Import the required libraries:

2. Define the server's address and port:

3. Create a UDP socket:

4. Set the timeout value for the socket:


We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe