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

SemanticPacketQueue Class Reference

#include <semantic-packetqueue.h>

Inheritance diagram for SemanticPacketQueue:

Inheritance graph
[legend]
Collaboration diagram for SemanticPacketQueue:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SemanticPacketQueue ()
int command (int argc, const char *const *argv)
Packetdeque_acksfirst ()
int compareFlows (hdr_ip *ip1, hdr_ip *ip2)
void filterAcks (Packet *pkt, int replace_head)
int isMarked (Packet *p)
Packetlookup (int index, int markedFlag)
PacketpickPacketForECN (Packet *pkt)
PacketpickPacketToDrop ()
void remove (Packet *p, Packet *pp)
Packethead ()
virtual Packetdeque ()
Packetenque (Packet *)
virtual void enque_head (Packet *p)
virtual void remove (Packet *)
virtual int length () const
virtual int byteLength () const
Packetlookup (int n)
Packettail ()
virtual void enqueHead (Packet *p)
void resetIterator ()
PacketgetNext ()

Public Attributes

int ack_count
int data_count
int acks_to_send
int marked_count_
int unmarked_count_
int acksfirst_
int filteracks_
int reconsAcks_
int replace_head_
int priority_drop_
int random_drop_
int random_ecn_
AckReconsControllerreconsCtrl_

Protected Attributes

Packethead_
Packettail_
int len_
int bytes_

Constructor & Destructor Documentation

SemanticPacketQueue::SemanticPacketQueue  ) 
 

Definition at line 52 of file semantic-packetqueue.cc.

References acksfirst_, filteracks_, priority_drop_, random_drop_, random_ecn_, reconsAcks_, and replace_head_.

00052                                          : ack_count(0), data_count(0), 
00053         acks_to_send(0), marked_count_(0), unmarked_count_(0) 
00054 {
00055         bind_bool("acksfirst_", &acksfirst_);
00056         bind_bool("filteracks_", &filteracks_);
00057         bind_bool("reconsAcks_", &reconsAcks_);
00058         bind_bool("replace_head_", &replace_head_);
00059         bind_bool("priority_drop_", &priority_drop_);
00060         bind_bool("random_drop_", &random_drop_);
00061         bind_bool("random_ecn_", &random_ecn_);
00062 }       


Member Function Documentation

virtual int PacketQueue::byteLength  )  const [inline, virtual, inherited]
 

Definition at line 49 of file queue.h.

References PacketQueue::bytes_.

Referenced by REDQueue::bcount_(), Queue< T >::byteLength(), PIQueue::calculate_p(), REDQueue::deque(), PIQueue::deque(), DropTail::deque(), REDQueue::drop_early(), RIOQueue::enque(), REDQueue::enque(), RedPDQueue::enque(), PushbackQueue::enque(), PIQueue::enque(), and DropTail::enque().

00049 { return (bytes_); }

int SemanticPacketQueue::command int  argc,
const char *const *  argv
 

Definition at line 65 of file semantic-packetqueue.cc.

References reconsAcks_, reconsCtrl_, and AckReconsController::spq_.

00066 {
00067         if (argc == 3) {
00068                 if (strcmp(argv[1], "ackrecons") == 0) {
00069                         if ((reconsCtrl_ = (AckReconsController *) 
00070                              TclObject::lookup(argv[2]))) {
00071                                 reconsCtrl_->spq_ = this;
00072                                 reconsAcks_ = 1;
00073                         }
00074                 }
00075                 return (TCL_OK);
00076         }
00077         return (TclObject::command(argc, argv));
00078 }

int SemanticPacketQueue::compareFlows hdr_ip ip1,
hdr_ip ip2
[inline]
 

Definition at line 62 of file semantic-packetqueue.h.

References hdr_ip::daddr(), hdr_ip::dport(), hdr_ip::saddr(), and hdr_ip::sport().

Referenced by filterAcks().

00062                                                           {
00063                 return ((ip1->saddr() == ip2->saddr()) &&
00064                         (ip1->sport() == ip2->sport()) &&
00065                         (ip1->daddr() == ip2->daddr()) && 
00066                         (ip1->dport() == ip2->dport())); 
00067         }

Here is the call graph for this function:

Packet * SemanticPacketQueue::deque  )  [virtual]
 

Reimplemented from PacketQueue.

Definition at line 292 of file semantic-packetqueue.cc.

References hdr_cmn::access(), ack_count, acksfirst_, data_count, PacketQueue::deque(), deque_acksfirst(), isMarked(), marked_count_, PT_ACK, hdr_cmn::ptype_, and unmarked_count_.

00293 {
00294         Packet *pkt;
00295 
00296         if (acksfirst_)
00297                 pkt = deque_acksfirst();
00298         else
00299                 pkt = PacketQueue::deque();
00300         
00301         if (pkt) {
00302                 if (hdr_cmn::access(pkt)->ptype_ == PT_ACK)
00303                         ack_count--;
00304                 else
00305                         data_count--;
00306                 if (isMarked(pkt))
00307                         marked_count_--;
00308                 else
00309                         unmarked_count_--;
00310         }
00311         return pkt;
00312 }

Here is the call graph for this function:

Packet * SemanticPacketQueue::deque_acksfirst  ) 
 

Definition at line 84 of file semantic-packetqueue.cc.

References hdr_cmn::access(), ack_count, PacketQueue::deque(), PacketQueue::head_, PacketQueue::length(), Packet::next_, packet_t, PT_ACK, hdr_cmn::ptype_, and PacketQueue::remove().

Referenced by deque().

00084                                      {
00085         Packet* p = head_;
00086         Packet* pp = NULL;
00087         packet_t type;
00088 
00089         if (ack_count > 0) {
00090                 while (p) {
00091                         type = hdr_cmn::access(p)->ptype_;
00092                         if (type == PT_ACK)
00093                                 break;
00094                         pp = p;
00095                         p = p->next_;
00096                 }
00097                 if (!p) 
00098                         fprintf(stderr, "In deque_acksfirst(): ack_count: %d but no acks in queue, length = %d\n", ack_count, length());
00099                 PacketQueue::remove(p, pp);
00100         } else {
00101                 p = PacketQueue::deque();
00102         }
00103         return p;
00104 }

Here is the call graph for this function:

Packet * SemanticPacketQueue::enque Packet  )  [virtual]
 

Reimplemented from PacketQueue.

Definition at line 269 of file semantic-packetqueue.cc.

References hdr_cmn::access(), ack_count, data_count, PacketQueue::enque(), filterAcks(), filteracks_, isMarked(), marked_count_, PT_ACK, hdr_cmn::ptype_, reconsAcks_, reconsCtrl_, AckReconsController::recv(), replace_head_, and unmarked_count_.

Referenced by AckRecons::recv().

00270 {
00271         if (reconsAcks_&&(hdr_cmn::access(pkt)->ptype_==PT_ACK)) {
00272                 reconsCtrl_->recv(pkt);
00273                 return NULL;
00274         }
00275         if (hdr_cmn::access(pkt)->ptype_ == PT_ACK)
00276                 ack_count++;
00277         else
00278                 data_count++;
00279         if (isMarked(pkt)) 
00280                 marked_count_++;
00281         else
00282                 unmarked_count_++;
00283 
00284         Packet* pt = PacketQueue::enque(pkt); /* actually enque the packet */
00285 
00286         if (filteracks_ && (hdr_cmn::access(pkt)->ptype_==PT_ACK))
00287                 filterAcks(pkt, replace_head_);
00288         return pt;
00289 }

Here is the call graph for this function:

virtual void SemanticPacketQueue::enque_head Packet p  )  [inline, virtual]
 

Definition at line 115 of file semantic-packetqueue.h.

References PacketQueue::enque(), PacketQueue::head_, PacketQueue::len_, and Packet::next_.

00115                                                   {
00116                 if (len_ == 0)
00117                         PacketQueue::enque(p);
00118                 else {
00119                         p->next_ = head_;
00120                         head_ = p;
00121                         ++len_;
00122                 }
00123         }

Here is the call graph for this function:

virtual void PacketQueue::enqueHead Packet p  )  [inline, virtual, inherited]
 

Definition at line 85 of file queue.h.

References hdr_cmn::access(), PacketQueue::bytes_, PacketQueue::head_, PacketQueue::len_, Packet::next_, hdr_cmn::size(), and PacketQueue::tail_.

Referenced by imepAgent::aggregateObjectBlock(), PushbackQueue::enque(), and PriQueue::recvHighPriority().

00085                                                  {
00086                 if (!head_) tail_ = p;
00087                 p->next_ = head_;
00088                 head_ = p;
00089                 ++len_;
00090                 bytes_ += hdr_cmn::access(p)->size();
00091         }

Here is the call graph for this function:

void SemanticPacketQueue::filterAcks Packet pkt,
int  replace_head
 

Definition at line 114 of file semantic-packetqueue.cc.

References hdr_cmn::access(), hdr_ip::access(), hdr_tcp::access(), ack_count, Scheduler::cancel(), compareFlows(), Packet::free(), head(), Scheduler::instance(), Scheduler::lookup(), Packet::next_, PT_ACK, hdr_cmn::ptype_, PacketQueue::remove(), and hdr_tcp::seqno().

Referenced by enque().

00115 {
00116         int done_replacement = 0;
00117 
00118         Packet *p, *pp, *new_p;
00119         hdr_tcp *tcph = hdr_tcp::access(pkt);
00120         int &ack = tcph->seqno();
00121 
00122         hdr_ip *iph = hdr_ip::access(pkt);
00123         for (p = head(), pp = p; p != 0; ) {
00124                 /* 
00125                  * Check if packet in the queue belongs to the 
00126                  * same connection as the most recent ack
00127                  */
00128                 if (compareFlows(hdr_ip::access(p), iph)) {
00129                         /* check if queued packet is an ack */
00130                         if (hdr_cmn::access(p)->ptype_==PT_ACK) {
00131                                 hdr_tcp *th = hdr_tcp::access(p);
00132                                 /* is this ack older than the current one? */
00133                                 if ((th->seqno() < ack) ||
00134                                     (replace_head && th->seqno() == ack)) { 
00135                                         /* 
00136                                          * If we haven't yet replaced the ack 
00137                                          * closest to the head with the most 
00138                                          * recent ack, do so now.
00139                                          */
00140                                         if (replace_head && pkt != p &&
00141                                             !done_replacement) {
00142                                                 PacketQueue::remove(pkt);
00143                                                 ack_count--; /* XXX */
00144                                                 pkt->next_ = p;
00145                                                 if (pp)
00146                                                         pp->next_ = pkt;
00147                                                 pp = pkt;
00148                                                 done_replacement = 1;
00149                                                 continue;
00150                                         } else if (done_replacement||pkt != p){
00151                                                 new_p = p->next_;
00152                                                 /* 
00153                                                  * If p is in scheduler queue,
00154                                                  * cancel the event. Also, 
00155                                                  * print out a warning because
00156                                                  * this should never happen.
00157                                                  */
00158                                                 Scheduler &s = Scheduler::instance();
00159                                                 if (s.lookup(p->uid_)) {
00160                                                         s.cancel(p);
00161                                                         fprintf(stderr, "Warning: In filterAcks(): packet being dropped from queue is in scheduler queue\n");
00162                                                 }
00163                                                 PacketQueue::remove(p, pp);
00164                                                 /* XXX should drop, but we
00165                                                    don't have access to q */
00166                                                 Packet::free(p); 
00167                                                 ack_count--;
00168                                                 p = new_p;
00169                                                 continue;
00170                                         }
00171                                         if (ack_count <= 0)
00172                                                 fprintf(stderr, 
00173                                                         "oops! ackcount %d\n",
00174                                                         ack_count);
00175                                 }
00176                         }
00177                 }
00178                 pp = p;
00179                 p = p->next_;
00180         }
00181 }

Here is the call graph for this function:

Packet* PacketQueue::getNext  )  [inline, inherited]
 

Definition at line 93 of file queue.h.

References PacketQueue::iter, and Packet::next_.

00093                           { 
00094                 if (!iter) return 0;
00095                 Packet *tmp = iter; iter = iter->next_;
00096                 return tmp;
00097         }

Packet* SemanticPacketQueue::head  )  [inline]
 

Reimplemented from PacketQueue.

Definition at line 92 of file semantic-packetqueue.h.

References PacketQueue::head_.

Referenced by filterAcks().

00092 { return head_; }

int SemanticPacketQueue::isMarked Packet p  ) 
 

Definition at line 185 of file semantic-packetqueue.cc.

References hdr_flags::access(), and hdr_flags::fs_.

Referenced by deque(), enque(), lookup(), and remove().

00186 {
00187         return (hdr_flags::access(p)->fs_);
00188 }

Here is the call graph for this function:

virtual int PacketQueue::length  )  const [inline, virtual, inherited]
 

Definition at line 48 of file queue.h.

References PacketQueue::len_.

Referenced by imepAgent::aggregateAckBlock(), imepAgent::aggregateHelloBlock(), imepAgent::aggregateObjectBlock(), redQueue::calcAvg(), PIQueue::calculate_p(), Vq::deque(), SimpleIntServ::deque(), REMQueue::deque(), REDQueue::deque(), PIQueue::deque(), GK::deque(), DropTail::deque(), deque_acksfirst(), REDQueue::drop_early(), Vq::dropPacketForECN(), Vq::enque(), SimpleIntServ::enque(), RIOQueue::enque(), REMQueue::enque(), REDQueue::enque(), RedPDQueue::enque(), PushbackQueue::enque(), PIQueue::enque(), Marker::enque(), GK::enque(), redQueue::enque(), DropTail::enque(), Demarker::enque(), PriQueue::filter(), DSDV_Agent::forwardPacket(), redQueue::getRealLength(), imepAgent::handlerBeaconTimer(), imepAgent::handlerControlTimer(), Queue< T >::length(), pickPacketForECN(), pickPacketToDrop(), REDQueue::pickPacketToDrop(), PIQueue::pickPacketToDrop(), LinkDelay::pktintran(), TBF::recv(), PriQueue::recvHighPriority(), LinkDelay::reset(), TBF::timeout(), and TBF::~TBF().

00048 { return (len_); }

Packet* PacketQueue::lookup int  n  )  [inline, inherited]
 

Definition at line 71 of file queue.h.

References PacketQueue::head_, and Packet::next_.

Referenced by DRR::deque(), PriQueue::filter(), pickPacketForECN(), pickPacketToDrop(), REDQueue::pickPacketToDrop(), PIQueue::pickPacketToDrop(), LinkDelay::pktintran(), and PriQueue::recvHighPriority().

00071                               {
00072                 for (Packet* p = head_; p != 0; p = p->next_) {
00073                         if (--n < 0)
00074                                 return (p);
00075                 }
00076                 return (0);
00077         }

Packet * SemanticPacketQueue::lookup int  index,
int  markedFlag
 

Definition at line 193 of file semantic-packetqueue.cc.

References PacketQueue::head_, isMarked(), and Packet::next_.

Referenced by pickPacketToDrop().

00194 {
00195         if (index < 0) {
00196                 fprintf(stderr, "In SemanticPacketQueue::lookup(): index = %d\n", index);
00197                 return (NULL);
00198         }
00199         for (Packet* p = head_; p != 0; p = p->next_) {
00200                 if (isMarked(p) == markedFlag)
00201                         if (--index < 0)
00202                                 return (p);
00203         }
00204         return (NULL);
00205 }

Here is the call graph for this function:

Packet * SemanticPacketQueue::pickPacketForECN Packet pkt  ) 
 

Definition at line 213 of file semantic-packetqueue.cc.

References Random::integer(), PacketQueue::length(), PacketQueue::lookup(), and random_ecn_.

00214 {
00215         Packet *victim;
00216         int victimIndex;
00217 
00218         if (random_ecn_) {
00219                 victimIndex = Random::integer(length()+1);
00220                 if (victimIndex == length())
00221                         victim = pkt;
00222                 else
00223                         victim = PacketQueue::lookup(victimIndex);
00224         }
00225         else 
00226                 victim = pkt;
00227         return (victim);
00228 }

Here is the call graph for this function:

Packet * SemanticPacketQueue::pickPacketToDrop  ) 
 

Definition at line 237 of file semantic-packetqueue.cc.

References Random::integer(), PacketQueue::length(), lookup(), PacketQueue::lookup(), marked_count_, priority_drop_, random_drop_, and unmarked_count_.

00238 {
00239         Packet *victim;
00240         int victimIndex, victimMarked;
00241 
00242         if (!priority_drop_) {
00243                 if (random_drop_)
00244                         victim=PacketQueue::lookup(Random::integer(length()));
00245                 else
00246                         victim = PacketQueue::lookup(length() - 1);
00247         } else {
00248                 /* if there are marked (low priority) packets */
00249                 if (marked_count_) {
00250                         victimMarked = 1;
00251                         if (!random_drop_) 
00252                                 victimIndex = marked_count_ - 1;
00253                         else
00254                                 victimIndex = Random::integer(marked_count_);
00255                 }
00256                 else {
00257                         victimMarked = 0;
00258                         if (!random_drop_)
00259                                 victimIndex = unmarked_count_ - 1;
00260                         else
00261                                 victimIndex = Random::integer(unmarked_count_);
00262                 }
00263                 victim = lookup(victimIndex, victimMarked);
00264         }
00265         return (victim);
00266 }

Here is the call graph for this function:

void SemanticPacketQueue::remove Packet  )  [virtual]
 

Reimplemented from PacketQueue.

Definition at line 315 of file semantic-packetqueue.cc.

References hdr_cmn::access(), ack_count, data_count, isMarked(), marked_count_, PT_ACK, hdr_cmn::ptype_, PacketQueue::remove(), and unmarked_count_.

00316 {
00317         PacketQueue::remove(pkt);
00318         if (pkt) {
00319                 if (hdr_cmn::access(pkt)->ptype_ == PT_ACK)
00320                         ack_count--;
00321                 else
00322                         data_count--;
00323                 if (isMarked(pkt))
00324                         marked_count_--;
00325                 else
00326                         unmarked_count_--;
00327         }
00328 }

Here is the call graph for this function:

void SemanticPacketQueue::remove Packet p,
Packet pp
 

Reimplemented from PacketQueue.

void PacketQueue::resetIterator  )  [inline, inherited]
 

Definition at line 92 of file queue.h.

References PacketQueue::head_, and PacketQueue::iter.

00092 {iter = head_;}

Packet* PacketQueue::tail  )  [inline, inherited]
 

Definition at line 83 of file queue.h.

References PacketQueue::tail_.

00083 { return tail_; }


Member Data Documentation

int SemanticPacketQueue::ack_count
 

Definition at line 95 of file semantic-packetqueue.h.

Referenced by deque(), deque_acksfirst(), enque(), filterAcks(), and remove().

int SemanticPacketQueue::acks_to_send
 

Definition at line 97 of file semantic-packetqueue.h.

int SemanticPacketQueue::acksfirst_
 

Definition at line 105 of file semantic-packetqueue.h.

Referenced by deque(), and SemanticPacketQueue().

int PacketQueue::bytes_ [protected, inherited]
 

Definition at line 103 of file queue.h.

Referenced by PacketQueue::byteLength(), PacketQueue::deque(), PacketQueue::enque(), PacketQueue::enqueHead(), PacketQueue::PacketQueue(), and PacketQueue::remove().

int SemanticPacketQueue::data_count
 

Definition at line 96 of file semantic-packetqueue.h.

Referenced by deque(), enque(), and remove().

int SemanticPacketQueue::filteracks_
 

Definition at line 106 of file semantic-packetqueue.h.

Referenced by enque(), and SemanticPacketQueue().

Packet* PacketQueue::head_ [protected, inherited]
 

Definition at line 100 of file queue.h.

Referenced by PacketQueue::deque(), deque_acksfirst(), PacketQueue::enque(), enque_head(), PacketQueue::enqueHead(), head(), PacketQueue::head(), lookup(), PacketQueue::lookup(), PacketQueue::PacketQueue(), PacketQueue::remove(), and PacketQueue::resetIterator().

int PacketQueue::len_ [protected, inherited]
 

Definition at line 102 of file queue.h.

Referenced by PacketQueue::deque(), PacketQueue::enque(), enque_head(), PacketQueue::enqueHead(), PacketQueue::length(), PacketQueue::PacketQueue(), and PacketQueue::remove().

int SemanticPacketQueue::marked_count_
 

Definition at line 98 of file semantic-packetqueue.h.

Referenced by deque(), enque(), pickPacketToDrop(), and remove().

int SemanticPacketQueue::priority_drop_
 

Definition at line 110 of file semantic-packetqueue.h.

Referenced by pickPacketToDrop(), and SemanticPacketQueue().

int SemanticPacketQueue::random_drop_
 

Definition at line 111 of file semantic-packetqueue.h.

Referenced by pickPacketToDrop(), and SemanticPacketQueue().

int SemanticPacketQueue::random_ecn_
 

Definition at line 112 of file semantic-packetqueue.h.

Referenced by pickPacketForECN(), and SemanticPacketQueue().

int SemanticPacketQueue::reconsAcks_
 

Definition at line 107 of file semantic-packetqueue.h.

Referenced by command(), enque(), AckRecons::handle(), AckRecons::recv(), and SemanticPacketQueue().

AckReconsController* SemanticPacketQueue::reconsCtrl_
 

Definition at line 125 of file semantic-packetqueue.h.

Referenced by command(), and enque().

int SemanticPacketQueue::replace_head_
 

Definition at line 108 of file semantic-packetqueue.h.

Referenced by enque(), and SemanticPacketQueue().

Packet* PacketQueue::tail_ [protected, inherited]
 

Definition at line 101 of file queue.h.

Referenced by PacketQueue::deque(), PacketQueue::enque(), PacketQueue::enqueHead(), PacketQueue::PacketQueue(), PacketQueue::remove(), and PacketQueue::tail().

int SemanticPacketQueue::unmarked_count_
 

Definition at line 99 of file semantic-packetqueue.h.

Referenced by deque(), enque(), pickPacketToDrop(), and remove().


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