#include <ReceiveWindow.h>
Inheritance diagram for ReceiveWindow::
Public Methods | |
ReceiveWindow (int size, SAR *m_sar) | |
~ReceiveWindow () | |
Destroy the receive window. More... | |
int | receive (u_char *buffer, int bufferLength) |
Receive some data from a remote node. More... | |
bool | addReceive (TpPacket *packet) |
Try to add a packet to the window and ACK it. More... | |
void | close () |
Close the receive window. More... | |
virtual void | toStream (std::ostream &out) |
Print out the state of the sliding window. More... | |
Private Methods | |
void | removePacket (int seqNum) |
Delete the packet from the buffer and free its memory. More... | |
int | addPacket (TpPacket *packet) |
Add a packet to the buffer. More... | |
void | destroy () |
Flush the receive window. More... | |
void | setInitialSequenceNumber (int sequenceNumber) |
Once a connection is established, this function should be called to set up the window position pointers. More... | |
TpPacket * | getNext (bool blocking=true) |
Return the next packet in the receive window. More... | |
bool | canAdd (TpPacket *packet) |
Returns true if another packet can be added to the queue. More... | |
int | calcCredits () |
Calculates the credits. More... | |
WindowPosition | calcMaxAck () |
Calculate the maximum sequence number to ACK. More... | |
int | reassemble (u_char *buffer, int bufferLength) |
Reassemble a message. More... | |
void | sendAck () |
ACKs as many packets as possible. More... | |
void | dumpDebug () |
Dump the table to debug output. More... | |
Private Attributes | |
WindowPosition | m_nextExpected |
next packet sequence number expected to be received. More... | |
WindowPosition | m_lastAccepted |
last possible sequence number we will accept. More... | |
WindowPosition | m_lastRead |
last packet read by application. More... | |
vector< u_char > | m_excessBuffer |
used as a buffer when reassembling a message. More... | |
bool | m_reading |
true while getNext() is executing. More... | |
bool | m_destroy |
used to signal that we want the object to die. More... | |
bool | m_closed |
used to signal that the connection is closed. More... | |
bool | m_firstAck |
true if we havent sent the first ACK yet. More... | |
SAR * | m_sar |
a pointer back to our container. More... | |
Condition | m_dataSignal |
signalled when we receive some data. More... | |
Condition | m_terminate |
used to signal that getNext() is done. More... | |
int | m_size |
the size of the sliding window. More... | |
Mutex | m_slidingWindowLock |
a lock for the window while doing stuff to it. More... | |
vector< TpPacket *> | m_window |
The array that stores all the packets. More... |
Definition at line 9 of file ReceiveWindow.h.
|
Definition at line 16 of file ReceiveWindow.cpp. |
|
Destroy the receive window.
Definition at line 41 of file ReceiveWindow.cpp. |
|
Add a packet to the buffer. This removes any packet that was in the position that the packet wants to go in.
Definition at line 62 of file ReceiveWindow.cpp. Referenced by addReceive().
|
|
Try to add a packet to the window and ACK it. If it cannot be addedto the window, delete the packet.
Definition at line 144 of file ReceiveWindow.cpp. Referenced by SAR::receivePacket().
|
|
Calculates the credits. Credits == number of holes in window from nextExpected to lastAccepted Note: this function does not lock m_slidingWindowLock because it is private. You must make sure that this is locked before calling this function.
Definition at line 319 of file ReceiveWindow.cpp. Referenced by sendAck().
|
|
Calculate the maximum sequence number to ACK. This means there are no holes in the window up to the return value.
Definition at line 347 of file ReceiveWindow.cpp. Referenced by addReceive(), and sendAck().
|
|
Returns true if another packet can be added to the queue. Note: this function does not lock m_slidingWindowLock because it is private. You must make sure that this is locked before calling this function. Definition at line 296 of file ReceiveWindow.cpp. Referenced by addReceive().
|
|
Close the receive window. The window will no longer accept packets, but if there are any left they will be saved in case "receive" is called. Definition at line 552 of file ReceiveWindow.cpp. Referenced by SAR::connectionClosed().
|
|
Flush the receive window. Used to destroy the receive queue. Definition at line 532 of file ReceiveWindow.cpp. Referenced by ~ReceiveWindow().
|
|
Dump the table to debug output.
Definition at line 564 of file ReceiveWindow.cpp. Referenced by addReceive(), and getNext().
|
|
Return the next packet in the receive window.
Definition at line 210 of file ReceiveWindow.cpp. Referenced by reassemble().
|
|
Reassemble a message. This function will put as much data as it can into the buffer provided. This function will block until it receives at least one data packet. If it is unable to fit the data in the provided buffer, it will copy as much as it can into it, and save the rest for later. On the next call to the function it will continue from where it left off.
Definition at line 404 of file ReceiveWindow.cpp. Referenced by receive().
|
|
Receive some data from a remote node.
Definition at line 96 of file ReceiveWindow.cpp. Referenced by SAR::receive().
|
|
Delete the packet from the buffer and free its memory.
Definition at line 77 of file ReceiveWindow.cpp. Referenced by addPacket().
|
|
ACKs as many packets as possible.
Definition at line 117 of file ReceiveWindow.cpp. Referenced by addReceive().
|
|
Once a connection is established, this function should be called to set up the window position pointers.
Definition at line 106 of file ReceiveWindow.cpp. |
|
Print out the state of the sliding window.
Reimplemented from BasicObject. Definition at line 577 of file ReceiveWindow.cpp. |
|
used to signal that the connection is closed.
Definition at line 54 of file ReceiveWindow.h. |
|
signalled when we receive some data.
Definition at line 66 of file ReceiveWindow.h. |
|
used to signal that we want the object to die.
Definition at line 51 of file ReceiveWindow.h. |
|
used as a buffer when reassembling a message.
Definition at line 45 of file ReceiveWindow.h. |
|
true if we havent sent the first ACK yet.
Definition at line 60 of file ReceiveWindow.h. |
|
last possible sequence number we will accept.
Definition at line 38 of file ReceiveWindow.h. |
|
last packet read by application.
Definition at line 41 of file ReceiveWindow.h. |
|
next packet sequence number expected to be received.
Definition at line 35 of file ReceiveWindow.h. |
|
true while getNext() is executing.
Definition at line 48 of file ReceiveWindow.h. |
|
a pointer back to our container.
Definition at line 63 of file ReceiveWindow.h. |
|
the size of the sliding window.
Definition at line 72 of file ReceiveWindow.h. |
|
a lock for the window while doing stuff to it.
Definition at line 75 of file ReceiveWindow.h. |
|
used to signal that getNext() is done.
Definition at line 69 of file ReceiveWindow.h. |
|
The array that stores all the packets.
Definition at line 78 of file ReceiveWindow.h. |