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

SrmNode Class Reference

#include <srm-topo.h>

Inheritance diagram for SrmNode:

Inheritance graph
[legend]
Collaboration diagram for SrmNode:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SrmNode ()
void id (int i)
void handle (Event *)
void send (SRM_Event *)
void append (SRM_Event *)
void remove (int, int)

Protected Member Functions

void sched_nack (int)
void dump_packet (SRM_Event *e)

Protected Attributes

int id_
int expected_
SRM_Requestpending_

Constructor & Destructor Documentation

SrmNode::SrmNode  )  [inline]
 

Definition at line 88 of file srm-topo.h.

References expected_, id_, and pending_.

00088 : id_(0), expected_(0), pending_(0) {}


Member Function Documentation

void SrmNode::append SRM_Event  ) 
 

Definition at line 411 of file srm-topo.cc.

References pending_, and req.

Referenced by sched_nack().

00412 {
00413         SRM_Request *req = new SRM_Request(e);
00414         req->next_ = pending_;
00415         pending_ = req;
00416 }

void SrmNode::dump_packet SRM_Event e  )  [protected]
 

Definition at line 306 of file srm-topo.cc.

References id_, SRM_Event::iif(), tprintf, and SRM_Event::type().

00307 {
00308 #ifdef SRM_DEBUG
00309         tprintf(("(type %d) (in %d) -- @ %d --> \n", e->type(), e->iif(), id_));
00310 #endif
00311 }

Here is the call graph for this function:

void SrmNode::handle Event  )  [virtual]
 

Implements Handler.

Definition at line 353 of file srm-topo.cc.

References expected_, id_, remove(), sched_nack(), send(), SRM_Event::seqno(), SRM_DATA, SRM_NO_SUPPRESS, SRM_PENDING_RREQ, SRM_RREQ, SRM_SUPPRESS, tprintf, and SRM_Event::type().

00354 {
00355         SRM_Event *srm_event = (SRM_Event *) event;
00356         int type  = srm_event->type();
00357         int seqno = srm_event->seqno();
00358         //int iif   = srm_event->iif();
00359         //Scheduler& s = Scheduler::instance();
00360 
00361         switch (type) {
00362         case SRM_DATA :
00363                 if (seqno != expected_) 
00364                         sched_nack(seqno);
00365                 expected_ = seqno;
00366                 break;
00367 
00368         case SRM_PENDING_RREQ :
00369                 tprintf(("Fired RREQ (node %d)\n", id_));
00370                 remove(seqno, SRM_NO_SUPPRESS);
00371                 srm_event->type(SRM_RREQ);
00372                 break;
00373 
00374         case SRM_RREQ :
00375 
00376                 remove(seqno, SRM_SUPPRESS);
00377                 break;
00378 
00379         default :
00380                 tprintf(("panic: node(%d) Unexpected type %d\n", id_, type));
00381                 return;
00382         }
00383 #ifdef SRM_STAR
00384         if (type == SRM_RREQ || type == SRM_DATA) {
00385                 delete srm_event;
00386                 return;
00387         }
00388 #endif
00389         send(srm_event);        
00390         return;
00391 }

Here is the call graph for this function:

void SrmNode::id int  i  )  [inline]
 

Definition at line 89 of file srm-topo.h.

References id_.

Referenced by Topology::Topology().

00089 { id_ = i; }

void SrmNode::remove int  ,
int 
 

Definition at line 419 of file srm-topo.cc.

References SRM_Request::cancel_timer(), SRM_Request::event_, SRM_Request::next_, pending_, SRM_Event::seqno(), and SRM_SUPPRESS.

Referenced by handle().

00420 {
00421         SRM_Request *curr, *prev;
00422         SRM_Event *ev;
00423 
00424         if (!pending_)
00425                 return;
00426         for (curr=pending_, prev=0; curr; curr=curr->next_) 
00427         {
00428                 ev = curr->event_;
00429                 if (ev->seqno() == seqno) {
00430                         if (!prev) 
00431                                 pending_ = curr->next_;
00432                         else {
00433                                 prev->next_ = curr->next_;
00434                                 prev = curr;
00435                         }
00436                         if (flag == SRM_SUPPRESS) {
00437                                 curr->cancel_timer();
00438                         }
00439                         delete curr;
00440                 }
00441         }
00442 }

Here is the call graph for this function:

void SrmNode::sched_nack int   )  [protected]
 

Definition at line 397 of file srm-topo.cc.

References append(), Topology::backoff(), Scheduler::clock(), id_, Scheduler::instance(), Scheduler::schedule(), SRM_NOIF, SRM_PENDING_RREQ, and topology.

Referenced by handle().

00398 {
00399         double backoff, time;
00400         Scheduler& s = Scheduler::instance();
00401         SRM_Event *event = new SRM_Event(seqno, 
00402                                          SRM_PENDING_RREQ, SRM_NOIF);
00403         append(event);
00404 
00405         backoff = topology->backoff(id_);
00406         time = backoff + s.clock();
00407 //      tprintf(("node(%d) schd rrq after %f s\n", id_, backoff));
00408         s.schedule(this, event, backoff);
00409 }

Here is the call graph for this function:

void SrmNode::send SRM_Event  ) 
 

Definition at line 316 of file srm-topo.cc.

References Topology::delay(), Interface_List::head_, id_, SRM_Event::iif(), Interface::in_, Scheduler::instance(), Interface::next_, Topology::node(), Topology::oif(), Scheduler::schedule(), SRM_Event::seqno(), topology, and SRM_Event::type().

Referenced by Star::flood(), BTree::flood(), Line::flood(), and handle().

00317 {
00318         /* 
00319          * Copy the packet and send it over to 
00320          * all the outbound interfaces 
00321          */
00322         int nn;
00323         Scheduler& s = Scheduler::instance();
00324         SRM_Event *copy;
00325         Interface *p;
00326         Interface_List *ilist = topology->oif(id_, e->iif());
00327         if (e->iif() < 0)
00328                 e->iif(id_);
00329 
00330         if (ilist) {
00331                 for (p=ilist->head_; p; p=p->next_) {
00332                         nn = p->in_;
00333                         int t = e->type();
00334                         //int i = id_; 
00335                         int snum = e->seqno();
00336                         SrmNode *next = topology->node(nn);
00337                         if (next) {
00338                                 copy = new SRM_Event(snum, t, id_);
00339                                 s.schedule(next, copy,
00340                                            topology->delay(id_, nn));    
00341                         }
00342                 }
00343         }
00344         delete ilist;
00345         delete e;
00346 }

Here is the call graph for this function:


Member Data Documentation

int SrmNode::expected_ [protected]
 

Definition at line 102 of file srm-topo.h.

Referenced by handle(), and SrmNode().

int SrmNode::id_ [protected]
 

Definition at line 101 of file srm-topo.h.

Referenced by dump_packet(), handle(), id(), sched_nack(), send(), and SrmNode().

SRM_Request* SrmNode::pending_ [protected]
 

Definition at line 103 of file srm-topo.h.

Referenced by append(), remove(), and SrmNode().


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