Example #1
0
    def __init__(self, timeout):
        self._lossy_layer = LossyLayer(self, CLIENT_IP, CLIENT_PORT, SERVER_IP,
                                       SERVER_PORT)

        self._timeout = timeout / 100000  # The timeout for one segment in seconds.
        self._timer = None  # The timer used to detect a timeout.
        self._seq_num = None  # The initial sequence number, initialized during establishment.

        # Variables for sending data over to the server.
        self._send_flag = None  # A flag to signify when to stop all the threads.
        self._seg_tries = None  # The amount of tries every segment gets.

        self._segments = None  # All segments which are to be send plus the amount of tries left for every segment.
        self._status = None  # The status for every segment: 0 not send, 1 send not ACKed, 2 timeout, 3 ACKed.
        self._pending = None  # The time at which certain segments are send, contains (seq_num, time send).
        self._acks = None  # All of the acknowledgements which need to be processed.

        self._send_base = None  # The index for self._segments up to which all segments are ACKed.
        self._window_size = None  # The window size of the server, initialized during establishment.

        self._status_lock = None  # Ensure that changing the status list is done thread safe.
        self._pending_lock = None  # Ensure that changing the pending list is done thread safe.
        self._send_base_lock = None  # Ensure that changing the send base is done thread safe.

        # Variables for the connection establishment phase.
        self._syn_tries = None  # The number of tries to establish a connection.
        self._connected = None  # A boolean to signify if the connection was successful, returned by connect().
        self._connected_flag = None  # An event to signify when the connection is established.

        # Variables for the connection termination phase.
        self._fin_tries = None  # The number of tries to terminate a connection.
        self._finished = None  # A boolean to signify if the closing was (ab)normal, returned by disconnect().
        self._finished_flag = None  # An event to signify when the connection is terminated.
Example #2
0
 def __init__(self, window, timeout):
     super().__init__(window, timeout)
     self.window = window
     self.timeout = timeout
     self.thread_executor = ThreadPoolExecutor(max_workers=window)
     self._lossy_layer = LossyLayer(self, SERVER_IP, SERVER_PORT, CLIENT_IP,
                                    CLIENT_PORT)
     self.state = State.CLOSED
Example #3
0
 def __init__(self, window, timeout):
     self._btcpsocket = BTCPSocket
     super().__init__(window, timeout)
     self._lossy_layer = LossyLayer(self, SERVER_IP, SERVER_PORT, CLIENT_IP,
                                    CLIENT_PORT)
     self._HandshakeSuccessful = False
     self._Disconnected = False
     self._PacketList = []
     self._OutputList = []
     self._PacketCounter = 0
     self._AckNumber = 0
Example #4
0
 def __init__(self, window, timeout):
     super().__init__(window, timeout)
     self._lossy_layer = LossyLayer(self, CLIENT_IP, CLIENT_PORT, SERVER_IP,
                                    SERVER_PORT)
     self._btcpsocket = BTCPSocket
     self._HandshakeSuccessful = False
     self._Disconnected = False
     self._timeout = timeout
     self._First_Packet_Sequence_Number = 0
     self._PacketList = []
     self._AckPacket = None
     self._SequenceNumberList = []
     self._Packetloss = 0
     self._packets1 = []
     self._retryCounter = 10
    def __init__(self, window, timeout):
        super().__init__(window, timeout)
        self._lossy_layer = LossyLayer(self, CLIENT_IP, CLIENT_PORT, SERVER_IP, SERVER_PORT)

        # Boolean variable that determines whether the server has a connection to the cient
        self._connected_to_server = False

        # Global variables that keep track of the sequence and the acknowledgement number that are send during
        # the three-way handshake
        self._x_value = 0
        self._y_value = 0

        # Variable that keeps track of the window size on the server side
        self._window_size_server = 0

        # Selective repeater
        self._selective_repeater = SelectiveRepeaterSender(self._lossy_layer, self._window, self._timeout)
Example #6
0
 def __init__(self, window, timeout, printSegments, maxRetries):
     super().__init__(window, timeout)
     self._lossy_layer = LossyLayer(self, CLIENT_IP, CLIENT_PORT, SERVER_IP,
                                    SERVER_PORT)
     self._printSegments = printSegments
     self._currentState = "disconnected"
     self._maxRetries = maxRetries
     self._numberOfRetries = 0
     self._nextSeqNum = 0
     self._ackNum = 0
     self._sendBase = 0
     self._initialSequenceNumber = 0
     self._timer = 0
     self._timerLock = threading.Lock()
     self._disconnected = threading.Event()
     self._connected = threading.Event()
     self._entireFileAcknowledged = threading.Event()
    def __init__(self, window, timeout):
        super().__init__(window, timeout)
        self._lossy_layer = LossyLayer(self, SERVER_IP, SERVER_PORT, CLIENT_IP, CLIENT_PORT)

        # Boolean variable that determines whether the server has a connection to the client
        self._connected_to_client = False

        # Boolean variable that is true when the server is listening for the clients initiation of the three-way handshake
        self._listening = False

        # Global variables that keep track of the sequence and the acknowledgement number that are send during
        # the three-way handshake
        self._x_value = 0
        self._y_value = 0

        # Selective repeater
        self._selective_repeater = SelectiveRepeaterReceiver(self._lossy_layer, self._window)
Example #8
0
 def __init__(self, window, timeout):
     super().__init__(window, timeout)
     self._lossy_layer = LossyLayer(self, CLIENT_IP, CLIENT_PORT, SERVER_IP,
                                    SERVER_PORT)
     self.connloop = asyncio.get_event_loop()
     self.tries = 1
Example #9
0
 def __init__(self, window, timeout):
     super().__init__(window, timeout)
     self.timeout = TIMEOUT_TIME
     self._lossy_layer = LossyLayer(self, CLIENT_IP, CLIENT_PORT, SERVER_IP,
                                    SERVER_PORT)
Example #10
0
 def __init__(self, window, timeout):
     super().__init__(window, timeout)
     self.window = window
     self.timeout = timeout
     self._lossy_layer = LossyLayer(self, SERVER_IP, SERVER_PORT, CLIENT_IP,
                                    CLIENT_PORT)
Example #11
0
 def __init__(self, window, timeout):
     super().__init__(window, timeout)
     self._lossy_layer = LossyLayer(self, SERVER_IP, SERVER_PORT, CLIENT_IP,
                                    CLIENT_PORT)
     self._active = True