subject

Another similar application to the UDP Ping would be the UDP Heartbeat. The Heartbeat can be used to check if an application is up and running on the client side and to report one-way packet loss. The client continuously sends a message acting as a heartbeat in the UDP packet to the server, which is monitoring the heartbeat (i. e., the UDP packets) of the client. Upon receiving the packets, the server calculates the time difference. If the heartbeat packets are missing for some specified time interval, the server can assume that the client application has stopped working. Implement the UDP Heartbeat (both client and server). You will need to modify the given udppingserver. py, and your udppingclient. py.
The client program sends a ping message to the server using UDP every 5 seconds.
The server program monitors if a ping is received from the client. If the ping from the client was absent for more than 10 seconds, it prints the message "No pulse after 10 seconds. Server quits".
Current udppingserver. py file:
# udppingserver. 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(('', 45678))
while True:
# Generate random number in the range of 0 to 10
rand = random. randint(0, 10)
# Receive the client packet along with the address it is coming from
message, address = serverSocket. recvfrom(1024)
# If rand is less is than 4, we consider the packet lost, do not respond
if rand < 4:
continue
# Otherwise, the server responds
serverSocket. sendto(message, address)
Current udppingclient. py file:
UDPPinglerClient. py
import socket
from socket import AF_INET, SOCK_DGRAM
import time
print 'Running'
serverName = '127.0.0.1' #server set as localhost
clientSocket = socket. socket(AF_INET, SOCK_DGRAM) #create the socket
clientSocket. settimeout(1) #sets the timeout at 1 sec
sequence_number = 1 #variable to keep track of the sequence number
rtt=[] # list to store the rtt values
while sequence_number<=10:
start=time. time() #the current time
message = ('PING %d %d' % (sequence_number, start)) #client message
clientSocket. sendto(message,(serverName, 11046))#client sends a message to the server
try:
message, address = clientSocket. recvfrom(1024) #recieves message from server
elapsed = (time. time()-start) # calculates the rtt
rtt. append(elapsed)
print message
print 'Round Trip Time is:' + str(elapsed) + ' seconds'
except socket. timeout: #if no reply within 1 second
print message
print 'Request timed out'
sequence_number+=1 #incremented by 1
if sequence_number > 10: #closes the socket after 10 packets
mean=sum(rtt, 0.0)/ len(rtt)
print ''
print 'Maximum RTT is:' + str(max(rtt)) + ' seconds'
print 'Minimum RTT is:' + str(min(rtt)) + ' seconds'
print 'Average RTT is:' + str(mean)+ ' seconds'
print 'Packet loss rate is:' + str((10-len(rtt))*10)+ ' percent'
clientSocket. close()

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:50
Explain why it is reasonable to assume that receiving 3 duplicate acks in tcp is an indication that the network is not currently congested.
Answers: 1
question
Computers and Technology, 22.06.2019 14:00
Which database model is best used for data warehouse and data mining
Answers: 3
question
Computers and Technology, 22.06.2019 17:30
Which tab should you open to find the option for adding a header?
Answers: 1
question
Computers and Technology, 22.06.2019 22:00
Researchers measured the data speeds for a particular smartphone carrier at 50 airports. the highest speed measured was 78.1 mbps. the complete list of 50 data speeds has a mean of x overbarequals16.11 mbps and a standard deviation of sequals18.65 mbps. a. what is the difference between carrier's highest data speed and the mean of all 50 data speeds? b. how many standard deviations is that [the difference found in part (a)]? c. convert the carrier's highest data speed to a z score. d. if we consider data speeds that convert to z scores between minus2 and 2 to be neither significantly low nor significantly high, is the carrier's highest data speed significant? a. the difference is nothing mbps.
Answers: 3
You know the right answer?
Another similar application to the UDP Ping would be the UDP Heartbeat. The Heartbeat can be used to...
Questions
question
English, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
question
Social Studies, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
question
English, 14.09.2020 23:01
question
English, 14.09.2020 23:01
question
History, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
question
Geography, 14.09.2020 23:01
question
History, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
question
English, 14.09.2020 23:01
question
Mathematics, 14.09.2020 23:01
Questions on the website: 13722361