print 'Listening on port {} for Gast'.format(GASTPORT)
conn, addr = s.accept()
print 'Connected by Gast at {}'.format(addr)
- sender = None
+ sender = Sender(serverIP="127.0.0.1", networkInterface="lo", isLocal=True, serverPort=serverPort, waitTime=1, isVerbose=0)
seqnr = None
response = ''
data = ''
data = conn.recv(int(data))
print "INPUT: "+data
+
+ if data == 'SYN':
+ seqnr = 100
+ print 'S: {}'.format(seqnr)
+ response = sender.sendInput('S', seqnr, seqnr)
+ elif data == 'ACK':
+ seqnr += 1
+ print 'A: {}'.format(seqnr)
+ response = sender.sendInput('A', seqnr, sender.lastSeqReceived + 1)
+ elif data == 'RST':
+ seqnr += 1
+ print 'RP: {}'.format(seqnr)
+ response = sender.sendInput("RP", seqnr, 0)
+ sender.sendReset()
+ elif data == 'FIN':
+ seqnr += 1
+ print 'F: {}'.format(seqnr)
+ response = sender.sendInput("FA", seqnr, sender.lastSeqReceived + 1)
+ else:
+ print 'INVALID INPUT!'
+ break
+
+ if response == 'Timeout':
+ data = 'TO'
+ elif response[0] == 'A':
+ data = 'ACK'
+ elif response[0] == 'R':
+ data = 'RST'
+ elif response[0] == 'SA':
+ data = 'SYN-ACK'
+ else:
+ data = 'ERR'
+
+ print 'RESPONSE: '+data
+ conn.send('{} {}'.format(len(data), data));
data = ''
continue