Beispiel #1
0
    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)
Beispiel #2
0
 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)
Beispiel #3
0
    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)

        if sequence in self.drop and not sequence in self.dropped:
            self.dropped.append(sequence)
            self.plot_sequence(sequence, 'drop')
            self.trace("%s (%d) dropping TCP segment to %d for %d" %
                       (self.node.hostname, self.source_address,
                        self.destination_address, packet.sequence))
            self.trace("PACKET DROPPED CWND IS %s\n" % (self.cwnd))
            return

        # send the packet
        self.plot_sequence(sequence, 'send')
        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.start_retransmit_timer(self.timeout)
    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)

        if sequence in self.drop and not sequence in self.dropped:
            self.dropped.append(sequence)
            self.plot_sequence(sequence, 'drop')
            self.trace("%s (%d) dropping TCP segment to %d for %d" %
                       (self.node.hostname, self.source_address,
                        self.destination_address, packet.sequence))
            return

        # send the packet
        self.plot_sequence(sequence, 'send')
        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 self.timer is None:
            self.timer = Sim.scheduler.add(delay=self.timeout,
                                           event='retransmit',
                                           handler=self.retransmit)
Beispiel #5
0
 def send_ack(self):
     ''' 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)
     # 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)
Beispiel #6
0
    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)

        # 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)
Beispiel #7
0
    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)

        # 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)