def send_packet(self,data,sequence): packet = TCPPacket(source_address=self.source_address, source_port=self.source_port, destination_address=self.destination_address, destination_port=self.destination_port, body=data, sequence=sequence,ack_number=self.ack, sent_time=Sim.scheduler.current_time()) # Forced Loss, loss, AIMD dropped packets drop_list = [] #drop_list = [32000] # For a single loss #drop_list = [32000, 33000, 34000] # For burst loss if sequence in drop_list and self.dropped_count < len(drop_list): self.trace("Manually dropping packet %d" % sequence) packet.drop = True if packet.drop: # manually drop packets self.dropped_count += 1 self.recordPacketDropped(Sim.scheduler.current_time(), packet.sequence) else: # send the packet self.trace("%s (%d) sending TCP segment to %d for %d" % (self.node.hostname,self.source_address,self.destination_address,packet.sequence)) self.transport.send_packet(packet) self.recordPacketSent(Sim.scheduler.current_time(), packet.sequence) # set a timer if not self.timer: self.timer = Sim.scheduler.add(delay=self.timeout, event='retransmit', handler=self.retransmit)
def send_packet(self,data,sequence): packet = TCPPacket(source_address=self.source_address, source_port=self.source_port, destination_address=self.destination_address, destination_port=self.destination_port, body=data, sequence=sequence,ack_number=self.ack, time_stamp=Sim.scheduler.current_time()) # send the packet if self.stand_trace: self.trace("%s (%d) sending TCP segment to %d for %d" % (self.node.hostname,self.source_address,self.destination_address,packet.sequence)) if self.seq_plot: self.trace("%d T" % (packet.sequence)) if self.graph4: self.trace(str(self.port) + " " + str(packet.sequence) + " T") self.transport.send_packet(packet) # Step 4 # set a timer if not self.timer: if self.proveTimer: print "Starting timer with timeout of: " + str(self.timeout) self.timer = Sim.scheduler.add(delay=self.timeout, event='retransmit', handler=self.retransmit)
def send_ack(self, packet_sent_time=0, packet_length=0): ''' Send an ack. ''' packet = TCPPacket(source_address=self.source_address, source_port=self.source_port, destination_address=self.destination_address, destination_port=self.destination_port, sequence=self.sequence,ack_number=self.ack, sent_time=packet_sent_time,ack_packet_length=packet_length) # send the packet self.trace("%s (%d) sending TCP ACK to %d for %d" % (self.node.hostname,self.source_address,self.destination_address,packet.ack_number)) self.transport.send_packet(packet)
def send_ack(self, time_stamp): ''' Send an ack. ''' ''' R2 ''' packet = TCPPacket(source_address=self.source_address, source_port=self.source_port, destination_address=self.destination_address, destination_port=self.destination_port, sequence=self.sequence,ack_number=self.ack, time_stamp=time_stamp) # send the packet if self.stand_trace: self.trace("%s (%d) sending TCP ACK to %d for %d" % (self.node.hostname,self.source_address,self.destination_address,packet.ack_number)) self.transport.send_packet(packet)
def add_layer(self,name): ''' Add a new network layer to the dictionary. ''' if "eth" in name: self.data["eth"] = EthPacket() elif "ip" in name: self.data["ip"] = IPPacket() elif "udp" in name: self.data["udp"] = UDPPacket() elif "tcp" in name: self.data["tcp"] = TCPPacket() elif "dns" in name: self.data["dns"] = DNSPacket() elif "icmp" in name: self.data["icmp"] = ICMPPacket()
def send_packet(self, data, sequence): packet = TCPPacket(source_address=self.source_address, source_port=self.source_port, destination_address=self.destination_address, destination_port=self.destination_port, body=data, sequence=sequence, ack_number=self.ack, time_stamp=Sim.scheduler.current_time()) # send the packet if self.stand_trace: self.trace("%s (%d) sending TCP segment to %d for %d" % (self.node.hostname, self.source_address, self.destination_address, packet.sequence)) if self.seq_plot: self.trace("%d T" % (packet.sequence)) # == UNCOMMENT THIS FOR DROPPING 3 PACKETS (as well as the code around line 215) # if not self.drop_next or self.dropped_count >= 3: # print "# " + str(self.window) # self.transport.send_packet(packet) # else: # self.dropped_count += 1 # self.trace("%d X" % (sequence)) # print "# Dropped packet with sequence number: " + str(sequence) # self.drop_next += 1 # == UNCOMMENT THIS FOR DROPPING 1 PACKET # if sequence != 61000 or self.has_dropped: # print "# " + str(self.window) # self.transport.send_packet(packet) # else: # self.trace("%d X" % (sequence)) # print "# Dropped packet with sequence number: " + str(sequence) # self.has_dropped = True # == UNCOMMENT THIS FOR NO DELIBERATE PACKET DROPPING self.transport.send_packet(packet) self.totalPacketsSent += 1 # Step 4 # set a timer if not self.timer: if self.proveTimer: print "Starting timer with timeout of: " + str(self.timeout) self.timer = Sim.scheduler.add(delay=self.timeout, event='retransmit', handler=self.retransmit)
def send_packet(self, data, sequence): packet = TCPPacket(source_address=self.source_address, source_port=self.source_port, destination_address=self.destination_address, destination_port=self.destination_port, body=data, sequence=sequence, ack_number=self.ack, sent_time=Sim.scheduler.current_time()) # send the packet self.trace("%s (%d) sending TCP segment to %d for %d" % (self.node.hostname, self.source_address, self.destination_address, packet.sequence)) self.transport.send_packet(packet) # set a timer if not self.timer: self.timer = Sim.scheduler.add(delay=self.timeout, event='retransmit', handler=self.retransmit)