Commit e36c50dc authored by Paul's avatar Paul
Browse files

Reset burst functionality

parent 55c4b9b4
......@@ -93,12 +93,17 @@ class ActionSender:
print "reset"
print "********** reset **********"
self.count = self.count + 1
if self.count % 10 == 0:
self.restartAdapter()
else:
self.resetAdapter()
#self.resetAdapter()
#if self.count % 100 == 100:
#self.restartAdapter()
#else:
self.resetAdapter()
self.listenForServerPort()
self.sender.setServerPort(self.serverPort)
def sendResetBurst(self, seqNums):
if self.sender is not None:
self.sender.sendResetBurst(seqNums)
def resetAdapter(self):
self.cmdSocket.send("reset\n")
......@@ -108,7 +113,7 @@ class ActionSender:
line = self.sockFile.readline()
if line != "ok\n":
raise Exception("expected 'ok' upon reset, received '" + line + "'")
time.sleep(0.4)
time.sleep(0.2)
self.setUpSocket()
def captureResponse(self):
......
......@@ -135,6 +135,7 @@ class Adapter:
print "received input " + input1
seqNr = 0
ackNr = 0
input1 = input1.strip()
#count = (count + 1) % 1000
#if count == 999:
# sleep(5)
......@@ -142,6 +143,15 @@ class Adapter:
if input1 == "reset":
print "Received reset signal."
self.sender.sendReset()
elif input1 == "resetBurst":
seqNums = set()
seqNums.add(0)
seqNum = self.receiveNumber()
while seqNum != 0:
seqNums.add(seqNum)
seqNum = self.receiveNumber()
self.sender.sendResetBurst(list(seqNums))
self.sendOutput("ok")
elif input1 == "exit":
msg = "Received exit signal " + "(continuous" + "=" + str(self.continuous) + ") :"
if self.continuous == False:
......@@ -176,7 +186,7 @@ class Adapter:
response = sender.captureResponse()
else:
self.fault("invalid input " + input1)
if response is not None:
print 'received ' + response.__str__() + "\n"
self.sendOutput(response.__str__())
......
......@@ -124,6 +124,14 @@ class Sender:
p = pIP / pTCP / Raw(load=payload)
return p
# sends a burst of reset packets
def sendResetBurst(self, seqNums = [], ackNum = 0):
rstPackets = []
for seqNum in seqNums:
rstPackets.append(self.createPacket("R", seqNum, 0, ''))
send(rstPackets, iface=self.networkInterface, verbose=self.isVerbose)
# sends packets and ensures both reception tools are used so as to retrieve the response when such response is given
# use packet = None for sniffing without sending a packet
def sendPacketAndRetrieveResponse(self, packet, waitTime = None):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment