我在一个UDP Pinger实验室工作
以下是说明中的完整问题: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).
在开始这一部分之前,我必须创建一个客户端Python代码,该代码与提供给我的服务器代码一起使用。在
以下是给我的服务器代码:import random
from socket import *
serverSocket = socket(AF_INET, SOCK_DGRAM)
serverSocket.bind(('', 12000))
while True:
rand = random.randint(0, 10)
message, address = serverSocket.recvfrom(1024)
message = message.upper()
if rand < 4:
continue
serverSocket.sendto(message, address)
这是我的客户端代码,在命令提示符下工作:
^{pr2}$