forked from nsg-ethz/p4-learning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
send.py
31 lines (23 loc) · 688 Bytes
/
send.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
#!/usr/bin/env python
import sys
import time
from p4utils.utils.tcp_utils import *
def main(ip, port, num_packets):
sender = Sender()
sender.connect(ip, port)
try:
while num_packets > 0:
sender.send(" ")
#needed so tcp does not aggregate messages
time.sleep(0.005)
num_packets -=1
sender.close()
except KeyboardInterrupt:
sender.close()
if __name__ == '__main__':
if len(sys.argv) != 4:
print "Invalid number of arguments. Run as receive.py <dst_ip> <port> <packets>"
ip = sys.argv[1]
port = int(sys.argv[2])
n_packets = int(sys.argv[3])
main(ip, port, n_packets)