Programing in python.

1 answer below »
see attached


Programing in python.
Answered Same DayOct 28, 2021

Answer To: Programing in python.

Shashi Kant answered on Oct 29 2021
123 Votes
UDP/clientSnap1.jpg
UDP/Report..odt
UDP PINGER
In this project I have created a Ping program for Client.
Here ther are two files:
    
    Client.py
    Server.py
Client.py is the one who will send the ping message which will be a simple me
ssage ping and if the server respond the it will get parellel message from the server too.
Here I have checked RTT which is Round-Trip Time, So the Client side will check the max, min RTT.
RTT is nothing but the time delay which was happened after ping the server and got the response from the server.
In this program Client side will ping 10 time for the server and if server gives the response then it will count them.
If server is not giving response since it is UDP then it will be counted as well that how many time server didn’t gave the response and it will be displayed at the end.
If Client didn’t got the response from the server then the client side will understand that since it is UDP connection so data has been lost and it will display the result that Requested time has been out.
Client will for 1 sec to get the response from the server.
Now we will see the Client.py code :
Here I am importing the modules which are needed -
import socket
from decimal import Decimal
import time
Here I am creating socket which is UDP on localhost-
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server_addr = ('localhost', 12110)
Here I have declared that once the Client side will hit to server it will wait for 1 Sec to get the response from the server.
sock.settimeout(1)
Here I have declared the count “0” for the client that how many times Client got response from the server and how many times the server didn’t responed.
lost =0.0
reciv = 0.0
Here I am checking when i is 1 then do some certain task so from that i will be able to track Max RTT and Min RTT.
try:
for i in range(1, 11):
if i == 1:
Here I have started time to track RTT and it will stop once the Client got the response from the server.
start = time.time()
.
.
sent message
.
.
received message
Here I am storing the end time to check how much time it took to complete the taske.
end = time.time();
Here I have used sendto() message for the Client from where the ping message will be send to the server.
Time() I have used to trace the time for the ping from the Client and the response from the Server.
     start = time.time()
     ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here