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, 22.06.2019 15:00
This is not a factor that you should use to determine the content of your presentation. your audience your goals your purpose your technology
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
Word vocabulary words: print, proofread, status line, graphics, font effects, left margin, justification, line spacing, copy/paste, data. review words: font point, bold, save, center, error. fill in the correct word for the definition and then transfer the letters to the appropriate spot by number. some numbers will be found multiple times. you will end up with a quotation about…… what else? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 k 16 17 18 19 20 21 22 23 24 25 8 27 28 29 w 31 32 k 34 35 36 w h 39 40 41 42 8 44 45 46 47 48 49 50 51 52 53 54 55 .1. a software function that records keystrokes on a disk or drive so information can be 5 4 52 9 later retrieved. p n 2. to produce a paper copy of information. 10 7 12u n 3. a display that shows the location of the cursor, pages, etc. 45 46 18 27 36 20 42p4. pictures or images, located in clip art or other files. 6 24 44 28 34 49 555. any mis-stroke of a key. 47 41 48 2 10 n6. allows major changes to the font such as shadow, emboss, etc. 21 25 46 35 23 21 29 14 22 17 n7. a feature that centers lines of text horizontally. 49 53 46 9 51 p8. size of the font 31 16 22 b l 9. a feature that prints designated text darker than the rest to add emphasis. 32 3 . p10. to compare copy on a display screen or printout to the original 24 39 25 23 54 9 50 3 and correct errors. j un 11. a feature that allows text to be aligned at the left 11 12 7 21 16 49 40 46 34 2 and right margins. leftn 12. amount of blank space on the left side of the paper. 8 18 41 6 34 linen 13. number of blank lines between lines of text. 17 4 49 13 1914. any information inputted into the computer. 3 4 46 44 p /p15. feature that duplicates text from one location and places it in another.
Answers: 2
question
Computers and Technology, 23.06.2019 05:00
Acompany is inviting design for its new corporate logo from its users. this is an example of ? a. crowdfunding b. crowdvoting c. crowdsourced design d. crowdtracking
Answers: 3
question
Computers and Technology, 23.06.2019 12:00
If you're using an existing powerpoint presentation that will receive new slides based on a word outline, select the a. slide that will appear after the new slides. b. first slide in the presentation. c. slide that will appear before the new slides. d. last slide in the presentation.
Answers: 2
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
Mathematics, 19.12.2020 02:10
question
Mathematics, 19.12.2020 02:10
question
Mathematics, 19.12.2020 02:10
question
Mathematics, 19.12.2020 02:10
question
Mathematics, 19.12.2020 02:10
question
Social Studies, 19.12.2020 02:10
question
Business, 19.12.2020 02:10
question
Mathematics, 19.12.2020 02:10
Questions on the website: 13722360