From d471a9019e131c6f141cced39fdb0f6b2374eba3 Mon Sep 17 00:00:00 2001 From: charlie Date: Tue, 26 Jan 2016 21:16:03 +0100 Subject: [PATCH] last model added --- a4/tcp/adapter/listener.py~ | 125 ++++++++++++++++++ .../learnedModel.full.LStar.wm.2666sec.dot | 36 +++++ .../learnedModel.full.RS.wm.2638sec.dot | 36 +++++ .../learnedModel.partial.TTT.wm.390sec.dot | 22 +++ a4/tcp/run.sh | 61 ++------- 5 files changed, 227 insertions(+), 53 deletions(-) create mode 100644 a4/tcp/adapter/listener.py~ create mode 100644 a4/tcp/results/learnedModel.full.LStar.wm.2666sec.dot create mode 100644 a4/tcp/results/learnedModel.full.RS.wm.2638sec.dot create mode 100644 a4/tcp/results/learnedModel.partial.TTT.wm.390sec.dot diff --git a/a4/tcp/adapter/listener.py~ b/a4/tcp/adapter/listener.py~ new file mode 100644 index 0000000..383bb77 --- /dev/null +++ b/a4/tcp/adapter/listener.py~ @@ -0,0 +1,125 @@ +#!/usr/bin/python +from sender import Sender +import sys +import socket + +PORT = 8888 + +if __name__ == "__main__": + serverPort = 10000 + if len(sys.argv) > 1: + serverPort = int(sys.argv[1]) + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.bind(('', PORT)) + s.listen(1) + print 'Listening on port {}'.format(PORT) + conn, addr = s.accept() + print 'Connected by {}'.format(addr) + print 'Initiating connection to EchoServer at port {}...'.format(serverPort) + sender = Sender(serverIP="127.0.0.1", networkInterface="lo", isLocal=True, serverPort=serverPort, waitTime=1, isVerbose=0) + seqnr = 0 + response = '' + data = '' + has_error=False + did_syn=False + con_closed=False + while True: + print 'waiting for data' + done = False + while not done: + d = conn.recv(1) + if not d: + break + if d != '\n': + data += d + if d == '\n': + done = True + if data == '': + print 'invalid data received!' + break + print 'received: {}'.format(data) + if data == 'RES': + print 'resetting the SUT...' + #sender.sendReset() + sender = Sender(serverIP="127.0.0.1", networkInterface="lo", isLocal=True, serverPort=serverPort, waitTime=1, isVerbose=0) + data = '' + has_error = False + did_syn = False + con_closed = False + continue + elif has_error: + response = 'ERR' + elif con_closed: + response = 'Closed' + elif data == 'SYN' and not did_syn: + seqnr = 100 + print 'S: {}'.format(seqnr) + response = sender.sendInput('S', seqnr, seqnr) + did_syn = True + elif not did_syn: + response = 'ERR' + has_error = True + elif data == 'SYN': + response = 'ERR' + has_error = True + elif data == 'ACK': + response = 'Timeout' + if sender.lastSeqReceived != None: + seqnr += 1 + print 'A: {}'.format(seqnr) + response = sender.sendInput('A', seqnr, sender.lastSeqReceived + 1) + elif data == 'DAT': + response = 'Timeout' + if sender.lastSeqReceived != None: + seqnr += 1 + print 'DAT: {} sending: a'.format(seqnr) + response = sender.sendInput('PA', seqnr, sender.lastSeqReceived + 1, 'a') + elif data == 'RST': + response = 'Timeout' + if sender.lastSeqReceived != None: + seqnr += 1 + print 'RP: {}'.format(seqnr) + response = sender.sendInput("RP", seqnr, 0) + if response[0] == 'T': + response = 'Reset' + elif data == 'FIN': + response = 'Timeout' + if sender.lastSeqReceived != None: + seqnr += 1 + print 'F: {}'.format(seqnr) + response = sender.sendInput("FA", seqnr, sender.lastSeqReceived + 1) + if response[0] == 'A': + con_closed = True + else + response = 'Timeout' + else: + print 'INVALID INPUT!: {}'.format(repr(data)) + break + + if response == 'Timeout': + data = 'ERR' + has_error = True + elif response == 'Reset': + data = 'Reset' + did_syn = False + elif response == 'Closed': + data = 'Closed' + elif response[0] == 'A': + data = 'ACK' + elif response[0] == 'PA': + data = 'DATA' + elif response[0] == 'R': + data = 'RST' + elif response[0] == 'SA': + data = 'SYN-ACK' + else: + data = 'ERR' + has_error = True + + print 'RESPONSE: '+data + conn.send('{}\n'.format(data)) + print 'sent...' + data = '' + print 'closed' + conn.close() + exit() diff --git a/a4/tcp/results/learnedModel.full.LStar.wm.2666sec.dot b/a4/tcp/results/learnedModel.full.LStar.wm.2666sec.dot new file mode 100644 index 0000000..2c5e774 --- /dev/null +++ b/a4/tcp/results/learnedModel.full.LStar.wm.2666sec.dot @@ -0,0 +1,36 @@ +digraph g { +__start0 [label="" shape="none"]; + + s0 [shape="circle" label="0"]; + s1 [shape="circle" label="1"]; + s2 [shape="circle" label="2"]; + s3 [shape="circle" label="3"]; + s4 [shape="circle" label="4"]; + s0 -> s1 [label="SYN / SYN-ACK"]; + s0 -> s2 [label="ACK / ERR"]; + s0 -> s2 [label="DAT / ERR"]; + s0 -> s2 [label="RST / ERR"]; + s0 -> s2 [label="FIN / ERR"]; + s1 -> s2 [label="SYN / ERR"]; + s1 -> s2 [label="ACK / ERR"]; + s1 -> s3 [label="DAT / ACK"]; + s1 -> s0 [label="RST / Reset"]; + s1 -> s4 [label="FIN / ACK"]; + s2 -> s2 [label="SYN / ERR"]; + s2 -> s2 [label="ACK / ERR"]; + s2 -> s2 [label="DAT / ERR"]; + s2 -> s2 [label="RST / ERR"]; + s2 -> s2 [label="FIN / ERR"]; + s3 -> s2 [label="SYN / ERR"]; + s3 -> s2 [label="ACK / ERR"]; + s3 -> s3 [label="DAT / DATA"]; + s3 -> s0 [label="RST / Reset"]; + s3 -> s4 [label="FIN / ACK"]; + s4 -> s4 [label="SYN / Closed"]; + s4 -> s4 [label="ACK / Closed"]; + s4 -> s4 [label="DAT / Closed"]; + s4 -> s4 [label="RST / Closed"]; + s4 -> s4 [label="FIN / Closed"]; + +__start0 -> s0; +} diff --git a/a4/tcp/results/learnedModel.full.RS.wm.2638sec.dot b/a4/tcp/results/learnedModel.full.RS.wm.2638sec.dot new file mode 100644 index 0000000..9193bf1 --- /dev/null +++ b/a4/tcp/results/learnedModel.full.RS.wm.2638sec.dot @@ -0,0 +1,36 @@ +digraph g { +__start0 [label="" shape="none"]; + + s0 [shape="circle" label="0"]; + s1 [shape="circle" label="1"]; + s2 [shape="circle" label="2"]; + s3 [shape="circle" label="3"]; + s4 [shape="circle" label="4"]; + s0 -> s1 [label="SYN / SYN-ACK"]; + s0 -> s3 [label="ACK / ERR"]; + s0 -> s3 [label="DAT / ERR"]; + s0 -> s3 [label="RST / ERR"]; + s0 -> s3 [label="FIN / ERR"]; + s1 -> s3 [label="SYN / ERR"]; + s1 -> s3 [label="ACK / ERR"]; + s1 -> s4 [label="DAT / ACK"]; + s1 -> s0 [label="RST / Reset"]; + s1 -> s2 [label="FIN / ACK"]; + s2 -> s2 [label="SYN / Closed"]; + s2 -> s2 [label="ACK / Closed"]; + s2 -> s2 [label="DAT / Closed"]; + s2 -> s2 [label="RST / Closed"]; + s2 -> s2 [label="FIN / Closed"]; + s3 -> s3 [label="SYN / ERR"]; + s3 -> s3 [label="ACK / ERR"]; + s3 -> s3 [label="DAT / ERR"]; + s3 -> s3 [label="RST / ERR"]; + s3 -> s3 [label="FIN / ERR"]; + s4 -> s3 [label="SYN / ERR"]; + s4 -> s3 [label="ACK / ERR"]; + s4 -> s4 [label="DAT / DATA"]; + s4 -> s0 [label="RST / Reset"]; + s4 -> s2 [label="FIN / ACK"]; + +__start0 -> s0; +} diff --git a/a4/tcp/results/learnedModel.partial.TTT.wm.390sec.dot b/a4/tcp/results/learnedModel.partial.TTT.wm.390sec.dot new file mode 100644 index 0000000..3eab61f --- /dev/null +++ b/a4/tcp/results/learnedModel.partial.TTT.wm.390sec.dot @@ -0,0 +1,22 @@ +digraph g { +__start0 [label="" shape="none"]; + + s0 [shape="circle" label="s0"]; + s1 [shape="circle" label="s1"]; + s2 [shape="circle" label="s2"]; + s3 [shape="circle" label="s3"]; + s0 -> s1 [label="SYN / SYN-ACK"]; + s0 -> s2 [label="ACK / ERR"]; + s0 -> s2 [label="DAT / ERR"]; + s1 -> s2 [label="SYN / ERR"]; + s1 -> s2 [label="ACK / ERR"]; + s1 -> s3 [label="DAT / ACK"]; + s2 -> s2 [label="SYN / ERR"]; + s2 -> s2 [label="ACK / ERR"]; + s2 -> s2 [label="DAT / ERR"]; + s3 -> s2 [label="SYN / ERR"]; + s3 -> s2 [label="ACK / ERR"]; + s3 -> s3 [label="DAT / DATA"]; + +__start0 -> s0; +} diff --git a/a4/tcp/run.sh b/a4/tcp/run.sh index 4cb553c..c1dee61 100644 --- a/a4/tcp/run.sh +++ b/a4/tcp/run.sh @@ -5,59 +5,14 @@ # learningMethod {LStar, TTT, RS, KV} # equaviance orace {rand, wm, wpm} -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main small LStar rand -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main small TTT rand -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main small RS rand -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main small KV rand - -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main small LStar wm -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main small TTT wm -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main small RS wm -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main small KV wm - -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main partial LStar rand -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main partial TTT rand -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main partial RS rand -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main partial KV rand - -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main partial LStar wm -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main partial TTT wm -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main partial RS wm -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main partial KV wm - - -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main full LStar rand -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main full TTT rand -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main full RS rand -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main full KV rand - -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main full LStar wm -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main full TTT wm -./adapter.sh & -java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main full RS wm -./adapter.sh & +#./adapter.sh & +#java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main partial TTT wm + +#./adapter.sh & +#java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main full LStar wm +#./adapter.sh & +#java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main full RS wm +#./adapter.sh & java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main full KV wm cp learned*.{dot,pdf} results/ -- 2.20.1