Question: Need help filling in the code for this assignment. UDP Pinger Lab In this lab, you will learn how to send and receive datagram packets
UDP Pinger Lab In this lab, you will learn how to send and receive datagram packets using UDP sockets and also, how to set a proper socket timcout. Throughout the lab, you will gain familiarity with a Ping application and its usefulness in computing statistics such as packet loss rate. You will first study a simple Internet ping server written in the Python, and implement a comesponding 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 to other machines You are given the complete code for the Ping server below. 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 # UDPPingerServer.py We will need the following module to generate randomized lost packets import random from socket import # Create a UDP socket Notice the use of SOCK_DGRAM for UDP packets serverSocket-socket (AF INET, SOCK DGRAM) # Assign IP address and port number to socket serverSocket.bind((',12000) while True: Generate random number in the range of 0 to 10 rand random. randi nt (0, 10 Receive the elient packet along with the address it is coming Erom message, address serversoekee.recvfrom 1024) VCapitalize the message from the client message = message. upper() If rand is less is than 4, we consider the packet lost and do not respond
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
