-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreliability_test.py
More file actions
47 lines (34 loc) · 846 Bytes
/
reliability_test.py
File metadata and controls
47 lines (34 loc) · 846 Bytes
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
import time
from fssp_protocol import FSSP
def sender():
conn = FSSP('localhost', 2000)
conn.connect('localhost', 3000)
conn.listen()
time.sleep(5)
counter = 1
while True:
if (counter > 100):
break
conn.send(counter)
print("sent: ", counter)
counter += 1
time.sleep(0.1)
def receiver():
conn = FSSP('localhost', 3000)
conn.connect('localhost', 2000)
conn.listen()
test_val = 1
while True:
data = conn.recv()
if (data == test_val):
test_val += 1
print("received: ", data)
if (data == 100):
if (test_val == 101):
print("reliability test passed.")
break
mode = input("mode (1 - sender, 2 - receiver): ")
if (mode == '1'):
sender()
else:
receiver()