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

Phy Class Reference

#include <phy.h>

Inheritance diagram for Phy:

Inheritance graph
[legend]
Collaboration diagram for Phy:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Phy ()
void recv (Packet *p, Handler *h)
virtual void sendDown (Packet *p)=0
virtual int sendUp (Packet *p)=0
double txtime (Packet *p)
double txtime (int bytes)
virtual double bittime () const
Phynextchnl (void) const
void insertchnl (struct if_head *head)
Phynextnode (void) const
void insertnode (struct if_head *head)
void removechnl ()
void setchnl (Channel *chnl)
virtual void setnode (Node *node)
virtual Nodenode (void) const
virtual Channelchannel (void) const
virtual void dump (void) const
LinkHeadhead ()
NsObjectuptarget ()
NsObjectdowntarget ()
virtual void drop (Packet *p)
virtual void recv (Packet *p, const char *s)
virtual void recvOnly (Packet *)
virtual void delay_bind_init_all ()
virtual int delay_bind_dispatch (const char *varName, const char *localName, TclObject *tracer)
int isdebug () const
virtual void debug (const char *fmt,...)

Protected Member Functions

int command (int argc, const char *const *argv)
 LIST_ENTRY (Phy) chnl_link_
 LIST_ENTRY (Phy) node_link_
virtual void drop (Packet *p, const char *s)
virtual void sendDown (Packet *p, Handler *h)
virtual void sendUp (Packet *p, Handler *h)
virtual void reset ()
void handle (Event *)

Protected Attributes

int index_
Nodenode_
LinkHeadhead_
double bandwidth_
Channelchannel_
NsObjectuptarget_
NsObjectdowntarget_
NsObjectdrop_
int debug_

Constructor & Destructor Documentation

Phy::Phy  ) 
 

Definition at line 54 of file phy.cc.

References bandwidth_, channel_, head_, index_, InterfaceIndex, and node_.

00054          : BiConnector() {
00055         index_ = InterfaceIndex++;
00056         bandwidth_ = 0.0;
00057         channel_ = 0;
00058         node_ = 0;
00059         head_ = 0;
00060 }


Member Function Documentation

virtual double Phy::bittime  )  const [inline, virtual]
 

Definition at line 85 of file phy.h.

References bandwidth_.

00085 { return 1/bandwidth_; }

virtual Channel* Phy::channel void   )  const [inline, virtual]
 

Definition at line 105 of file phy.h.

References channel_.

Referenced by SatLL::channel(), SatRouteObject::compute_topology(), SatChannel::find_peer_mac_addr(), LinkHandoffMgr::get_peer(), LinkHandoffMgr::get_peer_linkhead(), LinkHandoffMgr::get_peer_next_linkhead(), SatLinkHandoffMgr::handoff(), Mac802_3::sendDown(), and Channel::sendUp().

00105 {return channel_;}      

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

Reimplemented from BiConnector.

Reimplemented in WiredPhy, WirelessPhy, and SatPhy.

Definition at line 63 of file phy.cc.

References channel_, BiConnector::command(), BiConnector::downtarget_, head_, index_, and node_.

Referenced by WirelessPhy::command(), WiredPhy::command(), and SatPhy::command().

00063                                              {
00064         if (argc == 2) {
00065                 Tcl& tcl = Tcl::instance();
00066 
00067                 if(strcmp(argv[1], "id") == 0) {
00068                         tcl.resultf("%d", index_);
00069                         return TCL_OK;
00070                 }
00071         }
00072 
00073         else if(argc == 3) {
00074 
00075                 TclObject *obj;
00076 
00077                 if( (obj = TclObject::lookup(argv[2])) == 0) {
00078                         fprintf(stderr, "%s lookup failed\n", argv[1]);
00079                         return TCL_ERROR;
00080                 }
00081                 if (strcmp(argv[1], "channel") == 0) {
00082                         assert(channel_ == 0);
00083                         channel_ = (Channel*) obj;
00084                         downtarget_ = (NsObject*) obj;
00085                         // LIST_INSERT_HEAD() is done by Channel
00086                         return TCL_OK;
00087                 }
00088                 else if (strcmp(argv[1], "node") == 0) {
00089                         assert(node_ == 0);
00090                         node_ = (Node*) obj;
00091                         // LIST_INSERT_HEAD() is done by Node
00092                         return TCL_OK;
00093                 }
00094                 else if (strcmp(argv[1], "linkhead") == 0) {
00095                         head_ = (LinkHead*)  obj;
00096                         return (TCL_OK);
00097                 }
00098 
00099         } 
00100         return BiConnector::command(argc, argv);
00101 }

Here is the call graph for this function:

void NsObject::debug const char *  fmt,
... 
[virtual, inherited]
 

Definition at line 102 of file object.cc.

References NsObject::debug_.

00103 {
00104         if (!debug_)
00105                 return;
00106         va_list ap;
00107         va_start(ap, fmt);
00108         vprintf(fmt, ap);
00109 }

int NsObject::delay_bind_dispatch const char *  varName,
const char *  localName,
TclObject tracer
[virtual, inherited]
 

Reimplemented in BayFullTcpAgent, Agent, MPLSAddressClassifier, LDPAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, and VegasTcpAgent.

Definition at line 63 of file object.cc.

References NsObject::debug_.

Referenced by MPLSAddressClassifier::delay_bind_dispatch(), and Agent::delay_bind_dispatch().

00064 {
00065         if (delay_bind_bool(varName, localName, "debug_", &debug_, tracer)) 
00066                 return TCL_OK;
00067         return TclObject::delay_bind_dispatch(varName, localName, tracer);
00068 }

void NsObject::delay_bind_init_all  )  [virtual, inherited]
 

Reimplemented in BayFullTcpAgent, Agent, MPLSAddressClassifier, LDPAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, and VegasTcpAgent.

Definition at line 57 of file object.cc.

Referenced by MPLSAddressClassifier::delay_bind_init_all(), and Agent::delay_bind_init_all().

00058 {
00059         delay_bind_init_one("debug_");
00060 }

NsObject* BiConnector::downtarget  )  [inline, inherited]
 

Definition at line 49 of file bi-connector.h.

References BiConnector::downtarget_.

Referenced by SatLL::channel().

00049 { return downtarget_; }

void BiConnector::drop Packet p,
const char *  s
[protected, virtual, inherited]
 

Definition at line 144 of file bi-connector.cc.

References BiConnector::drop_, Packet::free(), and NsObject::recv().

00145 {
00146         if (drop_ != 0)
00147                 drop_->recv(p, s);
00148         else
00149                 Packet::free(p);
00150 }

Here is the call graph for this function:

void BiConnector::drop Packet p  )  [virtual, inherited]
 

Definition at line 135 of file bi-connector.cc.

References BiConnector::drop_, Packet::free(), and NsObject::recv().

Referenced by Mac802_3::collision(), Mac802_11::discard(), SMAC::drop_CTS(), SMAC::drop_DATA(), SMAC::drop_RTS(), SMAC::drop_SYNC(), UnslottedAlohaMac::end_of_contention(), MacTdma::recvHandler(), Mac::resume(), MacCsma::resume(), UnslottedAlohaMac::sendUp(), SatMac::sendUp(), Mac::sendUp(), MacTdma::TX_Time(), and Mac802_11::txtime().

00136 {
00137         if (drop_ != 0)
00138                 drop_->recv(p);
00139         else
00140                 Packet::free(p);
00141 }

Here is the call graph for this function:

void Phy::dump void   )  const [virtual]
 

Reimplemented in WirelessPhy.

Definition at line 183 of file phy.cc.

References channel_, index_, u_int32_t, and BiConnector::uptarget_.

Referenced by WirelessPhy::dump(), MobileNode::dump(), and Channel::dump().

00184 {
00185         fprintf(stdout, "\tINDEX: %d\n",
00186                 index_);
00187         fprintf(stdout, "\tuptarget: %x, channel: %x",
00188                 (u_int32_t) uptarget_, (u_int32_t) channel_);
00189 
00190 }

void NsObject::handle Event  )  [protected, virtual, inherited]
 

Implements Handler.

Reimplemented in LinkDelay, LL, AckRecons, and Snoop.

Definition at line 91 of file object.cc.

References NsObject::recv().

00092 {
00093         recv((Packet*)e);
00094 }

Here is the call graph for this function:

LinkHead* Phy::head  )  [inline]
 

Definition at line 108 of file phy.h.

References head_.

Referenced by SatRouteObject::compute_topology(), SatChannel::find_peer_mac_addr(), LinkHandoffMgr::get_peer(), LinkHandoffMgr::get_peer_linkhead(), and SatPhy::sendDown().

00108 { return head_; }

void Phy::insertchnl struct if_head *  head  )  [inline]
 

Definition at line 89 of file phy.h.

References LIST_INSERT_HEAD.

Referenced by SatChannel::add_interface(), SatLinkHandoffMgr::handoff(), and TermLinkHandoffMgr::handoff().

00089                                                      {
00090                 LIST_INSERT_HEAD(head, this, chnl_link_);
00091                 //channel_ = chnl;
00092         }

void Phy::insertnode struct if_head *  head  )  [inline]
 

Definition at line 95 of file phy.h.

References LIST_INSERT_HEAD.

Referenced by SatNode::command(), and MobileNode::command().

00095                                                      {
00096                 LIST_INSERT_HEAD(head, this, node_link_);
00097                 //node_ = node;
00098         }

int NsObject::isdebug  )  const [inline, inherited]
 

Definition at line 61 of file object.h.

References NsObject::debug_.

00061 { return debug_; }

Phy::LIST_ENTRY Phy   )  [protected]
 

Phy::LIST_ENTRY Phy   )  [protected]
 

Phy* Phy::nextchnl void   )  const [inline]
 

Definition at line 88 of file phy.h.

Referenced by SatRouteObject::compute_topology(), Channel::dump(), SatChannel::find_peer_mac_addr(), LinkHandoffMgr::get_peer(), LinkHandoffMgr::get_peer_linkhead(), NoDupChannel::sendUp(), and Channel::sendUp().

00088 { return chnl_link_.le_next; }

Phy* Phy::nextnode void   )  const [inline]
 

Definition at line 94 of file phy.h.

Referenced by MobileNode::dump(), and Channel::sendUp().

00094 { return node_link_.le_next; }

virtual Node* Phy::node void   )  const [inline, virtual]
 

Reimplemented in WirelessPhy.

Definition at line 104 of file phy.h.

References node_.

Referenced by SatRouteObject::compute_topology(), SatChannel::find_peer_mac_addr(), SatLinkHandoffMgr::handoff(), TermLinkHandoffMgr::handoff(), MacTdma::radioSwitch(), Mac802_11::recv_timer(), Mac802_11::send(), and Channel::sendUp().

00104 { return node_; }

void NsObject::recv Packet p,
const char *  s
[virtual, inherited]
 

Reimplemented in CMUTrace.

Definition at line 96 of file object.cc.

References Packet::free().

00097 {
00098         Packet::free(p);
00099 }

Here is the call graph for this function:

void Phy::recv Packet p,
Handler h
[virtual]
 

Reimplemented from BiConnector.

Reimplemented in RepeaterPhy.

Definition at line 106 of file phy.cc.

References hdr_cmn::DOWN, Packet::free(), HDR_CMN, NsObject::recv(), sendDown(), sendUp(), hdr_cmn::UP, and BiConnector::uptarget_.

Referenced by NoDupChannel::sendUp().

00107 {
00108         struct hdr_cmn *hdr = HDR_CMN(p);       
00109         //struct hdr_sr *hsr = HDR_SR(p);
00110         
00111         /*
00112          * Handle outgoing packets
00113          */
00114         switch(hdr->direction()) {
00115         case hdr_cmn::DOWN :
00116                 /*
00117                  * The MAC schedules its own EOT event so we just
00118                  * ignore the handler here.  It's only purpose
00119                  * it distinguishing between incoming and outgoing
00120                  * packets.
00121                  */
00122                 sendDown(p);
00123                 return;
00124         case hdr_cmn::UP :
00125                 if (sendUp(p) == 0) {
00126                         /*
00127                          * XXX - This packet, even though not detected,
00128                          * contributes to the Noise floor and hence
00129                          * may affect the reception of other packets.
00130                          */
00131                         Packet::free(p);
00132                         return;
00133                 } else {
00134                         uptarget_->recv(p, (Handler*) 0);
00135                 }
00136                 break;
00137         default:
00138                 printf("Direction for pkt-flow not specified; Sending pkt up the stack on default.\n\n");
00139                 if (sendUp(p) == 0) {
00140                         /*
00141                          * XXX - This packet, even though not detected,
00142                          * contributes to the Noise floor and hence
00143                          * may affect the reception of other packets.
00144                          */
00145                         Packet::free(p);
00146                         return;
00147                 } else {
00148                         uptarget_->recv(p, (Handler*) 0);
00149                 }
00150         }
00151         
00152 }

Here is the call graph for this function:

virtual void NsObject::recvOnly Packet  )  [inline, virtual, inherited]
 

Reimplemented in Agent, and Trace.

Definition at line 56 of file object.h.

Referenced by Trace::recvOnly().

00056 {};

void Phy::removechnl  )  [inline]
 

Definition at line 99 of file phy.h.

References LIST_REMOVE.

Referenced by SatLinkHandoffMgr::handoff(), TermLinkHandoffMgr::handoff(), and SatChannel::remove_interface().

00099                                  {
00100                 LIST_REMOVE(this, chnl_link_);
00101         }

void NsObject::reset  )  [protected, virtual, inherited]
 

Reimplemented in BayFullTcpAgent, HashClassifier, IvsSource, dsREDQueue, DiffusionRate, SinkAgent, DiffusionAgent, FloodingAgent, OmniMcastAgent, LinkDelay, CBQueue, DropTail, ErrorModel, PIQueue, Queue< T >, RedPDQueue, REDQueue, REMQueue, RIOQueue, Snoop, FackTcpAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, Sack1TcpAgent, TcpSink, DelAckSink, TcpAgent, VegasTcpAgent, toraAgent, and Queue< T >.

Definition at line 70 of file object.cc.

Referenced by NsObject::command().

00071 {
00072 }

virtual void BiConnector::sendDown Packet p,
Handler h
[inline, protected, virtual, inherited]
 

Reimplemented in Mac802_3.

Definition at line 55 of file bi-connector.h.

References BiConnector::downtarget_, and NsObject::recv().

Referenced by BiConnector::recv().

00056                 { downtarget_->recv(p, h); }

Here is the call graph for this function:

virtual void Phy::sendDown Packet p  )  [pure virtual]
 

Implemented in WiredPhy, WirelessPhy, SatPhy, and RepeaterPhy.

Referenced by recv().

virtual void BiConnector::sendUp Packet p,
Handler h
[inline, protected, virtual, inherited]
 

Reimplemented in Mac802_3.

Definition at line 57 of file bi-connector.h.

References NsObject::recv(), and BiConnector::uptarget_.

Referenced by BiConnector::recv().

00058                 { uptarget_->recv(p, h); }

Here is the call graph for this function:

virtual int Phy::sendUp Packet p  )  [pure virtual]
 

Implemented in WiredPhy, WirelessPhy, SatPhy, and RepeaterPhy.

Referenced by recv().

void Phy::setchnl Channel chnl  )  [inline]
 

Definition at line 102 of file phy.h.

References channel_.

Referenced by SatChannel::add_interface(), SatLinkHandoffMgr::handoff(), TermLinkHandoffMgr::handoff(), and SatChannel::remove_interface().

00102 { channel_ = chnl; }

virtual void Phy::setnode Node node  )  [inline, virtual]
 

Definition at line 103 of file phy.h.

References node_.

Referenced by SatNode::command(), and MobileNode::command().

00103 { node_ = node; }

double Phy::txtime int  bytes  )  [inline]
 

Definition at line 83 of file phy.h.

References bandwidth_.

00083                                         {
00084                 return (8.0 * bytes / bandwidth_); }

double Phy::txtime Packet p  )  [inline]
 

Definition at line 81 of file phy.h.

References hdr_cmn::access(), bandwidth_, and hdr_cmn::size().

Referenced by Mac802_3::collision(), Mac8023HandlerSend::handle(), Mac802_3::recv_complete(), MacHandlerRetx::schedule(), WirelessPhy::sendDown(), Mac802_3::sendDown(), Mac802_3::sendUp(), and Mac802_3::transmit().

00081                                          {
00082                 return (hdr_cmn::access(p)->size() * 8.0) / bandwidth_; }

Here is the call graph for this function:

NsObject* BiConnector::uptarget  )  [inline, inherited]
 

Definition at line 48 of file bi-connector.h.

References BiConnector::uptarget_.

Referenced by SatChannel::find_peer_mac_addr().

00048 { return uptarget_; }


Member Data Documentation

double Phy::bandwidth_ [protected]
 

Definition at line 137 of file phy.h.

Referenced by bittime(), Phy(), txtime(), and WiredPhy::WiredPhy().

Channel* Phy::channel_ [protected]
 

Definition at line 138 of file phy.h.

Referenced by channel(), command(), dump(), Phy(), WirelessPhy::sendDown(), WiredPhy::sendDown(), RepeaterPhy::sendDown(), SatPhy::sendDown(), and setchnl().

int NsObject::debug_ [protected, inherited]
 

Reimplemented in FECModel, FloodAgent, and LandmarkAgent.

Definition at line 66 of file object.h.

Referenced by REDQueue::command(), RedPDQueue::command(), PushbackQueue::command(), NsObject::debug(), NsObject::delay_bind_dispatch(), RedPDQueue::enque(), PushbackQueue::enque(), NsObject::isdebug(), NsObject::NsObject(), TfrcAgent::recv(), PushbackQueue::reportDrop(), and REDQueue::reset().

NsObject* BiConnector::downtarget_ [protected, inherited]
 

Definition at line 63 of file bi-connector.h.

Referenced by command(), BiConnector::command(), BiConnector::downtarget(), WirelessPhy::initialized(), WiredPhy::initialized(), SMAC::initialized(), Mac::initialized(), FECModel::recv(), MacTdma::send(), UnslottedAlohaMac::sendDown(), SatMac::sendDown(), Mac::sendDown(), BiConnector::sendDown(), SMAC::transmit(), and Mac802_3::transmit().

NsObject* BiConnector::drop_ [protected, inherited]
 

Definition at line 64 of file bi-connector.h.

Referenced by BiConnector::command(), and BiConnector::drop().

LinkHead* Phy::head_ [protected]
 

Definition at line 116 of file phy.h.

Referenced by command(), head(), and Phy().

int Phy::index_ [protected]
 

Definition at line 113 of file phy.h.

Referenced by command(), dump(), and Phy().

Node* Phy::node_ [protected]
 

Definition at line 115 of file phy.h.

Referenced by WirelessPhy::command(), command(), WirelessPhy::initialized(), WiredPhy::initialized(), WirelessPhy::node(), node(), Phy(), setnode(), WirelessPhy::UpdateIdleEnergy(), and WirelessPhy::WirelessPhy().

NsObject* BiConnector::uptarget_ [protected, inherited]
 

Definition at line 60 of file bi-connector.h.

Referenced by BiConnector::command(), dump(), UnslottedAlohaMac::end_of_contention(), WirelessPhy::initialized(), WiredPhy::initialized(), SMAC::initialized(), Mac::initialized(), God::initialized(), RepeaterPhy::recv(), recv(), FECModel::recv(), Mac802_3::recv_complete(), MacTdma::recvDATA(), Mac802_11::recvDATA(), SMAC::rxMsgDone(), SatMac::sendUp(), Mac::sendUp(), BiConnector::sendUp(), and BiConnector::uptarget().


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