Scapy具有在每个数据包的基础上修改时间戳的capability,因此我想知道为什么通过指定开始值来修改PCAP中许多数据包的时间戳可能是最好的方法。我能够修改数据包,但尚未成功增加微秒值。
例如,想要修改PCAP中的数据包时间戳,其中包含:
1360806997.231777 IP 192.168.1.100.50496 > 192.168.1.200.http: S 4211078664:4211078664(0) win 14600 <mss 1460,sackOK,timestamp 199086437 0,nop,wscale 3>
1360806997.231808 IP 192.168.1.200.http > 192.168.1.100.50496: S 256066681:256066681(0) ack 4211078665 win 14480 <mss 1460,sackOK,timestamp 199086195 199086437,nop,wscale 3>
1360806997.232034 IP 192.168.1.100.50496 > 192.168.1.200.http: . ack 1 win 1825 <nop,nop,timestamp 199086437 199086195>
1360806997.232043 IP 192.168.1.100.50496 > 192.168.1.200.http: P 1:19(18) ack 1 win 1825 <nop,nop,timestamp 199086437 199086195>
1360806997.232063 IP 192.168.1.200.http > 192.168.1.100.50496: . ack 19 win 1810 <nop,nop,timestamp 199086195 199086437>设置为以下内容:
1234567890.000000 IP 192.168.1.100.50496 > 192.168.1.200.http: S 4211078664:4211078664(0) win 14600 <mss 1460,sackOK,timestamp 199086437 0,nop,wscale 3>
1234567890.000001 IP 192.168.1.200.http > 192.168.1.100.50496: S 256066681:256066681(0) ack 4211078665 win 14480 <mss 1460,sackOK,timestamp 199086195 199086437,nop,wscale 3>
1234567890.000002 IP 192.168.1.100.50496 > 192.168.1.200.http: . ack 1 win 1825 <nop,nop,timestamp 199086437 199086195>
1234567890.000003 IP 192.168.1.100.50496 > 192.168.1.200.http: P 1:19(18) ack 1 win 1825 <nop,nop,timestamp 199086437 199086195>
1234567890.000004 IP 192.168.1.200.http > 192.168.1.100.50496: . ack 19 win 1810 <nop,nop,timestamp 199086195 199086437>发布于 2013-03-03 02:52:55
这似乎起作用了:
def process_packets():
pkts = rdpcap(infile)
cooked=[]
timestamp = 1234567890.000000
for p in pkts:
p.time = timestamp
timestamp += 0.000001
pmod=p
cooked.append(pmod)
wrpcap("dump.pcap", cooked)代码会将每个数据包的新时间值写入具有指定秒数的新PCAP,并递增微秒值。如果有更好的方法,请告诉我。
https://stackoverflow.com/questions/15139939
复制相似问题