data = ''
has_error=False
did_syn=False
+ con_closed=False
while True:
print 'waiting for data'
done = False
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.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)
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 = 'SYN-ACK'
else:
data = 'ERR'
+ has_error = True
print 'RESPONSE: '+data
conn.send('{}\n'.format(data))
--- /dev/null
+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"];
+ s4 [shape="circle" label="s4"];
+ 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;
+}
--- /dev/null
+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"];
+ s0 -> s2 [label="RST / ERR"];
+ s1 -> s2 [label="SYN / ERR"];
+ s1 -> s2 [label="ACK / ERR"];
+ s1 -> s3 [label="DAT / ACK"];
+ s1 -> s0 [label="RST / Reset"];
+ s2 -> s2 [label="SYN / ERR"];
+ s2 -> s2 [label="ACK / ERR"];
+ s2 -> s2 [label="DAT / ERR"];
+ s2 -> s2 [label="RST / ERR"];
+ s3 -> s2 [label="SYN / ERR"];
+ s3 -> s2 [label="ACK / ERR"];
+ s3 -> s3 [label="DAT / DATA"];
+ s3 -> s0 [label="RST / Reset"];
+
+__start0 -> s0;
+}
#!/bin/bash -x
+
+# parametrs for learner
+# aphabetSize {small, partial, full} - selects subset input alphabet. this affects model size
+# learningMethod {LStar, TTT, RS, KV}
+# equaviance orace {rand, wm, wpm}
+
#java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main small
-java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main partial TTT wm
+java -cp ":lib/automata-parent.jar:lib/learnlib-parent.jar" learner.Main full TTT wm
private static String stateCountStr;
private static String methodStr;
private static String testStr;
+ private static long startTime;
public static void main(String [] args) throws IOException {
+ startTime = System.currentTimeMillis();
+
if (args.length != 3) {
System.out.println("error: missing commandline arguments!");
return;
* @throws IOException
*/
public static void produceOutput(String fileName, MealyMachine<?,String,?,String> model, Alphabet<String> alphabet, boolean verboseError) throws FileNotFoundException, IOException {
- GraphDOT.write(model, alphabet, new PrintWriter(fileName + "." + stateCountStr + "." + methodStr + "." + testStr + ".dot"));
+ long time = (System.currentTimeMillis()-startTime)/1000L;
+ GraphDOT.write(model, alphabet, new PrintWriter(fileName + "." + stateCountStr + "." + methodStr + "." + testStr + "." + time + "sec" + ".dot"));
try {
- DOT.runDOT(new File(fileName + "." + stateCountStr + "." + methodStr + "." + testStr + ".dot"), "pdf", new File(fileName + "." + stateCountStr + "." + methodStr + "." + testStr + ".pdf"));
+ DOT.runDOT(new File(fileName + "." + stateCountStr + "." + methodStr + "." + testStr + "." + time + "sec" + ".dot"), "pdf", new File(fileName + "." + stateCountStr + "." + methodStr + "." + testStr + "." + time + "sec" + ".pdf"));
} catch (Exception e) {
if (verboseError) {
System.err.println("Warning: Install graphviz to convert dot-files to PDF");