【问题标题】:What layers/protocols does this use?这使用了哪些层/协议?
【发布时间】:2013-12-05 20:01:07
【问题描述】:

我有以下 python 脚本连接到我的网站并读取文本文件。然后它将从文本文件中读取的值转发到 USB 串行端口。我需要找出它与网络概念的关系以及它可能在后台使用的层和协议。例如,我知道它使用 TCP/IP。还有哪些相关细节?谢谢..

import time
import urllib
import serial

# usb serial connection to arduino
ser = serial.Serial('COM4', 9600)
myUrl = 'http://somewebsite/hitcounter.txt'

last_counter = urllib.urlopen(myUrl).read()
while (True):
    counter = urllib.urlopen(myUrl).read()
    delta = int(counter) - int(last_counter)
    print "counter: %s, delta: %s" % (counter, delta)
    ser.write(chr(ord(chr(delta))))
    last_counter = counter

【问题讨论】:

  • 请修正您的代码缩进!否则很难(如果不是不可能的话)破译脚本。
  • 与osi模型有关?
  • @JoachimPileborg:我刚刚修好了!
  • @ins0:当然!为什么不呢?

标签: python networking network-programming network-protocols


【解决方案1】:

了解您的 PC 和远程网站之间在网络方面发生了什么的最佳方法是下载一个应用程序,例如 Wireshark,并在运行脚本时查看数据包交换。

根据您想要深入的程度,所涉及的关键协议将是作为传输的 TCP 和作为应用层协议的 HTTP。

【讨论】:

  • 注意官网是wireshark.org,而不是本回答中给出的www.wireshark.com。
猜你喜欢
  • 2011-06-21
  • 2017-09-09
  • 1970-01-01
  • 2018-07-07
  • 2014-08-21
  • 1970-01-01
  • 1970-01-01
  • 2015-05-07
  • 1970-01-01
相关资源
最近更新 更多