-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
majorMajor changesMajor changes
Description
Brief description
Latency calculated is 10 times higher than 2.4.0, and sometimes, latency is negative.
Looks like #1791 but with negative values now.
The test is done in TCP.
It does not seem there is a mismatch between receive and sent packets as SEQ/ACK and SPORT/DPORT matches.
Environment
Scapy version: Scapy 2.4.3
Python version: 3.6 & 3.7
Operating System: centos 7.4 & arch linux
Tests are done in a LAN with stable machine, and also in production in datacenters.
How to reproduce
dest = "192.168.0.1"
pkt = []
pkt_rst = []
for i in range(1, 100):
a = IP(dst=dest) / TCP(flags="S", seq=i, sport=65000+i, dport=55556)
b = IP(dst=dest) / TCP(flags="R", seq=i, sport=65000+i, dport=55556)
pkt.append(a)
pkt_rst.append(b)
ans, unans = sr(pkt, filter="host {0}".format(dest), inter=0, timeout=1)
send(pkt_rst, inter=0)
print("scapy version: {}".format(conf.version))
for pkt in ans:
sent = pkt[0]
received = pkt[1]
res = (received.time - sent.sent_time) * 1000
print(res)
if res < 0:
breakpoint()
Actual result
Using 2.4.0:
Begin emission:
.****************************************************Finished sending 99 packets.
***********************************************
Received 100 packets, got 99 answers, remaining 0 packets
...................................................................................................
Sent 99 packets.
scapy version: 2.4.0
0.48351287841796875
0.31113624572753906
0.46896934509277344
....
0.27561187744140625
0.3025531768798828
0.38909912109375
0.3840923309326172
0.3809928894042969
0.2892017364501953
Using 2.4.3:
sudo python ./test.py
Begin emission:
.**************************************************************************************************Finished sending 99 packets.
*
Received 100 packets, got 99 answers, remaining 0 packets
...................................................................................................
Sent 99 packets.
scapy version: 2.4.3
3.6242008209228516
2.803325653076172
3.2286643981933594
7.400989532470703
12.633323669433594
13.63062858581543
15.126228332519531
11.01994514465332
24.735450744628906
24.316787719726562
23.879051208496094
23.487329483032227
22.953510284423828
22.533655166625977
22.108078002929688
40.10128974914551
39.75367546081543
39.3528938293457
38.92111778259277
38.49363327026367
38.06662559509277
37.683963775634766
36.977529525756836
36.301374435424805
34.806013107299805
34.380197525024414
34.37399864196777
34.02996063232422
33.62083435058594
33.17570686340332
32.75179862976074
32.33003616333008
24.41573143005371
23.94843101501465
23.525714874267578
23.09560775756836
22.677898406982422
22.095203399658203
21.67963981628418
21.364927291870117
20.95651626586914
20.496606826782227
20.053863525390625
19.638776779174805
19.222021102905273
18.764257431030273
18.578290939331055
18.302440643310547
19.684314727783203
...
-0.3478527069091797
[0] > /home/kevin/tmp/scapy-test/test.py(18)<module>()
-> for pkt in ans:
(Pdb++) sent
<IP frag=0 proto=tcp dst=192.168.18.71 |<TCP sport=65067 dport=55556 seq=67 flags=S |>>
(Pdb++) received
<IP version=4 ihl=5 tos=0x0 len=40 id=0 flags=DF frag=0 ttl=64 proto=tcp chksum=0x94e4 src=192.168.18.71 dst=192.168.18.84 |<TCP sport=55556 dport=65067 seq=0 ack=68 dataofs=5 reserved=0 flags=RA window=0 chksum=0x3270 urgptr=0 |<Padding load='\x00\x00\x00\x00\x00\x00' |>>>
Metadata
Metadata
Assignees
Labels
majorMajor changesMajor changes