-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-read-noack.py
70 lines (50 loc) · 1.14 KB
/
test-read-noack.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import io
import os
import select
import socket
import time
import utils
utils.new_ns()
port = 1
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
s.bind(('127.0.0.1', port))
s.listen(16)
tcpdump = utils.tcpdump_start(port)
c = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
c.connect(('127.0.0.1', port))
x, _ = s.accept()
c.setsockopt(socket.IPPROTO_TCP, socket.TCP_USER_TIMEOUT, 41*1000)
# c.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
time.sleep(0.2)
t0 = time.time()
c.send(b"h"*200)
time.sleep(0.2)
utils.ss(port)
buf = x.recv(1000)
print("[x] %s" %(buf,))
utils.drop_start(sport=port)
utils.ss(port)
c.send(b"h"*10)
c.send(b"h"*10)
c.send(b"h"*10)
utils.ss(port)
time.sleep(0.05)
c.send(b"h"*10)
utils.ss(port)
time.sleep(0.4)
c.send(b"h"*10)
utils.ss(port)
time.sleep(1)
c.send(b"h"*10)
utils.ss(port)
utils.check_buffer(c)
buf = x.recv(1000)
print("[x] len=%d data=%s" %(len(buf),buf))
poll = select.poll()
poll.register(c, select.POLLIN)
poll.poll()
utils.ss(port)
e = c.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
print("[ ] SO_ERROR = %s" % (e,))
t1 = time.time()
print("[ ] took: %f seconds" % (t1-t0,))