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

Channel Class Reference

#include <channel.h>

Inheritance diagram for Channel:

Inheritance graph
[legend]
Collaboration diagram for Channel:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Channel (void)
virtual int command (int argc, const char *const *argv)
virtual void recv (Packet *p, Handler *)
double maxdelay ()
int index ()

Public Attributes

if_head ifhead_
TclObjectgridkeeper_

Protected Member Functions

virtual double get_pdelay (Node *tnode, Node *rnode)

Protected Attributes

int index_
double delay_
Tracetrace_

Private Member Functions

virtual void sendUp (Packet *p, Phy *txif)
void dump (void)

Constructor & Destructor Documentation

Channel::Channel void   ) 
 

Definition at line 90 of file channel.cc.

References ChannelIndex, delay_, ifhead_, index_, and LIST_INIT.

00090                  : TclObject()
00091 {
00092         index_ = ChannelIndex++;
00093         LIST_INIT(&ifhead_);
00094         bind_time("delay_", &delay_);
00095 }


Member Function Documentation

int Channel::command int  argc,
const char *const *  argv
[virtual]
 

Definition at line 97 of file channel.cc.

References ifhead_, index_, and trace_.

00098 {
00099         
00100         if (argc == 3) {
00101                 TclObject *obj;
00102 
00103                 if( (obj = TclObject::lookup(argv[2])) == 0) {
00104                         fprintf(stderr, "%s lookup failed\n", argv[1]);
00105                         return TCL_ERROR;
00106                 }
00107                 if (strcmp(argv[1], "trace-target") == 0) {
00108                         trace_ = (Trace*) obj;
00109                         return (TCL_OK);
00110                 }
00111                 else if(strcmp(argv[1], "addif") == 0) {
00112                         ((Phy*) obj)->insertchnl(&ifhead_);
00113                         ((Phy*) obj)->setchnl(this);
00114                         return TCL_OK;
00115                 }
00116                 // add interface for grid_keeper_
00117                 /*else if(strncasecmp(argv[1], "grid_keeper", 5) == 0) {
00118                         grid_keeper_ = (GridKeeper*)obj;
00119                         return TCL_OK;
00120                         }*/
00121         } else if (argc == 2) {
00122                 Tcl& tcl = Tcl::instance();
00123                 if (strcmp(argv[1], "trace-target") == 0) {
00124                         tcl.resultf("%s", trace_->name());
00125                         return (TCL_OK);
00126                 }
00127                 else if(strcmp(argv[1], "id") == 0) {
00128                         tcl.resultf("%d", index_);
00129                         return TCL_OK;
00130                 }
00131         }
00132         return TclObject::command(argc, argv);
00133 }

void Channel::dump void   )  [private]
 

Definition at line 220 of file channel.cc.

References Phy::dump(), ifhead_, and Phy::nextchnl().

00221 {
00222         Phy *n;
00223         
00224         fprintf(stdout, "Network Interface List\n");
00225         for(n = ifhead_.lh_first; n; n = n->nextchnl() )
00226                 n->dump();
00227         fprintf(stdout, "--------------------------------------------------\n");
00228 }

Here is the call graph for this function:

double Channel::get_pdelay Node tnode,
Node rnode
[protected, virtual]
 

Reimplemented in WirelessChannel, and SatChannel.

Definition at line 212 of file channel.cc.

References delay_.

Referenced by sendUp().

00213 {
00214         // Dummy function
00215         return delay_;
00216 }

int Channel::index  )  [inline]
 

Definition at line 67 of file channel.h.

References index_.

00067 {return index_;}

double Channel::maxdelay  )  [inline]
 

Definition at line 66 of file channel.h.

References delay_.

Referenced by Mac802_3::sendDown().

00066 { return delay_; };

void Channel::recv Packet p,
Handler
[virtual]
 

Reimplemented in NoDupChannel.

Definition at line 136 of file channel.cc.

References sendUp().

Referenced by WirelessPhy::sendDown(), WiredPhy::sendDown(), RepeaterPhy::sendDown(), and SatPhy::sendDown().

00137 {
00138 //      Scheduler& s = Scheduler::instance();
00139 //      hdr_cmn::access(p)->direction() = hdr_cmn::UP;
00140 //      s.schedule(target_, p, txstop_ + delay_ - s.clock());
00141         sendUp(p, (Phy*)h);
00142 }

Here is the call graph for this function:

void Channel::sendUp Packet p,
Phy txif
[private, virtual]
 

Reimplemented in NoDupChannel.

Definition at line 147 of file channel.cc.

References Phy::channel(), Packet::copy(), Packet::free(), GridKeeper::get_neighbors(), get_pdelay(), HDR_CMN, Node::ifhead(), ifhead_, GridKeeper::instance(), Scheduler::instance(), Phy::nextchnl(), Phy::nextnode(), Phy::node(), Scheduler::schedule(), GridKeeper::size_, and hdr_cmn::UP.

Referenced by recv().

00148 {
00149         Scheduler &s = Scheduler::instance();
00150         Phy *rifp = ifhead_.lh_first;
00151         Node *tnode = tifp->node();
00152         Node *rnode = 0;
00153         Packet *newp;
00154         double propdelay = 0.0;
00155         struct hdr_cmn *hdr = HDR_CMN(p);
00156         
00157         hdr->direction() = hdr_cmn::UP;
00158         
00159         if (GridKeeper::instance()) {
00160             int i;
00161             GridKeeper* gk = GridKeeper::instance();
00162             int size = gk->size_; 
00163             
00164             MobileNode **outlist = new MobileNode *[size];
00165          
00166             int out_index = gk->get_neighbors((MobileNode*)tnode,
00167                                                          outlist);
00168             for (i=0; i < out_index; i ++) {
00169                 
00170                   newp = p->copy();
00171                   rnode = outlist[i];
00172                   propdelay = get_pdelay(tnode, rnode);
00173 
00174                   rifp = (rnode->ifhead()).lh_first; 
00175                   for(; rifp; rifp = rifp->nextnode()){
00176                           if (rifp->channel() == this){
00177                                  s.schedule(rifp, newp, propdelay); 
00178                                  break;
00179                           }
00180                   }
00181             }
00182             delete [] outlist; 
00183         } else {
00184             for( ; rifp; rifp = rifp->nextchnl()) {
00185                 rnode = rifp->node();
00186                 if(rnode == tnode)
00187                         continue;
00188                 /*
00189                  * Each node needs to get their own copy of this packet.
00190                  * Since collisions occur at the receiver, we can have
00191                  * two nodes canceling and freeing the *same* simulation
00192                  * event.
00193                  *
00194                  */
00195                 newp = p->copy();
00196                 propdelay = get_pdelay(tnode, rnode);
00197                 
00198                 /*
00199                  * Each node on the channel receives a copy of the
00200                  * packet.  The propagation delay determines exactly
00201                  * when the receiver's interface detects the first
00202                  * bit of this packet.
00203                  */
00204                 s.schedule(rifp, newp, propdelay);
00205             }
00206         }
00207         Packet::free(p);
00208 }

Here is the call graph for this function:


Member Data Documentation

double Channel::delay_ [protected]
 

Definition at line 80 of file channel.h.

Referenced by Channel(), get_pdelay(), maxdelay(), and NoDupChannel::recv().

TclObject* Channel::gridkeeper_
 

Definition at line 65 of file channel.h.

struct if_head Channel::ifhead_
 

Definition at line 64 of file channel.h.

Referenced by SatChannel::add_interface(), Channel(), command(), SatRouteObject::compute_topology(), dump(), SatChannel::find_peer_mac_addr(), LinkHandoffMgr::get_peer(), LinkHandoffMgr::get_peer_linkhead(), SatLinkHandoffMgr::handoff(), TermLinkHandoffMgr::handoff(), NoDupChannel::sendUp(), and sendUp().

int Channel::index_ [protected]
 

Definition at line 79 of file channel.h.

Referenced by Channel(), command(), SatChannel::getId(), and index().

Trace* Channel::trace_ [protected]
 

Definition at line 85 of file channel.h.

Referenced by command().


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