Channel Class Reference

#include <channel.h>

Inheritance diagram for Channel:

TclObject NoDupChannel SatChannel WirelessChannel Collaboration diagram for Channel:

Collaboration graph
[legend]

Detailed Description

Definition at line 59 of file channel.h.

Public Member Functions

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

Data Fields

TclObjectgridkeeper_
if_head ifhead_

Protected Member Functions

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

Protected Attributes

double delay_
int index_
Tracetrace_

Private Member Functions

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


Constructor & Destructor Documentation

Channel::Channel void   ) 
 

Definition at line 97 of file channel.cc.

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

00097                  : TclObject()
00098 {
00099     index_ = ChannelIndex++;
00100     LIST_INIT(&ifhead_);
00101     bind_time("delay_", &delay_);
00102 }


Member Function Documentation

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

Reimplemented in WirelessChannel.

Definition at line 104 of file channel.cc.

References ifhead_, index_, and trace_.

Referenced by WirelessChannel::command().

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

void Channel::dump void   )  [private]
 

Definition at line 201 of file channel.cc.

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

00202 {
00203     Phy *n;
00204     
00205     fprintf(stdout, "Network Interface List\n");
00206     for(n = ifhead_.lh_first; n; n = n->nextchnl() )
00207         n->dump();
00208     fprintf(stdout, "--------------------------------------------------\n");
00209 }

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 193 of file channel.cc.

References delay_.

Referenced by sendUp().

00194 {
00195     // Dummy function
00196     return delay_;
00197 }

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 144 of file channel.cc.

References sendUp().

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

00145 {
00146     sendUp(p, (Phy*)h);
00147 }

Here is the call graph for this function:

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

Reimplemented in NoDupChannel, and WirelessChannel.

Definition at line 152 of file channel.cc.

References Packet::copy(), hdr_cmn::direction(), get_pdelay(), HDR_CMN, ifhead_, Scheduler::instance(), Phy::nextchnl(), Phy::node(), Scheduler::schedule(), and hdr_cmn::UP.

Referenced by recv().

00153 {
00154     Scheduler &s = Scheduler::instance();
00155     Phy *rifp = ifhead_.lh_first;
00156     Node *tnode = tifp->node();
00157     Node *rnode = 0;
00158     Packet *newp;
00159     double propdelay = 0.0;
00160     struct hdr_cmn *hdr = HDR_CMN(p);
00161 
00162     hdr->direction() = hdr_cmn::UP;
00163     for( ; rifp; rifp = rifp->nextchnl()) {
00164         rnode = rifp->node();
00165         if(rnode == tnode)
00166             continue;
00167         /*
00168          * Each node needs to get their own copy of this packet.
00169          * Since collisions occur at the receiver, we can have
00170          * two nodes canceling and freeing the *same* simulation
00171          * event.
00172          *
00173          */
00174         newp = p->copy();
00175         propdelay = get_pdelay(tnode, rnode);
00176         
00177         /*
00178          * Each node on the channel receives a copy of the
00179          * packet.  The propagation delay determines exactly
00180          * when the receiver's interface detects the first
00181          * bit of this packet.
00182          */
00183         s.schedule(rifp, newp, propdelay);
00184     }
00185 
00186     Packet::free(p);
00187 }

Here is the call graph for this function:


Field Documentation

double Channel::delay_ [protected]
 

Definition at line 81 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(), WirelessChannel::calcHighestAntennaZ(), Channel(), command(), SatRouteObject::compute_topology(), dump(), SatChannel::find_peer_mac_addr(), LinkHandoffMgr::get_peer(), LinkHandoffMgr::get_peer_linkhead(), WirelessChannel::sendUp(), NoDupChannel::sendUp(), and sendUp().

int Channel::index_ [protected]
 

Definition at line 80 of file channel.h.

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

Trace* Channel::trace_ [protected]
 

Definition at line 86 of file channel.h.

Referenced by command().


The documentation for this class was generated from the following files:
Generated on Tue Mar 6 17:04:20 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6