不过,我想让我的手机和个人电脑以某种方式连接起来,在研究的第一步,我做了这些非常简单的测试:
#this is for the udp client file
import socket as soc
import os
server = "192.167.1.4"
serverPort = 12000
value = 0
sockobj = soc.socket(soc.AF_INET, soc.SOCK_DGRAM)
while True:
message = 'This is my secret message: '
message += input("Enter your message: ")
data = message.encode(encoding="UTF-8")
sockobj.sendto(data, (server, serverPort))
if not value:
# os.system("traceroute 192.168.1.4")
value += 1
import time
time.sleep(5)
print("sleep ended")
message, address = sockobj.recvfrom(2048)
print("I got", message.decode())
sockobj.close() __
and this is for the udp server file
import socket as soc
import time
server = ''
serverPort = 12000
sockobj = soc.socket(soc.AF_INET, soc.SOCK_DGRAM)
sockobj.bind((server, serverPort))
while True:
message, clientaddress = sockobj.recvfrom(2048)
print("I got the client's address as: ", clientaddress)
print("I got the message")
print("...modifying, this might take time")
message = message.decode().upper()
data = ("Server: {} data with {} length".format(message, len(message.split()))).encode(encoding="UTF-8")
time.sleep(1.5)
sockobj.sendto(data,clientaddress)
print("SENT!")
sockobj.close() 我现在已经在我的安卓设备上安装了QPython,并在那里运行服务器文件。设备连接和通信!!
因此,在这一点上,,,我想看看包是如何从我的PC到手机的,从终端运行traceroute是没用的,我的手机的本地IP:192.167.1.4被拒绝连接,所以我想我可以从udp客户端脚本进行系统呼叫,但从那里也没有运气。我猜是包会从我的电脑反弹到路由器到我的手机,但是,这只是一个猜测。那么,如何跟踪这个脚本的数据包呢?
发布于 2018-11-19 05:26:31
或许最好作为一种评论。但鉴于他们在这篇文章上几乎没有任何活动,我想只是把它作为一个答案。
你试过使用:https://github.com/CiscoDevNet/dnac-python-path-trace吗?
就像你看起来想要的那样。您可以查看代码来了解它是如何工作的。
https://stackoverflow.com/questions/49516002
复制相似问题