-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-rst2.py
59 lines (47 loc) · 1.08 KB
/
test-rst2.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
import io
import os
import select
import socket
import time
import utils
# 以下はnetwork namespaceを新たに作成するためか、tcp_fin_timeoutの変更等が継承されないためコメントアウト
# 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)
time.sleep(1)
utils.ss(port)
c.connect(('127.0.0.1', port))
time.sleep(1)
print("[c] client connect")
utils.ss(port)
x, _ = s.accept()
time.sleep(1)
print("[x] server accept")
utils.ss(port)
for num in range(3):
print("[x] send")
c.send(b"hello world")
x.shutdown(socket.SHUT_WR)
time.sleep(1)
print("[x] server shutdown(SHUT_WR)")
utils.ss(port)
x.close()
time.sleep(1)
print("[x] server close socket")
utils.ss(port)
for num in range(3):
print("[x] send")
c.send(b"hello world")
time.sleep(1)
utils.ss(port)
print("#####just ss outputs from now#####")
time.sleep(1)
utils.ss(port)
time.sleep(1)
utils.ss(port)
time.sleep(1)
utils.ss(port)