如何解决UDP 数据包不会在wireshark 中捕获
我在 python 中设置了简单的服务器/客户端,并通过端口号为 1234 的 UDP 协议在它们之间来回发送信息。但是,这些数据包不会在 Wireshark 中捕获。 有人可以帮我过滤吗? 我的服务器代码:
import socket
#CONfigURATION OF THE SERVERPORT
serverPort=1234
#CONfigURATION OF THE SERVERSOCKET
serverSocket=socket.socket(socket.AF_INET,socket.soCK_DGRAM)
#GENErating THE ARTIFICIAL SERVER
serverSocket.bind((socket.gethostname(),serverPort))
print("server is ready to receive")
#sending the server into listening mode
while 1:
#server is gettinbg the client info
#plus we also get the address
msgandaddress=serverSocket.recvfrom(1024)
#server is reading the text
a=(msgandaddress[0].decode())
#server is sending the response
filecomposition="response sent for "+str(a)
#server is sending the composition to the client
serverSocket.sendto(filecomposition.encode(),msgandaddress[1])
我的客户代码
import socket
from datetime import datetime
import time
#configuring the server port
serverPort=1234
#configuring the socket to UDP
clientsocket=socket.socket(socket.AF_INET,socket.soCK_DGRAM)
print(socket.gethostname())
for i in range(0,1):
#marking the starttime
starttime=datetime.Now()
#sending the message at the specific time
clientsocket.sendto(str(i).encode(),(socket.gethostname(),serverPort))
print("ping has been sent at "+str(starttime))
#receiving the message at the specific time
responseandaddress=clientsocket.recvfrom(1024)
endttime=datetime.Now()
print("pong has been received at "+str(endttime))
#calculating the difference
print(str(i)+"."+" RTT TIME:"+str((endttime-starttime).total_seconds()))
print("\n\n")
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。