1

Scapy 能够每个数据包的基础上修改时间戳,因此我想知道为什么通过指定起始值来修改 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>
4

1 回答 1

1

这似乎有效:

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,并增加微秒值。如果有更优雅的方法,请告诉我。

于 2013-03-02T18:52:54.963 回答