summaryrefslogtreecommitdiffstats
path: root/src/scripts
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2017-03-01 08:17:34 -0800
committerDave Barach <openvpp@barachs.net>2017-03-04 01:22:36 +0000
commite04c29942af6a130591059679531c9ffa3d7237a (patch)
tree3dd68c33cb346820d098390a088d733e02e779e4 /src/scripts
parentfb38095d1c9d1b84850f345f0344f82b9ae2c375 (diff)
Cleanup URI code and TCP bugfixing
- Add CLI/API to enable session layer, by default it's disabled - Improve rcv wnd computation - Improvements to tx path - URI code cleanup - Builtin test tcp server - Improve src port allocation Change-Id: I2ace498e76a0771d4c31a8075cc14fe33d7dfa38 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/scripts')
-rw-r--r--src/scripts/vnet/uri/dummy_app.py65
-rw-r--r--src/scripts/vnet/uri/tcp_server1
2 files changed, 66 insertions, 0 deletions
diff --git a/src/scripts/vnet/uri/dummy_app.py b/src/scripts/vnet/uri/dummy_app.py
new file mode 100644
index 00000000000..b80fbb28163
--- /dev/null
+++ b/src/scripts/vnet/uri/dummy_app.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+
+import socket
+import sys
+import bitstring
+
+# action can be reflect or drop
+action = "drop"
+
+def handle_connection (connection, client_address):
+ print("Received connection from {}".format(repr(client_address)))
+ try:
+ while True:
+ data = connection.recv(4096)
+ if not data:
+ break;
+ if (action != "drop"):
+ connection.sendall(data)
+ finally:
+ connection.close()
+
+def run_server(ip, port):
+ print("Starting server {}:{}".format(repr(ip), repr(port)))
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ server_address = (ip, int(port))
+ sock.bind(server_address)
+ sock.listen(1)
+
+ while True:
+ connection, client_address = sock.accept()
+ handle_connection (connection, client_address)
+
+def prepare_data():
+ buf = []
+ for i in range (0, pow(2, 16)):
+ buf.append(i & 0xff)
+ return bytearray(buf)
+
+def run_client(ip, port):
+ print("Starting client {}:{}".format(repr(ip), repr(port)))
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ server_address = ("6.0.1.1", 1234)
+ sock.connect(server_address)
+
+ data = prepare_data()
+ try:
+ sock.sendall(data)
+ finally:
+ sock.close()
+
+def run(mode, ip, port):
+ if (mode == "server"):
+ run_server (ip, port)
+ elif (mode == "client"):
+ run_client (ip, port)
+ else:
+ raise Exception("Unknown mode. Only client and server supported")
+
+if __name__ == "__main__":
+ if (len(sys.argv)) < 4:
+ raise Exception("Usage: ./dummy_app <mode> <ip> <port> [<action>]")
+ if (len(sys.argv) == 5):
+ action = sys.argv[4]
+
+ run (sys.argv[1], sys.argv[2], sys.argv[3])
diff --git a/src/scripts/vnet/uri/tcp_server b/src/scripts/vnet/uri/tcp_server
index 7f5a86defad..c29afc6f5a1 100644
--- a/src/scripts/vnet/uri/tcp_server
+++ b/src/scripts/vnet/uri/tcp_server
@@ -2,3 +2,4 @@ create host-interface name vpp1
set int state host-vpp1 up
set int ip address host-vpp1 6.0.1.1/24
trace add af-packet-input 10
+session enable