aboutsummaryrefslogtreecommitdiffstats
path: root/src/scripts/vnet/uri/dummy_app.py
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2017-05-07 19:12:02 -0700
committerDamjan Marion <dmarion.lists@gmail.com>2017-05-09 14:38:56 +0000
commitf6d68ed2db2bcd41c9b7ddde5e411073c1566c29 (patch)
tree7477fb7b0187d36429e9e2d1a348be14157ebb09 /src/scripts/vnet/uri/dummy_app.py
parent1ea82dfe5dabb0f9bbfa5ba953ef31328c987b89 (diff)
Add support for tcp/session buffer chains
Change-Id: I01c6e3dc3a1b2785df37bb66b19c4b5cbb8f3211 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/scripts/vnet/uri/dummy_app.py')
-rw-r--r--src/scripts/vnet/uri/dummy_app.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/scripts/vnet/uri/dummy_app.py b/src/scripts/vnet/uri/dummy_app.py
index 50333923d6e..ff00f2fc8c6 100644
--- a/src/scripts/vnet/uri/dummy_app.py
+++ b/src/scripts/vnet/uri/dummy_app.py
@@ -6,14 +6,28 @@ import time
# action can be reflect or drop
action = "drop"
+test = 0
+
+def test_data (data, n_rcvd):
+ n_read = len (data);
+ for i in range(n_read):
+ expected = (n_rcvd + i) & 0xff
+ byte_got = ord (data[i])
+ if (byte_got != expected):
+ print("Difference at byte {}. Expected {} got {}"
+ .format(n_rcvd + i, expected, byte_got))
+ return n_read
def handle_connection (connection, client_address):
print("Received connection from {}".format(repr(client_address)))
+ n_rcvd = 0
try:
while True:
data = connection.recv(4096)
if not data:
break;
+ if (test == 1):
+ n_rcvd += test_data (data, n_rcvd)
if (action != "drop"):
connection.sendall(data)
finally:
@@ -78,8 +92,9 @@ def run(mode, ip, port):
if __name__ == "__main__":
if (len(sys.argv)) < 4:
- raise Exception("Usage: ./dummy_app <mode> <ip> <port> [<action>]")
- if (len(sys.argv) == 5):
+ raise Exception("Usage: ./dummy_app <mode> <ip> <port> [<action> <test>]")
+ if (len(sys.argv) == 6):
action = sys.argv[4]
+ test = int(sys.argv[5])
run (sys.argv[1], sys.argv[2], int(sys.argv[3]))