Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

SendWindow Class Reference

Handles the reliable sending of packets to their destination. More...

#include <SendWindow.h>

Inheritance diagram for SendWindow::

BasicObject List of all members.

Public Methods

 SendWindow (int size, SAR *sar)
 ~SendWindow ()
 Destroy the SendWindow. More...

TimeValue getRtt ()
 Get the average round trip time for the send window. More...

int reliableSend (u_char *data, int dataLength)
 Send a queue of packets. More...

void onAckRecvd (int numAcked, int credits, bool retrans)
 This function is called by the SAR when an ACK packet is received. More...

void end ()
 Used to clear the send 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...

ThreadMessageQueue< Packet > * initialSegmentation ()
 Segment up to a WINDOW_SIZE full of packets. More...

TpPacketsegment ()
 Segment one packet size of data. More...

void sendEmptyPacket ()
 This is used when the receive window credits go to zero. More...

bool windowFull ()
 Returns true if a packet can be added to the send window. More...

void sentPacketTimeoutImpl (WindowPosition)
 A callback that gets executed if we havent yet received an ACK for a packet within the required timeout. More...

void computeEffectiveWindow ()
 This needs to be called every time m_credits, m_lastPacketSent, or m_lastAckRecv changes. More...

void dumpDebug ()
 Dump the table to debug output. More...


Static Private Methods

void * sentPacketTimeout (void *arg)
 A wrapper around sentPacketTimeoutImpl. More...


Private Attributes

u_char * m_data
 a pointer to the data we are sending. More...

int m_dataLength
 the amount of data we are sending. More...

int m_currentPosition
 how much data we have sent already. More...

CallbackTimer m_packetTimeoutCallbackTimer
 A callback timer to timeout sent packets that havent been acked. More...

vector< bool *> m_needSend
 whether the packet in the corresponding position in the window needs to be sent. More...

vector< TimeValuem_timeStamp
 when the packet in the corresponding position in the window was sent. More...

vector< int > m_retries
 indicates how many retries this packet has had. More...

SARm_sar
 a pointer back to our container. More...

WindowPosition m_lastAckRecv
 location in the send window where the last ACK was received. More...

WindowPosition m_lastPacketSent
 location in the send window where the last packet was sent. More...

WindowPosition m_firstPacketSent
 remember the sequence number of the first packet that was sent. More...

Counter m_packetSequenceNum
 A counter for the packet sequence number. More...

int m_effectiveWindow
 How many packets we are allowed to send right now. More...

bool m_sending
 true while executing the "addSend" function. More...

bool m_end
 marked true when the "end" function is called, signifies that the object is being destroyed. More...

int m_credits
 The last reported credits from the other side of the end-to-end connection. More...

TimeValue m_rtt
 average round trip time for all packets in send window. More...

Condition m_terminate
 used to signal to the destructor that other parts of the object have been destroyed. More...

Condition m_ackSignal
 Signal when an ACK is received. More...

int m_size
 the size of the sliding window. More...

Mutex m_sendWindowLock
 a lock for the window while doing stuff to it. More...

vector< TpPacket *> m_window
 The array that stores all the packets. More...


Detailed Description

Handles the reliable sending of packets to their destination.

Definition at line 20 of file SendWindow.h.


Constructor & Destructor Documentation

SendWindow::SendWindow int size,
SAR * sar
 

Parameters:
size   The number of packets the SendWindow can hold.
sar   A pointer back to our SAR container.

Definition at line 19 of file SendWindow.cpp.

SendWindow::~SendWindow
 

Destroy the SendWindow.

Definition at line 50 of file SendWindow.cpp.


Member Function Documentation

int SendWindow::addPacket TpPacket * packet [private]
 

Add a packet to the buffer.

This removes any packet that was in the position that the packet wants to go in.

Returns:
The position which the packet was added to, which is the same as the sequence number.

Definition at line 72 of file SendWindow.cpp.

Referenced by reliableSend().

void SendWindow::computeEffectiveWindow [private]
 

This needs to be called every time m_credits, m_lastPacketSent, or m_lastAckRecv changes.

Definition at line 265 of file SendWindow.cpp.

Referenced by onAckRecvd(), and reliableSend().

void SendWindow::dumpDebug [private]
 

Dump the table to debug output.

Definition at line 502 of file SendWindow.cpp.

Referenced by onAckRecvd(), and reliableSend().

void SendWindow::end
 

Used to clear the send window.

Marks all packets as "not needed to be sent".

Definition at line 287 of file SendWindow.cpp.

Referenced by SAR::connectionClosed(), and ~SendWindow().

TimeValue SendWindow::getRtt
 

Get the average round trip time for the send window.

Definition at line 278 of file SendWindow.cpp.

Referenced by SAR::getAverageRtt().

ThreadMessageQueue< Packet > * SendWindow::initialSegmentation [private]
 

Segment up to a WINDOW_SIZE full of packets.

Creates a queue of segmented packets. The caller of this function has the responsibility of deleting the returned memory.

Definition at line 463 of file SendWindow.cpp.

Referenced by reliableSend().

void SendWindow::onAckRecvd int numAcked,
int credits,
bool retrans
 

This function is called by the SAR when an ACK packet is received.

The positions of the ACKed packet(s) in the buffer are freed up so more data can be added.

Definition at line 375 of file SendWindow.cpp.

Referenced by SAR::receivePacket().

int SendWindow::reliableSend u_char * data,
int dataLength
 

Send a queue of packets.

This function blocks until all the packets have been sent.

Returns:
The number of bytes sent. PB_ERROR on error.

Definition at line 108 of file SendWindow.cpp.

Referenced by SAR::reliableSend().

void SendWindow::removePacket int index [private]
 

Delete the packet from the buffer and free its memory.

Parameters:
seqNum   The sequence number to delete.

Definition at line 87 of file SendWindow.cpp.

Referenced by addPacket(), and onAckRecvd().

TpPacket * SendWindow::segment [private]
 

Segment one packet size of data.

Side-effects: modifies m_currentPosition, m_packetSequenceNum.

Returns:
A new packet.

Definition at line 486 of file SendWindow.cpp.

Referenced by initialSegmentation(), and reliableSend().

void SendWindow::sendEmptyPacket [private]
 

This is used when the receive window credits go to zero.

This will send an empty data packet to the receive window in hopes that it might ACK us with credits that are larger than zero.

Definition at line 248 of file SendWindow.cpp.

Referenced by reliableSend().

void * SendWindow::sentPacketTimeout void * threadArg [static, private]
 

A wrapper around sentPacketTimeoutImpl.

Parameters:
threadArg   A SendWindowThreadArg object.

Definition at line 310 of file SendWindow.cpp.

void SendWindow::sentPacketTimeoutImpl WindowPosition seqNum [private]
 

A callback that gets executed if we havent yet received an ACK for a packet within the required timeout.

It tries to send the packet and waits for the ACK.

Definition at line 325 of file SendWindow.cpp.

Referenced by sentPacketTimeout().

void SendWindow::toStream std::ostream & out [virtual]
 

Print out the state of the sliding window.

Reimplemented from BasicObject.

Definition at line 515 of file SendWindow.cpp.

bool SendWindow::windowFull [private]
 

Returns true if a packet can be added to the send window.

Definition at line 440 of file SendWindow.cpp.

Referenced by reliableSend().


Member Data Documentation

Condition SendWindow::m_ackSignal [private]
 

Signal when an ACK is received.

Definition at line 100 of file SendWindow.h.

int SendWindow::m_credits [private]
 

The last reported credits from the other side of the end-to-end connection.

Definition at line 91 of file SendWindow.h.

int SendWindow::m_currentPosition [private]
 

how much data we have sent already.

Definition at line 52 of file SendWindow.h.

u_char* SendWindow::m_data [private]
 

a pointer to the data we are sending.

Definition at line 46 of file SendWindow.h.

int SendWindow::m_dataLength [private]
 

the amount of data we are sending.

Definition at line 49 of file SendWindow.h.

int SendWindow::m_effectiveWindow [private]
 

How many packets we are allowed to send right now.

Definition at line 82 of file SendWindow.h.

bool SendWindow::m_end [private]
 

marked true when the "end" function is called, signifies that the object is being destroyed.

Definition at line 88 of file SendWindow.h.

WindowPosition SendWindow::m_firstPacketSent [private]
 

remember the sequence number of the first packet that was sent.

Definition at line 76 of file SendWindow.h.

WindowPosition SendWindow::m_lastAckRecv [private]
 

location in the send window where the last ACK was received.

Definition at line 70 of file SendWindow.h.

WindowPosition SendWindow::m_lastPacketSent [private]
 

location in the send window where the last packet was sent.

Definition at line 73 of file SendWindow.h.

vector<bool*> SendWindow::m_needSend [private]
 

whether the packet in the corresponding position in the window needs to be sent.

Definition at line 58 of file SendWindow.h.

Counter SendWindow::m_packetSequenceNum [private]
 

A counter for the packet sequence number.

Definition at line 79 of file SendWindow.h.

CallbackTimer SendWindow::m_packetTimeoutCallbackTimer [private]
 

A callback timer to timeout sent packets that havent been acked.

Definition at line 55 of file SendWindow.h.

vector<int> SendWindow::m_retries [private]
 

indicates how many retries this packet has had.

Definition at line 64 of file SendWindow.h.

TimeValue SendWindow::m_rtt [private]
 

average round trip time for all packets in send window.

Definition at line 94 of file SendWindow.h.

SAR* SendWindow::m_sar [private]
 

a pointer back to our container.

Definition at line 67 of file SendWindow.h.

Mutex SendWindow::m_sendWindowLock [private]
 

a lock for the window while doing stuff to it.

Definition at line 106 of file SendWindow.h.

bool SendWindow::m_sending [private]
 

true while executing the "addSend" function.

Definition at line 85 of file SendWindow.h.

int SendWindow::m_size [private]
 

the size of the sliding window.

Definition at line 103 of file SendWindow.h.

Condition SendWindow::m_terminate [private]
 

used to signal to the destructor that other parts of the object have been destroyed.

Definition at line 97 of file SendWindow.h.

vector<TimeValue> SendWindow::m_timeStamp [private]
 

when the packet in the corresponding position in the window was sent.

Definition at line 61 of file SendWindow.h.

vector<TpPacket*> SendWindow::m_window [private]
 

The array that stores all the packets.

Definition at line 109 of file SendWindow.h.


The documentation for this class was generated from the following files:
Generated at Thu Jul 11 13:31:58 2002 for Peekabooty by doxygen1.2.9 written by Dimitri van Heesch, © 1997-2001