我需要監視某個網站在尋址時需要多長時間才能響應。我想嗅探端口80上的流量,但只有在與目標站點交換流量時。我已經搜索過,似乎pcapy或scapy是工作的正確工具,但它們似乎比我需要的更深。我已經研究了下面的腳本:使用pcapy或scapy監視自生(HTTP)網絡流量
Network traffic monitor with pcapy in python
,我想我需要改變目的地爲目標站點的
def __handle_packet(self, header, data):
# method is called for each packet by dispatch call (pcapy)
self._dispatch_bytes_sum += header.getlen() #header.getlen() #len(data)
logger.debug("header: (len:{0}, caplen:{1}, ts:{2}), d:{3}".format(header.getlen(), header.getcaplen(), header.getts(), len(data)))
#self.dumper.dump(header, data)
以某種方式只能解包/手柄包。請注意,這適用於LAN上的Windows XP計算機,瀏覽器啓動流量至關重要。
任何指針讚賞?
[Bro](http://stackoverflow.com/a/11081321/1170277)將是適用於此方案的適當工具。但是,它不適用於Windows。 – mavam 2012-08-17 21:39:23
回答我自己的問題,答案在這裏:http://pypi.python.org/packages/source/N/NetCube/NetCube-0.3.0.zip。你必須查看network.py文件。 – reckoner 2012-09-05 13:15:57