Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

Acker Class Reference

#include <tcp-sink.h>

Inheritance diagram for Acker:

Inheritance graph
[legend]
Collaboration diagram for Acker:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Acker ()
virtual ~Acker ()
void update_ts (int seqno, double ts)
int update (int seqno, int numBytes)
void update_ecn_unacked (int value)
int Seqno () const
virtual void append_ack (hdr_cmn *, hdr_tcp *, int oldSeqno) const
void reset ()
double ts_to_echo ()
int ecn_unacked ()
int Maxseen () const
void resize_buffers (int sz)

Protected Attributes

int next_
int maxseen_
int wndmask_
int ecn_unacked_
int * seen_
double ts_to_echo_
int is_dup_

Constructor & Destructor Documentation

Acker::Acker  ) 
 

Definition at line 50 of file tcp-sink.cc.

References MWM, MWS, and seen_.

00050              : next_(0), maxseen_(0), wndmask_(MWM), ecn_unacked_(0), 
00051         ts_to_echo_(0)
00052 {
00053         seen_ = new int[MWS];
00054         memset(seen_, 0, (sizeof(int) * (MWS)));
00055 }

virtual Acker::~Acker  )  [inline, virtual]
 

Definition at line 58 of file tcp-sink.h.

References seen_.

00058 { delete[] seen_; }


Member Function Documentation

void Acker::append_ack hdr_cmn ,
hdr_tcp ,
int  oldSeqno
const [virtual]
 

Reimplemented in Sacker.

Definition at line 220 of file tcp-sink.cc.

Referenced by TcpSink::ack(), and QSTcpSink::ack().

00221 {
00222 }

int Acker::ecn_unacked  )  [inline]
 

Definition at line 66 of file tcp-sink.h.

References ecn_unacked_.

Referenced by TcpSink::ack(), and QSTcpSink::ack().

00066 { return ecn_unacked_;}

int Acker::Maxseen  )  const [inline]
 

Definition at line 67 of file tcp-sink.h.

References maxseen_.

Referenced by DelAckSink::recv().

00067 { return (maxseen_); }

void Acker::reset  ) 
 

Reimplemented in Sacker.

Definition at line 57 of file tcp-sink.cc.

References maxseen_, next_, seen_, and wndmask_.

Referenced by Sacker::reset(), and TcpSink::reset().

00058 {
00059         next_ = 0;
00060         maxseen_ = 0;
00061         memset(seen_, 0, (sizeof(int) * (wndmask_ + 1)));
00062 }       

void Acker::resize_buffers int  sz  ) 
 

Definition at line 66 of file tcp-sink.cc.

References maxseen_, next_, seen_, and wndmask_.

Referenced by update().

00066                                  { 
00067         int* new_seen = new int[sz];
00068         int new_wndmask = sz - 1;
00069         
00070         if(!new_seen){
00071                 fprintf(stderr, "Unable to allocate buffer seen_[%i]\n", sz);
00072                 exit(1);
00073         }
00074         
00075         memset(new_seen, 0, (sizeof(int) * (sz)));
00076         
00077         for(int i = next_; i <= maxseen_+1; i++){
00078                 new_seen[i & new_wndmask] = seen_[i&wndmask_];
00079         }
00080         
00081         delete[] seen_;
00082         seen_ = new_seen;      
00083         wndmask_ = new_wndmask;
00084         return; 
00085 }

int Acker::Seqno  )  const [inline]
 

Definition at line 62 of file tcp-sink.h.

References next_.

Referenced by TcpSink::ack(), QSTcpSink::ack(), Sacker::append_ack(), DelAckSink::recv(), and TcpAsymSink::recv().

00062 { return (next_ - 1); }

double Acker::ts_to_echo  )  [inline]
 

Definition at line 65 of file tcp-sink.h.

References ts_to_echo_.

Referenced by TcpSink::ack(), and QSTcpSink::ack().

00065 { return ts_to_echo_;}

int Acker::update int  seqno,
int  numBytes
 

Definition at line 95 of file tcp-sink.cc.

References FALSE, Scheduler::instance(), is_dup_, maxseen_, next_, resize_buffers(), seen_, TRUE, and wndmask_.

Referenced by DelAckSink::recv(), TcpSink::recv(), QSTcpSink::recv(), and TcpAsymSink::recv().

00096 {
00097         bool just_marked_as_seen = FALSE;
00098         is_dup_ = FALSE;
00099         // start by assuming the segment hasn't been received before
00100         if (numBytes <= 0)
00101                 printf("Error, received TCP packet size <= 0\n");
00102         int numToDeliver = 0;
00103         while(seq + 1 - next_ >= wndmask_) {
00104                 // next_ is next packet expected; wndmask_ is the maximum
00105                 // window size minus 1; if somehow the seqno of the
00106                 // packet is greater than the one we're expecting+wndmask_,
00107                 // then resize the buffer.
00108                 resize_buffers((wndmask_+1)*2);
00109         }
00110 
00111         if (seq > maxseen_) {
00112                 // the packet is the highest one we've seen so far
00113                 int i;
00114                 for (i = maxseen_ + 1; i < seq; ++i)
00115                         seen_[i & wndmask_] = 0;
00116                 // we record the packets between the old maximum and
00117                 // the new max as being "unseen" i.e. 0 bytes of each
00118                 // packet have been received
00119                 maxseen_ = seq;
00120                 seen_[maxseen_ & wndmask_] = numBytes;
00121                 // store how many bytes have been seen for this packet
00122                 seen_[(maxseen_ + 1) & wndmask_] = 0;
00123                 // clear the array entry for the packet immediately
00124                 // after this one
00125                 just_marked_as_seen = TRUE;
00126                 // necessary so this packet isn't confused as being a duplicate
00127         }
00128         int next = next_;
00129         if (seq < next) {
00130                 // Duplicate packet case 1: the packet is to the left edge of
00131                 // the receive window; therefore we must have seen it
00132                 // before
00133 #ifdef DEBUGDSACK
00134                 printf("%f\t Received duplicate packet %d\n",Scheduler::instance().clock(),seq);
00135 #endif
00136                 is_dup_ = TRUE;
00137         }
00138 
00139         if (seq >= next && seq <= maxseen_) {
00140                 // next is the left edge of the recv window; maxseen_
00141                 // is the right edge; execute this block if there are
00142                 // missing packets in the recv window AND if current
00143                 // packet falls within those gaps
00144 
00145                 if (seen_[seq & wndmask_] && !just_marked_as_seen) {
00146                 // Duplicate case 2: the segment has already been
00147                 // recorded as being received (AND not because we just
00148                 // marked it as such)
00149                         is_dup_ = TRUE;
00150 #ifdef DEBUGDSACK
00151                         printf("%f\t Received duplicate packet %d\n",Scheduler::instance().clock(),seq);
00152 #endif
00153                 }
00154                 seen_[seq & wndmask_] = numBytes;
00155                 // record the packet as being seen
00156                 while (seen_[next & wndmask_]) {
00157                         // this loop first gets executed if seq==next;
00158                         // i.e., this is the next packet in order that
00159                         // we've been waiting for.  the loop sets how
00160                         // many bytes we can now deliver to the
00161                         // application, due to this packet arriving
00162                         // (and the prior arrival of any segments
00163                         // immediately to the right)
00164 
00165                         numToDeliver += seen_[next & wndmask_];
00166                         ++next;
00167                 }
00168                 next_ = next;
00169                 // store the new left edge of the window
00170         }
00171         return numToDeliver;
00172 }

Here is the call graph for this function:

void Acker::update_ecn_unacked int  value  ) 
 

Definition at line 224 of file tcp-sink.cc.

References ecn_unacked_.

Referenced by TcpSink::ack(), and QSTcpSink::ack().

00225 {
00226         ecn_unacked_ = value;
00227 }

void Acker::update_ts int  seqno,
double  ts
 

Definition at line 87 of file tcp-sink.cc.

References next_, ts, and ts_to_echo_.

Referenced by DelAckSink::recv(), TcpSink::recv(), QSTcpSink::recv(), and TcpAsymSink::recv().

00088 {
00089         if (ts >= ts_to_echo_ && seqno <= next_)
00090                 ts_to_echo_ = ts;
00091 }


Member Data Documentation

int Acker::ecn_unacked_ [protected]
 

Definition at line 74 of file tcp-sink.h.

Referenced by ecn_unacked(), and update_ecn_unacked().

int Acker::is_dup_ [protected]
 

Definition at line 78 of file tcp-sink.h.

Referenced by Sacker::append_ack(), and update().

int Acker::maxseen_ [protected]
 

Definition at line 72 of file tcp-sink.h.

Referenced by Sacker::append_ack(), Maxseen(), reset(), resize_buffers(), and update().

int Acker::next_ [protected]
 

Definition at line 71 of file tcp-sink.h.

Referenced by reset(), resize_buffers(), Seqno(), update(), and update_ts().

int* Acker::seen_ [protected]
 

Definition at line 76 of file tcp-sink.h.

Referenced by Acker(), Sacker::append_ack(), reset(), resize_buffers(), update(), and ~Acker().

double Acker::ts_to_echo_ [protected]
 

Definition at line 77 of file tcp-sink.h.

Referenced by ts_to_echo(), and update_ts().

int Acker::wndmask_ [protected]
 

Definition at line 73 of file tcp-sink.h.

Referenced by Sacker::append_ack(), reset(), resize_buffers(), and update().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 12:31:44 2004 for NS2.26SourcesOriginal by doxygen 1.3.3