Constructor
new AbstractARQNode(options)
Initializes a new AbstractARQNode. Only subclasses should use this constructor, through super().
Parameters:
Name | Type | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
The options for the constructor. Properties
|
- Source:
Methods
(abstract, protected) _canSend() → {boolean}
An abstract method that should be implemented to decide whether the node can send a packet (true) or not (false) when send() is called, depending on the protocol.
- Source:
(abstract, protected) _checkReceivedPkt(packet) → {boolean}
An abstract method that should return a boolean indicating if the received packet is correct or not.
Parameters:
Name | Type | Description |
---|---|---|
packet |
Packet |
The received packet. |
- Source:
(protected) _nextSequence(seqNum)
Returns the next sequence to seqNum. This depends on the option seqNumLimit given to the constructor. For example, if seqNumLimit was 4, then the available sequences are 0, 1, 2 and 3, so the sequence next to 0 is 1, next to 1 is 2, next to 2 is 3 and next to 3 is 0.
Parameters:
Name | Type | Description |
---|---|---|
seqNum |
number |
The sequence number to get the next of. |
- Source:
(protected) _previousSequence(seqNum)
Returns the previous sequence to seqNum, similarly to _nextSequence().
Parameters:
Name | Type | Description |
---|---|---|
seqNum |
number |
The sequence number to get the previous of. |
- Source:
(abstract, protected) _processExpectedPkt(packet)
An abstract method that should be implemented to process packets that were correctly received.
Parameters:
Name | Type | Description |
---|---|---|
packet |
Packet |
The received packet to process. |
- Source:
(abstract, protected) _processSending()
An abstract method that should implement the logic for sending a packet.
- Source:
(abstract, protected) _processUnexpectedPkt(packet)
An abstract method that should be implemented to process packets that were not correctly received.
Parameters:
Name | Type | Description |
---|---|---|
packet |
Packet |
The received packet to process. |
- Source:
(protected) _sendPkt(packet)
Sends a packet through the channel and calls onSend().
Parameters:
Name | Type | Description |
---|---|---|
packet |
Packet |
The packet to send. |
- Source:
onReceive(packet, isOk)
A callback that is executed each time a packet is received through receive().
Parameters:
Name | Type | Description |
---|---|---|
packet |
Packet |
The received packet. |
isOk |
boolean |
true if the packet was correct according to the class (protocol) of the instance. |
- Source:
onSend(packet)
A callback that is executed every time a packet is sent.
Parameters:
Name | Type | Description |
---|---|---|
packet |
Packet |
The sent packet. |
- Source:
receive(packet)
Receives a packet.
Parameters:
Name | Type | Description |
---|---|---|
packet |
Packet |
The packet to be received. |
- Source:
send() → {boolean}
If the instance can send a packet, sends it and returns true, otherwise it returns false. This depends on the protocol.
- Source: