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

TpPacket Class Reference

A TpPacket has the following feilds, in the following order: Sequence Number (8 bits) Ack (8 bits) Credits (5 bits) Ack Bit Retrans Bit End Bit Data (variable length). More...

#include <TpPacket.h>

Inheritance diagram for TpPacket::

Packet BasicObject List of all members.

Public Methods

 TpPacket (unsigned char *message, unsigned int length, bool endBit, unsigned char sequenceNum)
 For data packets. More...

 TpPacket (unsigned short credits, unsigned short ack, bool isRetransmission)
 For creating ACK packets. More...

 TpPacket (unsigned char *tpdata, unsigned int length)
 Decode the header of the TP packet. More...

 TpPacket (const TpPacket &)
 Copy constructor. More...

virtual ~TpPacket ()
 delete the rawData. More...

unsigned char * getTpData ()
 Used right before sending over network. More...

unsigned short getTpLength ()
 Return the length of the data plus the length of the TP header. More...

bool isEnd ()
 Return true if the end bit is set. More...

bool isRetrans ()
 Return true if the retransmission bit is set. More...

void makeRetrans ()
 Set the retransmission bit to true. More...

unsigned char * getData ()
 Return a pointer to the data portion of the packet. More...

unsigned short getDataLength ()
 Return the length of the data in this packet. More...

unsigned short getSeqNum ()
 Return the sequence number of the packet. More...

bool isAck ()
 Return true if the ACK bit is set. More...

unsigned short getAckNum ()
 Return the ACK number. More...

unsigned short getCredits ()
 Return the number of credits. More...

virtual void toStream (std::ostream &out)
void dumpHeader (std::ostream &out)

Private Attributes

unsigned short m_seqNum
unsigned short m_credits
unsigned short m_ack
bool m_ackBit
unsigned int m_length
bool m_endBit
bool m_retransBit
unsigned char * m_data
unsigned char * m_rawData

Detailed Description

A TpPacket has the following feilds, in the following order: Sequence Number (8 bits) Ack (8 bits) Credits (5 bits) Ack Bit Retrans Bit End Bit Data (variable length).

Todo:
Convert this to use vectors instead.

Definition at line 13 of file TpPacket.h.


Constructor & Destructor Documentation

TpPacket::TpPacket unsigned char * message,
unsigned int length,
bool endBit,
unsigned char sequenceNum
 

For data packets.

Definition at line 20 of file TpPacket.cpp.

TpPacket::TpPacket unsigned short credits,
unsigned short ack,
bool isRetransmission
 

For creating ACK packets.

Parameters:
credits   The number of credits the sender has (up to 32 right now (2^5))
ack   The sequence number we are acknowledging.
isRetransmission   ????

Definition at line 45 of file TpPacket.cpp.

TpPacket::TpPacket unsigned char * tpData,
unsigned int length
 

Decode the header of the TP packet.

Parameters:
rawData   Assumed to point to the beginning of the TP header, and the buffer also includes the NP header.
length   The length feild out of the NP header.

Definition at line 67 of file TpPacket.cpp.

TpPacket::TpPacket const TpPacket & copyThis
 

Copy constructor.

Creates a copy of the TpPacket.

Definition at line 84 of file TpPacket.cpp.

TpPacket::~TpPacket [virtual]
 

delete the rawData.

Definition at line 112 of file TpPacket.cpp.


Member Function Documentation

void TpPacket::dumpHeader std::ostream & out
 

Definition at line 268 of file TpPacket.cpp.

unsigned short TpPacket::getAckNum
 

Return the ACK number.

Definition at line 226 of file TpPacket.cpp.

Referenced by SAR::receivePacket().

unsigned short TpPacket::getCredits
 

Return the number of credits.

Definition at line 236 of file TpPacket.cpp.

Referenced by SAR::receivePacket().

u_char * TpPacket::getData
 

Return a pointer to the data portion of the packet.

Definition at line 156 of file TpPacket.cpp.

Referenced by ReceiveWindow::reassemble().

unsigned short TpPacket::getDataLength
 

Return the length of the data in this packet.

Definition at line 166 of file TpPacket.cpp.

Referenced by ReceiveWindow::addReceive(), ReceiveWindow::reassemble(), and SendWindow::reliableSend().

unsigned short TpPacket::getSeqNum
 

Return the sequence number of the packet.

Definition at line 176 of file TpPacket.cpp.

Referenced by SendWindow::addPacket(), ReceiveWindow::addPacket(), ReceiveWindow::addReceive(), ReceiveWindow::canAdd(), and SendWindow::reliableSend().

u_char * TpPacket::getTpData
 

Used right before sending over network.

This automatically puts the data in a byte array, offset by the size of the Network Protocol header. Therefore, when the network layer goes to insert its info, it does not need to shift this array.

Definition at line 129 of file TpPacket.cpp.

Referenced by NpPacket::NpPacket(), and dumpHeader().

unsigned short TpPacket::getTpLength
 

Return the length of the data plus the length of the TP header.

Definition at line 146 of file TpPacket.cpp.

Referenced by NpPacket::NpPacket().

bool TpPacket::isAck
 

Return true if the ACK bit is set.

Definition at line 216 of file TpPacket.cpp.

Referenced by SAR::receivePacket().

bool TpPacket::isEnd
 

Return true if the end bit is set.

Definition at line 186 of file TpPacket.cpp.

bool TpPacket::isRetrans
 

Return true if the retransmission bit is set.

Definition at line 196 of file TpPacket.cpp.

Referenced by SAR::receivePacket().

void TpPacket::makeRetrans
 

Set the retransmission bit to true.

Definition at line 206 of file TpPacket.cpp.

Referenced by SendWindow::sentPacketTimeoutImpl().

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

Reimplemented from BasicObject.

Definition at line 243 of file TpPacket.cpp.


Member Data Documentation

unsigned short TpPacket::m_ack [private]
 

Definition at line 51 of file TpPacket.h.

bool TpPacket::m_ackBit [private]
 

Definition at line 52 of file TpPacket.h.

unsigned short TpPacket::m_credits [private]
 

Definition at line 50 of file TpPacket.h.

unsigned char* TpPacket::m_data [private]
 

Definition at line 56 of file TpPacket.h.

bool TpPacket::m_endBit [private]
 

Definition at line 54 of file TpPacket.h.

unsigned int TpPacket::m_length [private]
 

Definition at line 53 of file TpPacket.h.

unsigned char* TpPacket::m_rawData [private]
 

Definition at line 57 of file TpPacket.h.

bool TpPacket::m_retransBit [private]
 

Definition at line 55 of file TpPacket.h.

unsigned short TpPacket::m_seqNum [private]
 

Definition at line 49 of file TpPacket.h.


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