[包编辑]-延迟指定序号包及之后的其他包的arrive time
- 延迟指定序号包之后的其他包的时间
./updat_packet_timestamp.py -i input.pcap -o output.pcap -d 0.01 -n 2
#!/usr/bin/python3
import argparse
from scapy.all import *
def parse_args():
parse = argparse.ArgumentParser(description="postpone the packet timestamp after specified number of packet!")
parse.add_argument("-i", help='the input packet', dest='input', required=True)
parse.add_argument("-o", help='the output packet', dest='output', required=True)
parse.add_argument("-d", help='the delay time(s)', dest='delay', required=True)
parse.add_argument("-n", help='the index of packet', dest='index', required=True, default=0)
return parse.parse_args()
def postpone_packet():
pcap_file = rdpcap(args.input)
tc_packet = []
for number in range(len(pcap_file)):
pkg = pcap_file[number]
if number < args.index:
tc_packet.append(pkg)
else:
pkg.time = pkg.time + args.delay
tc_packet.append(pkg)
wrpcap(args.output, tc_packet)
if __name__ == "__main__":
args = parse_args()
postpone_packet()