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, ) packet.created = Sim.scheduler.current_time() # Store data for plotting if self.sequence_plot: self.app.add_plot_data(Sim.scheduler.current_time(), sequence, "Transmitted") # 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.rto, event="retransmit", handler=self.retransmit)
def send_ack(self, created): ''' 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) packet.created = created # 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)