pycozmo.window¶
Cozmo protocol sliding window implementation.
Classes
BaseWindow (seq_bits, size, max_seq) |
Base communication window class. |
ReceiveWindow (seq_bits, size, max_seq) |
Receive communication window class. |
SendWindow (seq_bits, size, max_seq) |
Send communication window class. |
-
class
pycozmo.window.
BaseWindow
(seq_bits: int, size: Optional[int] = None, max_seq: Optional[int] = None)¶ Bases:
object
Base communication window class.
-
is_valid_seq
(seq: int) → bool¶ Check whether a sequence number is valid for the window.
-
reset
() → None¶ Reset the window.
-
-
class
pycozmo.window.
ReceiveWindow
(seq_bits: int, size: Optional[int] = None, max_seq: Optional[int] = None)¶ Bases:
pycozmo.window.BaseWindow
Receive communication window class.
When packets are received (in whatever order), they are put in the window using the put() method.
Packets are extracted from the window in the expected order using the get() method.
-
exists
(seq: int) → bool¶ Check whether a sequence number has already been received (assuming it is valid).
-
get
() → Any¶ If data is available, return it and move the window forward. Return None otherwise.
-
is_out_of_order
(seq: int) → bool¶ Check whether a sequence number is outside the current window (assuming it is valid).
-
is_valid_seq
(seq: int) → bool¶ Check whether a sequence number is valid for the window.
-
put
(seq: int, data: Any) → None¶ Add the data, associated with a particular sequence number to the window.
-
reset
() → None¶ Reset the window.
-
-
class
pycozmo.window.
SendWindow
(seq_bits: int, size: Optional[int] = None, max_seq: Optional[int] = None)¶ Bases:
pycozmo.window.BaseWindow
Send communication window class.
When packets are sent, they are put in the window using the put() method which returns a sequence number.
Packets are removed from the window when they are acknowledged with the acknowledge() method.
-
acknowledge
(seq: int) → None¶ Acknowledge a sequence number and remove any associated data from the window.
-
get
() → List[Tuple[int, Any]]¶ Get the contents of the window as a list of tuples (sequence number, data).
-
is_full
() → bool¶ Check whether the window is full.
-
is_out_of_order
(seq: int) → bool¶ Check whether a sequence number is outside the current window (assuming it is valid).
-
is_valid_seq
(seq: int) → bool¶ Check whether a sequence number is valid for the window.
-
put
(data: Any) → int¶ Add data to the window. Raises NoSpace exception if the window is full.
-
reset
()¶ Reset the window.
-