Пример #1
0
    def __init__(self,
                 transport,
                 source_address,
                 source_port,
                 destination_address,
                 destination_port,
                 app=None,
                 window=1000):
        Connection.__init__(self, transport, source_address, source_port,
                            destination_address, destination_port, app)

        ### Sender functionality

        # send window; represents the total number of bytes that may
        # be outstanding at one time
        self.window = window
        # send buffer
        self.send_buffer = SendBuffer()
        # maximum segment size, in bytes
        self.mss = 1000
        # largest sequence number that has been ACKed so far; represents
        # the next sequence number the client expects to receive
        self.sequence = 0
        # retransmission timer
        self.timer = None
        # timeout duration in seconds
        self.timeout = 1

        ### Receiver functionality

        # receive buffer
        self.receive_buffer = ReceiveBuffer()
        # ack number to send; represents the largest in-order sequence
        # number not yet received
        self.ack = 0
Пример #2
0
    def __init__(self,
                 transport,
                 source_address,
                 source_port,
                 destination_address,
                 destination_port,
                 app=None,
                 drop=[],
                 fast_retransmit=False,
                 measure=False):
        Connection.__init__(self, transport, source_address, source_port,
                            destination_address, destination_port, app)

        # -- Sender functionality

        # send buffer
        self.send_buffer = SendBuffer()
        # maximum segment size, in bytes
        self.mss = 1000
        # initial cwnd is equal to 1mss
        self.cwnd = float(self.mss)
        # boolean flag that indicates if in slow start or additive increase
        self.slow_start = True
        # When cwnd >= ss_thresh, slow start ends
        self.ss_thresh = 100000
        if self.node.hostname == 'n1':
            self.trace("Entering Slow Start: SS Thresh = %s" %
                       (self.ss_thresh))
        # Tracks additive increase - determines when to add another MSS to cwnd
        self.cwnd_inc = 0

        # largest sequence number that has been ACKed so far; represents
        # the next sequence number the client expects to receive
        self.sequence = 0
        # plot sequence numbers
        self.plot_sequence_header()
        self.plot_cwnd_header()
        self.plot_cwnd()
        # packets to drop
        self.drop = drop
        self.dropped = []
        # retransmission timer
        self.timer = None
        # timeout duration in seconds
        self.timeout = 1

        # -- Receiver functionality

        # receive buffer
        self.receive_buffer = ReceiveBuffer()
        # ack number to send; represents the largest in-order sequence
        # number not yet received
        self.ack = 0
        self.fast_retransmit = fast_retransmit
        self.last_ack = 0
        self.last_ack_count = 0
Пример #3
0
    def __init__(self,
                 transport,
                 source_address,
                 source_port,
                 destination_address,
                 destination_port,
                 app=None,
                 window=1000,
                 drop=[]):
        Connection.__init__(self, transport, source_address, source_port,
                            destination_address, destination_port, app)

        # -- Sender functionality

        # send window; represents the total number of bytes that may
        # be outstanding at one time
        self.window = window
        # send buffer
        self.send_buffer = SendBuffer()
        # maximum segment size, in bytes
        self.mss = 1000
        # largest sequence number that has been ACKed so far; represents
        # the next sequence number the client expects to receive
        self.sequence = 0
        # plot sequence numbers
        self.plot_sequence_header()
        # packets to drop
        self.drop = drop
        self.dropped = []
        # retransmission timer
        self.timer = None
        # timeout duration in seconds
        self.timeout = 1
        # RTO calculation variables
        self.rto = 1
        self.srtt = 0
        self.rttvar = 0
        # Variables for handling fast retransmit
        self.fast_enable = False
        self.last_ack = 0
        self.same_ack_count = 0
        self.fast_retransmitted = False

        # -- Receiver functionality

        # receive buffer
        self.receive_buffer = ReceiveBuffer()
        # ack number to send; represents the largest in-order sequence
        # number not yet received
        self.ack = 0
Пример #4
0
    def __init__(self,
                 transport,
                 source_address,
                 source_port,
                 destination_address,
                 destination_port,
                 app=None,
                 window=1000):
        Connection.__init__(self, transport, source_address, source_port,
                            destination_address, destination_port, app)

        ### Sender functionality

        # send window; represents the total number of bytes that may
        # be outstanding at one time
        # Step 2
        self.window = window
        # send buffer
        self.send_buffer = SendBuffer()
        # maximum segment size, in bytes
        # self.mss = 1000
        self.mss = min(1000, window)
        # largest sequence number that has been ACKed so far; represents
        # the next sequence number the client expects to receive
        self.sequence = 0
        # retransmission timer
        self.timer = None
        # timeout duration in seconds
        self.timeout = 3.0
        # estimated rtt
        self.est_rtt = None
        # alpha
        self.alpha = 0.125
        # variation rtt
        self.var_rtt = None  ## TODO: revisit this later
        # beta
        self.beta = 0.25
        # timer start
        self.start_time = 0.0
        ### Receiver functionality

        # receive buffer
        self.receive_buffer = ReceiveBuffer()
        # ack number to send; represents the largest in-order sequence
        # number not yet received
        self.ack = 0
Пример #5
0
    def __init__(self,
                 transport,
                 source_address,
                 source_port,
                 destination_address,
                 destination_port,
                 app=None,
                 window=1000,
                 threshold=100000,
                 fast_recovery=False,
                 aiad=False,
                 aimdc=0.5):
        Connection.__init__(self, transport, source_address, source_port,
                            destination_address, destination_port, app)

        ### Sender functionality

        # send window; represents the total number of bytes that may
        # be outstanding at one time (cwnd)
        self.window = window
        # send buffer
        self.send_buffer = SendBuffer()
        # maximum segment size, in bytes
        self.mss = 1000
        # largest sequence number that has been ACKed so far; represents
        # the next sequence number the client expects to receive
        self.sequence = 0
        # retransmission timer
        self.timer = None
        # timeout duration in seconds
        self.timeout = 1
        # Round trip time in seconds
        self.estimated_rtt = None
        # Deviation of sample rtt from estimated rtt
        self.deviation_rtt = None
        # State determines slow start vs. additive increase
        # 0 = slow start
        # 1 = additive increase
        self.state = 0
        # Threshold for slow start
        self.threshold = threshold
        self.trace("Threshold starting at %d" % self.threshold)
        # Same ack count (used for calculating three duplicate acks)
        self.same_ack_count = 0
        # Most recent ack (used for calculating three duplicate acks)
        self.last_ack = None
        # Make sure settings start with slow start
        self.window = self.mss

        # Used when dropping certain packets
        self.dropped_count = 0

        # Fast Recovery (Reno)
        self.fast_recovery = fast_recovery

        # AIAD
        self.aiad = aiad

        # AIMD Constant
        self.aimdc = aimdc

        ### Used to make TCP Sequence Graphs

        self.x = []
        self.y = []
        self.dropX = []
        self.dropY = []
        self.ackX = []
        self.ackY = []

        ### Used to make window size graphs

        self.window_x = []
        self.window_y = []

        ### Receiver functionality

        # receive buffer
        self.receive_buffer = ReceiveBuffer()
        # ack number to send; represents the largest in-order sequence
        # number not yet received
        self.ack = 0
        # a list of all the queuing delays from the sender to receiver
        self.queueing_delay_list = []
        # keep track of when packets were received
        self.packets_received = {}