diff --git a/Python/filegenerator.py b/Python/filegenerator.py index 7a6a393..3c55602 100644 --- a/Python/filegenerator.py +++ b/Python/filegenerator.py @@ -288,7 +288,7 @@ def initializeSummary(self): # initializer for the summary file def initializeAnimationInstructions(self): # self.currentAnimations = "" #used to hold the instructions for the current line of the animation instructions - self.prefix_map = {'C': 'client', 'A': 'attacker', 'R': 'router', 'M': 'mserver', 'N': 'nserver'} + self.prefix_map = {'C': 'client', 'A': 'attacker', 'R': 'router', 'M': 'mserver', 'N': 'nserver', 'T': 'nat'} self.instructions = [] self.tempInstructions = [] @@ -321,7 +321,7 @@ def animateDrop(self, source, packet_type, def animateData(self, clientData, MServerData, NServerData, routerData, - attackerData): # function for generating data instructions. + attackerData, natData): # function for generating data instructions. if (self.makeAnimation): for entity in [clientData, MServerData, NServerData, routerData, attackerData]: instruction = ['data', entity] diff --git a/Python/main.py b/Python/main.py index cef63ca..39f8f02 100644 --- a/Python/main.py +++ b/Python/main.py @@ -211,11 +211,13 @@ def runSimulation(dddState, skipsim, sumOut, animationDataNServer = ['0'] * 7 animationDataRouter = ['0'] * 7 animationDataAttacker = ['0'] * 7 + animationDataNat = ['0'] * 7 # Index 0 is the number of enqueued packets animationDataClient[0] = str(len(simClient.queue)) animationDataMServer[0] = str(len(simMServer.queue)) animationDataNServer[0] = str(len(simNServer.queue)) animationDataRouter[0] = str(len(simRouter.queueClient) + len(simRouter.queueNServer) + len(simRouter.queueMServer)) + animationDataNat[0] = str(simNat.currentQueueLoadClient + simNat.currentQueueLoadRouter) # animationDataAttacker[0] = The attacker never receives packets, so it's value is unchanged # Index 1 is the number of packets the device has received animationDataClient[1] = str(simClient.packetsReceived) @@ -223,39 +225,44 @@ def runSimulation(dddState, skipsim, sumOut, animationDataNServer[1] = str(simNServer.packetsReceived) animationDataRouter[1] = str(simRouter.packetsReceived) animationDataAttacker[1] = str(simAttacker.packetsReceived) + animationDataNat[1] = str(simNat.packetsReceived) # Index 2 is the number of packets the device has dropped animationDataClient[2] = str(simClient.packetsDropped) animationDataMServer[2] = str(simMServer.packetsDropped) animationDataNServer[2] = str(simNServer.packetsDropped) animationDataRouter[2] = str(simRouter.packetsDropped) animationDataAttacker[2] = str(simAttacker.packetsDropped) + animationDataNat[2] = str(simNat.packetsDropped) # Index 3 is the number of packets the device has generated animationDataClient[3] = str(simClient.packetsGenerated) animationDataMServer[3] = str(simMServer.packetsGenerated) animationDataNServer[3] = str(simNServer.packetsGenerated) animationDataRouter[3] = str(simRouter.packetsGenerated) animationDataAttacker[3] = str(simAttacker.packetsGenerated) + # animationDataNat[3] Nothing to be done here, the NAT does not independently generate packets # Index 4 is the number of packets the device has sent animationDataClient[4] = str(simClient.packetsSent) animationDataMServer[4] = str(simMServer.packetsSent) animationDataNServer[4] = str(simNServer.packetsSent) animationDataRouter[4] = str(simRouter.packetsSent) animationDataAttacker[4] = str(simAttacker.packetsSent) + animationDataNat[4] = str(simNat.packetsSent) # Index 5 is the string of the device animationDataClient[5] = 'client' animationDataMServer[5] = 'mserver' animationDataNServer[5] = 'nserver' animationDataRouter[5] = 'router' animationDataAttacker[5] = 'attacker' + animationDataNat[5] = 'nat' # Index 6 is the number of outbound packets that get dropped due to the bandwidth animationDataClient[6] = str(simClient.packetsDroppedOnConnection) animationDataMServer[6] = str(simMServer.packetsDroppedOnConnection) animationDataNServer[6] = str(simNServer.packetsDroppedOnConnection) animationDataRouter[6] = str(simRouter.packetsDroppedOnConnection) animationDataAttacker[6] = str(simAttacker.packetsDroppedOnConnection) - #fileGen.animateData(animationDataClient, animationDataMServer, - # animationDataNServer, animationDataRouter, - # animationDataAttacker) + fileGen.animateData(animationDataClient, animationDataMServer, + animationDataNServer, animationDataRouter, + animationDataAttacker, animationDataNat) fileGen.updateTime() fileGen.updateSummary(simClient, simAttacker, simMServer, simNServer, simRouter, simNat, diff --git a/Python/nat.py b/Python/nat.py index 8b1e2e9..68d5640 100644 --- a/Python/nat.py +++ b/Python/nat.py @@ -45,12 +45,12 @@ def receivePacket(self, packet): packet.sequenceNumber, packet.ackNumber, packet.packetType, self.curTime) else: - # print("Packet is getting Dropped") - # self.fileGen.animateDrop(self.packetIDPrefix[0], - # curPacket.packetType, - # curPacket.sequenceNumber, - # curPacket.ackNumber, - # curPacket.dstPortNumber) + print("Packet is getting Dropped") + self.fileGen.animateDrop(curPacket.packetID[0], + curPacket.packetType, + curPacket.sequenceNumber, + curPacket.ackNumber, + curPacket.dstPortNumber) self.packetsDropped += 1 self.fileGen.addToLog(packet.packetID, "Dropped at Router: No space in receiveBuffer", @@ -74,6 +74,9 @@ def addtoQueues(self): else: self.currentQueueLoadRouter -= i.packetSize # Drop Packet + self.fileGen.animateDrop(i.packetID[0], i.packetType, + i.sequenceNumber, i.ackNumber, + i.dstPortNumber) self.receiveBuffer.remove(i) def mapPacket(self, packet, dst): @@ -90,6 +93,9 @@ def mapPacket(self, packet, dst): else: # Drop Packet print("Mapping not found") + self.fileGen.animateDrop(packet.packetID[0], packet.packetType, + packet.sequenceNumber, packet.ackNumber, + packet.dstPortNumber) return False else: print("Router packet getting mapped")