Acker Class Reference

#include <tcp-sink.h>

Inheritance diagram for Acker:

Sacker Collaboration diagram for Acker:

Collaboration graph
[legend]

Detailed Description

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

Public Member Functions

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

Data Fields

int last_ack_sent_

Protected Attributes

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


Constructor & Destructor Documentation

Acker::Acker  ) 
 

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

References MWS, and seen_.

00050              : next_(0), maxseen_(0), wndmask_(MWM), ecn_unacked_(0), 
00051     ts_to_echo_(0), last_ack_sent_(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 228 of file tcp-sink.cc.

Referenced by XcpSink::ack().

00229 {
00230 }

int Acker::ecn_unacked  )  [inline]
 

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

References ecn_unacked_.

Referenced by XcpSink::ack().

00066 { return ecn_unacked_;}

int Acker::Maxseen  )  const [inline]
 

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

References maxseen_.

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 XcpSink::reset(), 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 XcpSink::ack(), and Sacker::append_ack().

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 XcpSink::ack().

00065 { return ts_to_echo_;}

int Acker::update int  seqno,
int  numBytes
 

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

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

Referenced by TcpAsymSink::recv().

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

Here is the call graph for this function:

void Acker::update_ecn_unacked int  value  ) 
 

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

References ecn_unacked_.

Referenced by XcpSink::ack().

00233 {
00234     ecn_unacked_ = value;
00235 }

void Acker::update_ts int  seqno,
double  ts,
int  rfc1323 = 0
 

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

References last_ack_sent_, and ts_to_echo_.

Referenced by TcpAsymSink::recv().

00088 {
00089     // update timestamp if segment advances with ACK.
00090         // Code changed by Andrei Gurtov.
00091         if (rfc1323 && seqno == last_ack_sent_ + 1)
00092                ts_to_echo_ = ts;
00093         else if (ts >= ts_to_echo_ && seqno <= last_ack_sent_ + 1)
00094                //rfc1323-bis, update timestamps from duplicate segments
00095                ts_to_echo_ = ts;
00096 }


Field 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::last_ack_sent_
 

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

Referenced by XcpSink::ack(), and update_ts().

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(), and update().

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 Mar 6 17:02:28 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6