Phy802_15_4 Class Reference

#include <p802_15_4phy.h>

Inheritance diagram for Phy802_15_4:

WirelessPhy Phy BiConnector NsObject TclObject Handler Collaboration diagram for Phy802_15_4:

Collaboration graph
[legend]

Detailed Description

Definition at line 124 of file p802_15_4phy.h.

Public Member Functions

virtual double bittime () const
virtual Channelchannel (void) const
bool channelSupported (UINT_8 channel)
virtual int command (int argc, const char *const *argv)
void construct_PPDU (UINT_8 psduLength, Packet *psdu)
virtual void debug (const char *fmt,...)
virtual int delay_bind_dispatch (const char *varName, const char *localName, TclObject *tracer)
virtual void delay_bind_init_all ()
NsObjectdowntarget ()
virtual void drop (Packet *p)
virtual void dump (void) const
double getAntennaZ ()
double getCSThresh ()
double getDist (double Pr, double Pt, double Gt, double Gr, double hr, double ht, double L, double lambda)
double getFreq ()
double getL () const
double getLambda () const
double getPt ()
double getPtconsume ()
double getRate (char dataOrSymbol)
double getRXThresh ()
LinkHeadhead ()
void insertchnl (struct if_head *head)
void insertnode (struct if_head *head)
bool & Is_node_on ()
bool Is_sleeping ()
int isdebug () const
void macObj (Mac802_15_4 *m)
UINT_8 measureLinkQ (Packet *p)
Phynextchnl (void) const
Phynextnode (void) const
Nodenode (void) const
void node_off ()
void node_on ()
void node_sleep ()
void node_wakeup ()
void PD_DATA_indication (UINT_8 psduLength, Packet *psdu, UINT_8 ppduLinkQuality)
void PD_DATA_request (UINT_8 psduLength, Packet *psdu)
 Phy802_15_4 (PHY_PIB *pp)
void PLME_CCA_request ()
void PLME_ED_request ()
void PLME_GET_request (PPIBAenum PIBAttribute)
void PLME_SET_request (PPIBAenum PIBAttribute, PHY_PIB *PIBAttributeValue)
void PLME_SET_TRX_STATE_request (PHYenum state)
virtual void recv (Packet *p, const char *s)
void recv (Packet *p, Handler *h)
virtual void recvOnly (Packet *)
void removechnl ()
PacketrxPacket (void)
void sendDown (Packet *p)
int sendUp (Packet *p)
void setchnl (Channel *chnl)
virtual void setnode (Node *node)
double trxTime (Packet *p, bool phyPkt=false)
double txtime (int bytes)
double txtime (Packet *p)
NsObjectuptarget ()

Static Public Attributes

static PHY_PIB PPIB

Protected Types

enum  ChannelStatus { SLEEP, IDLE, RECV, SEND }

Protected Member Functions

void CCAHandler (void)
virtual void drop (Packet *p, const char *s)
void EDHandler (void)
void handle (Event *)
 LIST_ENTRY (Phy) node_link_
 LIST_ENTRY (Phy) chnl_link_
void recvOverHandler (Packet *p)
virtual void reset ()
virtual void sendDown (Packet *p, Handler *h)
void sendOverHandler (void)
virtual void sendUp (Packet *p, Handler *h)
void TRXHandler (void)

Protected Attributes

Antennaant_
double bandwidth_
Channelchannel_
double channel_idle_time_
double CPThresh_
double CSThresh_
int debug_
NsObjectdowntarget_
NsObjectdrop_
double freq_
LinkHeadhead_
int index_
double L_
double lambda_
double last_send_time_
Modulationmodulation_
Nodenode_
bool node_on_
double P_idle_
double P_sleep_
double P_transition_
double Pr_consume_
Propagationpropagation_
double Pt_
double Pt_consume_
double RXThresh_
Sleep_Timer sleep_timer_
int status_
double T_transition_
double update_energy_time_
NsObjectuptarget_

Private Attributes

Phy802_15_4Timer CCAH
Phy802_15_4Timer EDH
Mac802_15_4mac
PHY_PIB ppib
Phy802_15_4Timer recvOverH
double rxEDPeakPower
PacketrxPkt
UINT_32 rxThisTotNum [27]
UINT_32 rxTotNum [27]
double rxTotPower [27]
Phy802_15_4Timer sendOverH
PHYenum trx_state
PHYenum trx_state_defer_set
PHYenum trx_state_turnaround
Phy802_15_4Timer TRXH
PHYenum tx_state
PackettxPkt
PackettxPktCopy

Friends

class Phy802_15_4Timer


Member Enumeration Documentation

enum WirelessPhy::ChannelStatus [protected, inherited]
 

Enumerator:
SLEEP 
IDLE 
RECV 
SEND 

Definition at line 129 of file wireless-phy.h.

00129 { SLEEP, IDLE, RECV, SEND };    


Constructor & Destructor Documentation

Phy802_15_4::Phy802_15_4 PHY_PIB pp  ) 
 

Definition at line 110 of file p802_15_4phy.cc.

References p_IDLE, p_RX_ON, ppib, rxPkt, rxThisTotNum, rxTotNum, rxTotPower, trx_state, trx_state_defer_set, and tx_state.

00111 : WirelessPhy(),
00112   CCAH(this, phyCCAHType),
00113   EDH(this, phyEDHType),
00114   TRXH(this, phyTRXHType),
00115   recvOverH(this, phyRecvOverHType),
00116   sendOverH(this, phySendOverHType)
00117 {
00118     int i;
00119     ppib = *pp;
00120     trx_state = p_RX_ON;
00121     trx_state_defer_set = p_IDLE;
00122     tx_state = p_IDLE;
00123     rxPkt = 0;
00124     for (i=0;i<27;i++)
00125     {
00126         rxTotPower[i] = 0.0;
00127         rxTotNum[i] = 0;
00128         rxThisTotNum[i] = 0;
00129     }
00130     mac = 0;
00131 }


Member Function Documentation

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

Definition at line 85 of file phy.h.

References Phy::bandwidth_.

00085 { return 1/bandwidth_; }

void Phy802_15_4::CCAHandler void   )  [protected]
 

Definition at line 614 of file p802_15_4phy.cc.

References WirelessPhy::CSThresh_, mac, p_BUSY, p_IDLE, PHY_PIB::phyCCAMode, PHY_PIB::phyCurrentChannel, Mac802_15_4::PLME_CCA_confirm(), ppib, rxTotNum, rxTotPower, and tx_state.

Referenced by Phy802_15_4Timer::handle().

00615 {
00616     PHYenum t_status;
00617 
00618     //refer to sec 6.7.9 for CCA details
00619     //  1. CCA will be affected by outgoing packets,
00620     //     incoming packets (both destined for this device 
00621     //     and not destined for this device) and other
00622     //     interferences.
00623     //  2. In implementation, we don't care about the details 
00624     //     and just need to perform an actual measurement.
00625     if ((tx_state == p_BUSY)||(rxTotNum[ppib.phyCurrentChannel] > 0))
00626     {
00627         t_status = p_BUSY;
00628     }
00629     else if (ppib.phyCCAMode == 1)  //ED detection
00630     {
00631         //sec 6.5.3.3 and 6.6.3.4
00632         // -- receiver sensitivity: -85 dBm or better for 2.4G
00633         // -- receiver sensitivity: -92 dBm or better for 868M/915M
00634         //sec 6.7.9
00635         // -- ED threshold at most 10 dB above receiver sensitivity.
00636         //For simulations, we simply compare with CSThresh_
00637         t_status = (rxTotPower[ppib.phyCurrentChannel] >= CSThresh_)?p_BUSY:p_IDLE;
00638     }
00639     else if (ppib.phyCCAMode == 2)  //carrier sense only
00640     {
00641         t_status = (rxTotNum[ppib.phyCurrentChannel] > 0)?p_BUSY:p_IDLE;
00642     }
00643     else //if (ppib.phyCCAMode == 3)    //both
00644     {
00645         t_status = ((rxTotPower[ppib.phyCurrentChannel] >= CSThresh_)&&(rxTotNum[ppib.phyCurrentChannel] > 0))?p_BUSY:p_IDLE;
00646     }
00647     mac->PLME_CCA_confirm(t_status);
00648 }

Here is the call graph for this function:

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

Definition at line 105 of file phy.h.

References Phy::channel_.

Referenced by SatLL::channel(), SatRouteObject::compute_topology(), LinkHandoffMgr::get_peer(), LinkHandoffMgr::get_peer_linkhead(), LinkHandoffMgr::get_peer_next_linkhead(), Mac802_3::sendDown(), and WirelessChannel::sendUp().

00105 {return channel_;}  

bool Phy802_15_4::channelSupported UINT_8  channel  ) 
 

Definition at line 138 of file p802_15_4phy.cc.

References PHY_PIB::phyChannelsSupported, and ppib.

Referenced by Mac802_15_4::mlme_associate_request(), Mac802_15_4::mlme_start_request(), Mac802_15_4::mlme_sync_request(), and PLME_SET_request().

00139 {
00140     return ((ppib.phyChannelsSupported & (1 << channel)) != 0);
00141 }

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

Reimplemented from Phy.

Definition at line 134 of file wireless-phy.cc.

References WirelessPhy::ant_, Phy::command(), EnergyModel::DecrIdleEnergy(), WirelessPhy::em(), Phy::node_, WirelessPhy::node_off(), WirelessPhy::node_on(), NOW, WirelessPhy::P_idle_, WirelessPhy::P_sleep_, WirelessPhy::P_transition_, WirelessPhy::Pr_consume_, WirelessPhy::propagation_, WirelessPhy::Pt_consume_, WirelessPhy::T_transition_, and WirelessPhy::update_energy_time_.

00135 {
00136     TclObject *obj; 
00137 
00138     if (argc==2) {
00139         if (strcasecmp(argv[1], "NodeOn") == 0) {
00140             node_on();
00141 
00142             if (em() == NULL) 
00143                 return TCL_OK;
00144             if (NOW > update_energy_time_) {
00145                 update_energy_time_ = NOW;
00146             }
00147             return TCL_OK;
00148         } else if (strcasecmp(argv[1], "NodeOff") == 0) {
00149             node_off();
00150 
00151             if (em() == NULL) 
00152                 return TCL_OK;
00153             if (NOW > update_energy_time_) {
00154                 em()->DecrIdleEnergy(NOW-update_energy_time_,
00155                              P_idle_);
00156                 update_energy_time_ = NOW;
00157             }
00158             return TCL_OK;
00159         }
00160     } else if(argc == 3) {
00161         if (strcasecmp(argv[1], "setTxPower") == 0) {
00162             Pt_consume_ = atof(argv[2]);
00163             return TCL_OK;
00164         } else if (strcasecmp(argv[1], "setRxPower") == 0) {
00165             Pr_consume_ = atof(argv[2]);
00166             return TCL_OK;
00167         } else if (strcasecmp(argv[1], "setIdlePower") == 0) {
00168             P_idle_ = atof(argv[2]);
00169             return TCL_OK;
00170         }else if (strcasecmp(argv[1], "setSleepPower") == 0) {
00171             P_sleep_ = atof(argv[2]);
00172             return TCL_OK;
00173         } else if (strcasecmp(argv[1], "setTransitionPower") == 0) {
00174             P_transition_ = atof(argv[2]);
00175             return TCL_OK;
00176         } else if (strcasecmp(argv[1], "setTransitionTime") == 0) {
00177             T_transition_ = atof(argv[2]);
00178             return TCL_OK;
00179         }else if( (obj = TclObject::lookup(argv[2])) == 0) {
00180             fprintf(stderr,"WirelessPhy: %s lookup of %s failed\n", 
00181                 argv[1], argv[2]);
00182             return TCL_ERROR;
00183         }else if (strcmp(argv[1], "propagation") == 0) {
00184             assert(propagation_ == 0);
00185             propagation_ = (Propagation*) obj;
00186             return TCL_OK;
00187         } else if (strcasecmp(argv[1], "antenna") == 0) {
00188             ant_ = (Antenna*) obj;
00189             return TCL_OK;
00190         } else if (strcasecmp(argv[1], "node") == 0) {
00191             assert(node_ == 0);
00192             node_ = (Node *)obj;
00193             return TCL_OK;
00194         }
00195     }
00196     return Phy::command(argc,argv);
00197 }

Here is the call graph for this function:

void Phy802_15_4::construct_PPDU UINT_8  psduLength,
Packet psdu
 

Definition at line 182 of file p802_15_4phy.cc.

References defPHY_HEADER_LEN, defSHR_PreSeq, defSHR_SFD, HDR_CMN, HDR_LRWPAN, hdr_lrwpan::PHR_FrmLen, PHY_PIB::phyCurrentChannel, hdr_lrwpan::phyCurrentChannel, ppib, hdr_lrwpan::SHR_PreSeq, hdr_lrwpan::SHR_SFD, hdr_cmn::size(), trxTime(), and hdr_cmn::txtime().

Referenced by PD_DATA_request().

00183 {
00184     //not really a new packet in simulation, but just update some packet header fields.
00185     hdr_lrwpan* wph = HDR_LRWPAN(psdu);
00186     hdr_cmn* ch = HDR_CMN(psdu);
00187     
00188     wph->SHR_PreSeq = defSHR_PreSeq;
00189     wph->SHR_SFD = defSHR_SFD;
00190     wph->PHR_FrmLen = psduLength;
00191     //also set channel (for filtering in simulation)
00192     wph->phyCurrentChannel = ppib.phyCurrentChannel;
00193     ch->size() = psduLength + defPHY_HEADER_LEN;
00194     ch->txtime() = trxTime(psdu,true);  
00195 }

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, HbAfterRtoSctpAgent, MfrHbAfterRtoSctpAgent, MfrTimestampSctpAgent, MultipleFastRtxSctpAgent, NewRenoSctpAgent, TimestampSctpAgent, SctpAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, VegasTcpAgent, XcpAgent, and XcpSink.

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, HbAfterRtoSctpAgent, MfrHbAfterRtoSctpAgent, MfrTimestampSctpAgent, MultipleFastRtxSctpAgent, NewRenoSctpAgent, TimestampSctpAgent, SctpAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, VegasTcpAgent, XcpAgent, and XcpSink.

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(), SMAC::drop_CTS(), SMAC::drop_DATA(), SMAC::drop_RTS(), SMAC::drop_SYNC(), UnslottedAlohaMac::end_of_contention(), Mac802_15_4::recv(), MacTdma::recvHandler(), MacSimple::recvHandler(), recvOverHandler(), 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 WirelessPhy::dump void   )  const [virtual, inherited]
 

Reimplemented from Phy.

Definition at line 525 of file wireless-phy.cc.

References WirelessPhy::ant_, Phy::dump(), Antenna::getRxGain(), Antenna::getTxGain(), WirelessPhy::L_, WirelessPhy::lambda_, and WirelessPhy::Pt_.

00526 {
00527     Phy::dump();
00528     fprintf(stdout,
00529         "\tPt: %f, Gt: %f, Gr: %f, lambda: %f, L: %f\n",
00530         Pt_, ant_->getTxGain(0,0,0,lambda_), ant_->getRxGain(0,0,0,lambda_), lambda_, L_);
00531     //fprintf(stdout, "\tbandwidth: %f\n", bandwidth_);
00532     fprintf(stdout, "--------------------------------------------------\n");
00533 }

Here is the call graph for this function:

void Phy802_15_4::EDHandler void   )  [protected]
 

Definition at line 650 of file p802_15_4phy.cc.

References mac, p_SUCCESS, Mac802_15_4::PLME_ED_confirm(), rxEDPeakPower, and WirelessPhy::RXThresh_.

Referenced by Phy802_15_4Timer::handle().

00651 {
00652     int energy;
00653     UINT_8 t_EnergyLevel;
00654 
00655     //refer to sec 6.7.7 for ED implementation details
00656     //ED is somewhat simulation/implementation specific; here's our way:
00657 
00658     /* Linux floating number compatibility
00659     energy = (int)((rxEDPeakPower/RXThresh_)*128);
00660     */
00661     {
00662     double tmpf;
00663     tmpf = rxEDPeakPower/RXThresh_;
00664     energy = (int)(tmpf * 128);
00665     }
00666     t_EnergyLevel = (energy > 255)?255:energy;
00667     mac->PLME_ED_confirm(p_SUCCESS,t_EnergyLevel);
00668 }

Here is the call graph for this function:

double WirelessPhy::getAntennaZ  )  [inline, inherited]
 

Definition at line 88 of file wireless-phy.h.

References WirelessPhy::ant_, and Antenna::getZ().

00088 { return ant_->getZ(); }

Here is the call graph for this function:

double WirelessPhy::getCSThresh  )  [inline, inherited]
 

Definition at line 91 of file wireless-phy.h.

References WirelessPhy::CSThresh_.

00091 { return CSThresh_; }

double WirelessPhy::getDist double  Pr,
double  Pt,
double  Gt,
double  Gr,
double  hr,
double  ht,
double  L,
double  lambda
[inherited]
 

Definition at line 557 of file wireless-phy.cc.

References Propagation::getDist(), and WirelessPhy::propagation_.

00559 {
00560     if (propagation_) {
00561         return propagation_->getDist(Pr, Pt, Gt, Gr, hr, ht, L,
00562                          lambda);
00563     }
00564     return 0;
00565 }

Here is the call graph for this function:

double WirelessPhy::getFreq  )  [inline, inherited]
 

Definition at line 92 of file wireless-phy.h.

References WirelessPhy::freq_.

00092 { return freq_; }

double WirelessPhy::getL  )  const [inline, inherited]
 

Definition at line 72 of file wireless-phy.h.

References WirelessPhy::L_.

Referenced by TwoRayGround::Pr(), Shadowing::Pr(), and FreeSpace::Pr().

00072 {return L_;}

double WirelessPhy::getLambda  )  const [inline, inherited]
 

Definition at line 73 of file wireless-phy.h.

References WirelessPhy::lambda_.

Referenced by TwoRayGround::Pr(), Shadowing::Pr(), and FreeSpace::Pr().

00073 {return lambda_;}

double WirelessPhy::getPt  )  [inline, inherited]
 

Definition at line 89 of file wireless-phy.h.

References WirelessPhy::Pt_.

00089 { return Pt_; }

double WirelessPhy::getPtconsume  )  [inline, inherited]
 

Definition at line 75 of file wireless-phy.h.

References WirelessPhy::Pt_consume_.

00075 { return Pt_consume_; }

double Phy802_15_4::getRate char  dataOrSymbol  ) 
 

Definition at line 143 of file p802_15_4phy.cc.

References BR_2_4G, BR_868M, BR_915M, PHY_PIB::phyCurrentChannel, ppib, SR_2_4G, SR_868M, and SR_915M.

Referenced by macExtractTimer::backoffCAP(), Mac802_15_4::beaconTxHandler(), Mac802_15_4::canProceedWOcsmaca(), Mac802_15_4::getCAP(), Mac802_15_4::getCAPbyType(), Mac802_15_4::locateBoundary(), Mac802_15_4::mcps_data_request(), Mac802_15_4::mlme_associate_request(), Mac802_15_4::mlme_poll_request(), Mac802_15_4::mlme_rx_enable_request(), Mac802_15_4::mlme_scan_request(), Mac802_15_4::mlme_sync_request(), CsmaCA802_15_4::newBeacon(), PLME_CCA_request(), PLME_ED_request(), PLME_SET_TRX_STATE_request(), Mac802_15_4::recvBeacon(), Mac802_15_4::recvData(), recvOverHandler(), sendOverHandler(), macBeaconRxTimer::start(), macBeaconTxTimer::start(), CsmaCA802_15_4::start(), SSCS802_15_4::startPANCoord(), Mac802_15_4::taskSuccess(), and trxTime().

00144 {
00145     double rate;
00146     
00147     if (ppib.phyCurrentChannel == 0)
00148     {
00149         if (dataOrSymbol == 'd')
00150             rate = BR_868M;
00151         else
00152             rate = SR_868M;
00153     }
00154     else if (ppib.phyCurrentChannel <= 10)
00155     {
00156         if (dataOrSymbol == 'd')
00157             rate = BR_915M;
00158         else
00159             rate = SR_915M;
00160     }
00161     else
00162     {
00163         if (dataOrSymbol == 'd')
00164             rate = BR_2_4G;
00165         else
00166             rate = SR_2_4G;
00167     }
00168     return (rate*1000);
00169 }

double WirelessPhy::getRXThresh  )  [inline, inherited]
 

Definition at line 90 of file wireless-phy.h.

References WirelessPhy::RXThresh_.

00090 { return RXThresh_; }

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, inherited]
 

Definition at line 108 of file phy.h.

References Phy::head_.

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

00108 { return head_; }

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

Definition at line 89 of file phy.h.

References LIST_INSERT_HEAD.

Referenced by SatChannel::add_interface().

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

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

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     }

bool& WirelessPhy::Is_node_on  )  [inline, inherited]
 

Definition at line 97 of file wireless-phy.h.

References WirelessPhy::node_on_.

Referenced by WirelessPhy::sendDown(), WirelessPhy::sendUp(), WirelessPhy::UpdateIdleEnergy(), and WirelessPhy::UpdateSleepEnergy().

00097 { return node_on_; }

bool WirelessPhy::Is_sleeping  )  [inline, inherited]
 

Definition at line 98 of file wireless-phy.h.

References WirelessPhy::SLEEP, and WirelessPhy::status_.

Referenced by WirelessPhy::sendDown(), WirelessPhy::sendUp(), and WirelessPhy::UpdateSleepEnergy().

00098 { if (status_==SLEEP) return(1); else return(0); }

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, inherited]
 

Phy::LIST_ENTRY Phy   )  [protected, inherited]
 

void Phy802_15_4::macObj Mac802_15_4 m  ) 
 

Definition at line 133 of file p802_15_4phy.cc.

References mac.

Referenced by Mac802_15_4::command().

00134 {
00135     mac = m;
00136 }

UINT_8 Phy802_15_4::measureLinkQ Packet p  ) 
 

Definition at line 468 of file p802_15_4phy.cc.

References HDR_LRWPAN, PacketStamp::RxPr, WirelessPhy::RXThresh_, and Packet::txinfo_.

Referenced by recvOverHandler().

00469 {
00470     //Link quality measurement is somewhat simulation/implementation specific;
00471     //here's our way:
00472     int lq,lq2;
00473 
00474     //consider energy
00475     /* Linux floating number compatibility
00476     lq = (int)((p->txinfo_.RxPr/RXThresh_)*128);
00477     */
00478     {
00479     double tmpf;
00480     tmpf = p->txinfo_.RxPr/RXThresh_;
00481     lq = (int)(tmpf * 128);
00482     }
00483     if (lq > 255) lq = 255;
00484 
00485     //consider signal-to-noise
00486     /* Linux floating number compatibility
00487     lq2 = (int)((p->txinfo_.RxPr/HDR_LRWPAN(p)->rxTotPower)*255);
00488     */
00489     {
00490     double tmpf;
00491     tmpf = p->txinfo_.RxPr/HDR_LRWPAN(p)->rxTotPower;
00492     lq2 = (int)(tmpf * 255);
00493     }
00494     
00495     if (lq > lq2) lq = lq2;     //use worst value
00496         
00497     return (UINT_8) lq;
00498 }

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

Definition at line 88 of file phy.h.

Referenced by WirelessChannel::calcHighestAntennaZ(), SatRouteObject::compute_topology(), Channel::dump(), LinkHandoffMgr::get_peer(), LinkHandoffMgr::get_peer_linkhead(), and Channel::sendUp().

00088 { return chnl_link_.le_next; }

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

Definition at line 94 of file phy.h.

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

00094 { return node_link_.le_next; }

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

Reimplemented from Phy.

Definition at line 74 of file wireless-phy.h.

References Phy::node_.

Referenced by WirelessPhy::em(), recv(), WirelessPhy::sendDown(), and WirelessPhy::sendUp().

00074 { return node_; }

void WirelessPhy::node_off  )  [inherited]
 

Definition at line 451 of file wireless-phy.cc.

References EnergyModel::DecrIdleEnergy(), WirelessPhy::em(), FALSE, WirelessPhy::node_on_, NOW, WirelessPhy::P_idle_, WirelessPhy::SLEEP, WirelessPhy::status_, and WirelessPhy::update_energy_time_.

Referenced by WirelessPhy::command().

00452 {
00453 
00454         node_on_= FALSE;
00455     status_ = SLEEP;
00456 
00457     if (em() == NULL)
00458             return;
00459         if (NOW > update_energy_time_) {
00460             em()->DecrIdleEnergy(NOW-update_energy_time_,
00461                                 P_idle_);
00462             update_energy_time_ = NOW;
00463     }
00464 }

Here is the call graph for this function:

void WirelessPhy::node_on  )  [inherited]
 

Definition at line 437 of file wireless-phy.cc.

References WirelessPhy::em(), WirelessPhy::IDLE, WirelessPhy::node_on_, NOW, WirelessPhy::status_, TRUE, and WirelessPhy::update_energy_time_.

Referenced by WirelessPhy::command().

00438 {
00439 
00440         node_on_= TRUE;
00441     status_ = IDLE;
00442 
00443        if (em() == NULL)
00444         return; 
00445     if (NOW > update_energy_time_) {
00446             update_energy_time_ = NOW;
00447     }
00448 }

Here is the call graph for this function:

void WirelessPhy::node_sleep  )  [inherited]
 

Definition at line 495 of file wireless-phy.cc.

References EnergyModel::DecrIdleEnergy(), EnergyModel::DecrTransitionEnergy(), WirelessPhy::em(), WirelessPhy::IDLE, Phy::node_, NOW, WirelessPhy::P_idle_, WirelessPhy::P_transition_, WirelessPhy::SLEEP, WirelessPhy::status_, WirelessPhy::T_transition_, and WirelessPhy::update_energy_time_.

Referenced by WirelessPhy::UpdateSleepEnergy().

00496 {
00497 //
00498 //        node_on_= FALSE;
00499 //
00500     if (status_== SLEEP)
00501         return;
00502 
00503     if (em() == NULL)
00504             return;
00505 
00506         if ( NOW > update_energy_time_ && (status_== IDLE) ) {
00507     //the power consumption when radio goes from IDLE mode to SLEEP mode
00508         em()->DecrTransitionEnergy(T_transition_,P_transition_);
00509 
00510             em()->DecrIdleEnergy(NOW-update_energy_time_,
00511                                 P_idle_);
00512         status_ = SLEEP;
00513             update_energy_time_ = NOW;
00514 
00515     // log node energy
00516         if (em()->energy() > 0) {
00517             ((MobileNode *)node_)->log_energy(1);
00518             } else {
00519             ((MobileNode *)node_)->log_energy(0);   
00520             }
00521     }
00522 }

Here is the call graph for this function:

void WirelessPhy::node_wakeup  )  [inherited]
 

Definition at line 467 of file wireless-phy.cc.

References EnergyModel::DecrSleepEnergy(), EnergyModel::DecrTransitionEnergy(), WirelessPhy::em(), WirelessPhy::IDLE, Phy::node_, NOW, WirelessPhy::P_sleep_, WirelessPhy::P_transition_, WirelessPhy::SLEEP, WirelessPhy::status_, WirelessPhy::T_transition_, and WirelessPhy::update_energy_time_.

Referenced by WirelessPhy::UpdateSleepEnergy().

00468 {
00469 
00470     if (status_== IDLE)
00471         return;
00472 
00473     if (em() == NULL)
00474             return;
00475 
00476         if ( NOW > update_energy_time_ && (status_== SLEEP) ) {
00477         //the power consumption when radio goes from SLEEP mode to IDLE mode
00478         em()->DecrTransitionEnergy(T_transition_,P_transition_);
00479         
00480         em()->DecrSleepEnergy(NOW-update_energy_time_,
00481                       P_sleep_);
00482         status_ = IDLE;
00483             update_energy_time_ = NOW;
00484         
00485         // log node energy
00486         if (em()->energy() > 0) {
00487             ((MobileNode *)node_)->log_energy(1);
00488             } else {
00489             ((MobileNode *)node_)->log_energy(0);   
00490             }
00491     }
00492 }

Here is the call graph for this function:

void Phy802_15_4::PD_DATA_indication UINT_8  psduLength,
Packet psdu,
UINT_8  ppduLinkQuality
 

Definition at line 242 of file p802_15_4phy.cc.

References Packet::free(), HDR_LRWPAN, hdr_lrwpan::ppduLinkQuality, NsObject::recv(), WirelessPhy::sendUp(), and BiConnector::uptarget_.

Referenced by recvOverHandler().

00243 {
00244     //refer to sec 6.7.8 for LQI details
00245     hdr_lrwpan* wph = HDR_LRWPAN(psdu);
00246 
00247     wph->ppduLinkQuality = ppduLinkQuality;
00248 
00249     if (sendUp(psdu) == 0)
00250         Packet::free(psdu);
00251     else
00252         uptarget_->recv(psdu, (Handler*) 0);
00253 }

Here is the call graph for this function:

void Phy802_15_4::PD_DATA_request UINT_8  psduLength,
Packet psdu
 

Definition at line 197 of file p802_15_4phy.cc.

References aMaxPHYPacketSize, construct_PPDU(), Packet::copy(), CURRENT_TIME, Packet::free(), HDR_CMN, HDR_LRWPAN, Phy::index_, mac, p802_15_4macDA(), p802_15_4macSA(), p_BUSY, p_IDLE, p_TX_ON, p_UNDEFINED, Mac802_15_4::PD_DATA_confirm(), WirelessPhy::sendDown(), sendOverH, hdr_cmn::size(), Phy802_15_4Timer::start(), trx_state, trxTime(), tx_state, txPkt, txPktCopy, hdr_cmn::uid(), and wpan_pName().

Referenced by recv().

00198 {
00199     hdr_cmn* ch = HDR_CMN(psdu);
00200 
00201     //check packet length
00202     if (psduLength > aMaxPHYPacketSize)
00203     {
00204         fprintf(stdout,"[%s::%s][%f](node %d) Invalid PSDU/MPDU length: type = %s, src = %d, dst = %d, uid = %d, mac_uid = %u, size = %d\n",__FILE__,__FUNCTION__,CURRENT_TIME,index_,wpan_pName(psdu),p802_15_4macSA(psdu),p802_15_4macDA(psdu),ch->uid(),HDR_LRWPAN(psdu)->uid,ch->size());
00205         Packet::free(psdu);
00206         mac->PD_DATA_confirm(p_UNDEFINED);
00207         return;
00208     }
00209     
00210     if (trx_state == p_TX_ON)
00211     {
00212         if (tx_state == p_IDLE)
00213         {
00214 #ifdef DEBUG802_15_4
00215             fprintf(stdout,"[%s::%s][%f](node %d) sending pkt: type = %s, src = %d, dst = %d, uid = %d, mac_uid = %ld, size = %d\n",__FILE__,__FUNCTION__,CURRENT_TIME,index_,wpan_pName(psdu),p802_15_4macSA(psdu),p802_15_4macDA(psdu),ch->uid(),HDR_LRWPAN(psdu)->uid,ch->size());
00216 #endif
00217             //construct a PPDU packet (not really a new packet in simulation, but still <psdu>)
00218             construct_PPDU(psduLength,psdu);
00219             //somehow the packet size is set to 0 after sendDown() -- ok, the packet is out and anything can happen (we shouldn't care once it's out)
00220             //so we have to calculate the transmission time before sendDown()
00221             double trx_time = trxTime(psdu,true);
00222             //send the packet to Radio (channel target) for transmission
00223             txPkt = psdu;
00224             txPktCopy = psdu->copy();   //for debug purpose, we still want to access the packet after transmission is done
00225             sendDown(psdu);         //WirelessPhy::sendDown()
00226             tx_state = p_BUSY;      //for carrier sense
00227             sendOverH.start(trx_time);
00228         }
00229         else    //impossible
00230             assert(0);
00231     }
00232     else
00233     {
00234 #ifdef DEBUG802_15_4
00235         fprintf(stdout,"[D][TRX][%s::%s][%f](node %d) dropping pkt: type = %s, src = %d, dst = %d, uid = %d, mac_uid = %ld, size = %d\n",__FILE__,__FUNCTION__,CURRENT_TIME,index_,wpan_pName(psdu),p802_15_4macSA(psdu),p802_15_4macDA(psdu),ch->uid(),HDR_LRWPAN(psdu)->uid,ch->size());
00236 #endif
00237         Packet::free(psdu);
00238         mac->PD_DATA_confirm(trx_state);
00239     }
00240 }

Here is the call graph for this function:

void Phy802_15_4::PLME_CCA_request  ) 
 

Definition at line 255 of file p802_15_4phy.cc.

References CCAH, getRate(), mac, p_RX_ON, Mac802_15_4::PLME_CCA_confirm(), Phy802_15_4Timer::start(), and trx_state.

Referenced by CsmaCA802_15_4::deferCCAHandler(), and CsmaCA802_15_4::RX_ON_confirm().

00256 {
00257     if (trx_state == p_RX_ON)
00258     {
00259         //perform CCA
00260         //refer to sec 6.7.9 for CCA details
00261         //we need to delay 8 symbols
00262         CCAH.start(8/getRate('s'));
00263 
00264     }
00265     else
00266         mac->PLME_CCA_confirm(trx_state);
00267 }

Here is the call graph for this function:

void Phy802_15_4::PLME_ED_request  ) 
 

Definition at line 269 of file p802_15_4phy.cc.

References EDH, getRate(), mac, p_RX_ON, PHY_PIB::phyCurrentChannel, Mac802_15_4::PLME_ED_confirm(), ppib, rxEDPeakPower, rxTotPower, Phy802_15_4Timer::start(), and trx_state.

Referenced by Mac802_15_4::mlme_scan_request().

00270 {
00271     if (trx_state == p_RX_ON)
00272     {
00273         //perform ED
00274         //refer to sec 6.7.7 for ED implementation details
00275         //we need to delay 8 symbols
00276         rxEDPeakPower = rxTotPower[ppib.phyCurrentChannel];
00277         EDH.start(8/getRate('s'));
00278     }
00279     else
00280         mac->PLME_ED_confirm(trx_state,0);
00281 }

Here is the call graph for this function:

void Phy802_15_4::PLME_GET_request PPIBAenum  PIBAttribute  ) 
 

Definition at line 283 of file p802_15_4phy.cc.

References mac, p_SUCCESS, p_UNSUPPORT_ATTRIBUTE, phyCCAMode, phyChannelsSupported, phyCurrentChannel, phyTransmitPower, Mac802_15_4::PLME_GET_confirm(), and ppib.

Referenced by SSCS802_15_4::command(), Mac802_15_4::getBattLifeExtSlotNum(), Mac802_15_4::mlme_orphan_response(), SSCS802_15_4::MLME_SCAN_confirm(), Mac802_15_4::mlme_scan_request(), and Mac802_15_4::MLME_SET_request().

00284 {
00285     PHYenum t_status;
00286     
00287     switch(PIBAttribute)
00288     {
00289         case phyCurrentChannel:
00290         case phyChannelsSupported:
00291         case phyTransmitPower:
00292         case phyCCAMode:
00293             t_status = p_SUCCESS;
00294             break;
00295         default:
00296             t_status = p_UNSUPPORT_ATTRIBUTE;
00297             break;
00298     }
00299     mac->PLME_GET_confirm(t_status,PIBAttribute,&ppib);
00300 }

Here is the call graph for this function:

void Phy802_15_4::PLME_SET_request PPIBAenum  PIBAttribute,
PHY_PIB PIBAttributeValue
 

Definition at line 402 of file p802_15_4phy.cc.

References Phy802_15_4Timer::cancel(), channelSupported(), CURRENT_TIME, Packet::free(), HDR_CMN, HDR_LRWPAN, Phy::index_, mac, p802_15_4macDA(), p802_15_4macSA(), p_BUSY, p_IDLE, p_INVALID_PARAMETER, p_SUCCESS, p_TRX_OFF, p_UNSUPPORT_ATTRIBUTE, Mac802_15_4::PD_DATA_confirm(), PHY_PIB::phyCCAMode, phyCCAMode, PHY_PIB::phyChannelsSupported, phyChannelsSupported, PHY_PIB::phyCurrentChannel, phyCurrentChannel, PHY_PIB::phyTransmitPower, phyTransmitPower, Mac802_15_4::PLME_SET_confirm(), ppib, rxPkt, sendOverH, hdr_cmn::size(), trx_state_defer_set, tx_state, txPkt, txPktCopy, hdr_lrwpan::uid, hdr_cmn::uid(), and wpan_pName().

Referenced by Mac802_15_4::mlme_associate_request(), Mac802_15_4::mlme_scan_request(), Mac802_15_4::mlme_start_request(), Mac802_15_4::mlme_sync_request(), Mac802_15_4::recvCommand(), and SSCS802_15_4::startPANCoord().

00403 {
00404     PHYenum t_status;
00405     
00406     t_status = p_SUCCESS;
00407     switch(PIBAttribute)
00408     {
00409         case phyCurrentChannel:
00410             if (!channelSupported(PIBAttributeValue->phyCurrentChannel))
00411                 t_status = p_INVALID_PARAMETER;
00412             if (ppib.phyCurrentChannel != PIBAttributeValue->phyCurrentChannel)
00413             {
00414                 //any packet in transmission or reception will be corrupted
00415                 if (rxPkt)
00416                 {
00417 #ifdef DEBUG802_15_4
00418                     hdr_cmn *ch = HDR_CMN(rxPkt);
00419                     hdr_lrwpan *wph = HDR_LRWPAN(rxPkt);
00420                     fprintf(stdout,"[%s::%s][%f](node %d) SET phy channel sets error bit for incoming pkt: type = %s, src = %d, dst = %d, uid = %d, mac_uid = %ld, size = %d\n",__FILE__,__FUNCTION__,CURRENT_TIME,index_,wpan_pName(rxPkt),p802_15_4macSA(rxPkt),p802_15_4macDA(rxPkt),ch->uid(),wph->uid,ch->size());
00421 #endif
00422                     HDR_CMN(rxPkt)->error() = 1;
00423                 }
00424                 if (tx_state == p_BUSY)
00425                 {
00426 #ifdef DEBUG802_15_4
00427                     hdr_cmn *ch = HDR_CMN(txPkt);
00428                     hdr_lrwpan *wph = HDR_LRWPAN(txPkt);
00429                     fprintf(stdout,"[%s::%s][%f](node %d) SET phy channel sets error bit for outgoing pkt: type = %s, src = %d, dst = %d, uid = %d, mac_uid = %ld, size = %d\n",__FILE__,__FUNCTION__,CURRENT_TIME,index_,wpan_pName(txPkt),p802_15_4macSA(txPkt),p802_15_4macDA(txPkt),ch->uid(),wph->uid,ch->size());
00430 #endif
00431                     HDR_CMN(txPkt)->error() = 1;
00432                     sendOverH.cancel();
00433                     Packet::free(txPktCopy);
00434                     tx_state = p_IDLE;
00435                     mac->PD_DATA_confirm(p_TRX_OFF);
00436                     if (trx_state_defer_set != p_IDLE)
00437                         trx_state_defer_set = p_IDLE;
00438                 }
00439                 ppib.phyCurrentChannel = PIBAttributeValue->phyCurrentChannel;
00440             }
00441             break;
00442         case phyChannelsSupported:
00443             if ((PIBAttributeValue->phyChannelsSupported&0xf8000000) != 0)  //5 MSBs reserved
00444                 t_status = p_INVALID_PARAMETER;
00445             else
00446                 ppib.phyChannelsSupported = PIBAttributeValue->phyChannelsSupported;
00447             break;
00448         case phyTransmitPower:
00449             if (PIBAttributeValue->phyTransmitPower > 0xbf)
00450                 t_status = p_INVALID_PARAMETER;
00451             else
00452                 ppib.phyTransmitPower = PIBAttributeValue->phyTransmitPower;
00453             break;
00454         case phyCCAMode:
00455             if ((PIBAttributeValue->phyCCAMode < 1)
00456              || (PIBAttributeValue->phyCCAMode > 3))
00457                 t_status = p_INVALID_PARAMETER;
00458             else
00459                 ppib.phyCCAMode = PIBAttributeValue->phyCCAMode;
00460             break;
00461         default:
00462             t_status = p_UNSUPPORT_ATTRIBUTE;
00463             break;
00464     }
00465     mac->PLME_SET_confirm(t_status,PIBAttribute);
00466 }

Here is the call graph for this function:

void Phy802_15_4::PLME_SET_TRX_STATE_request PHYenum  state  ) 
 

Definition at line 302 of file p802_15_4phy.cc.

References Phy802_15_4Timer::active, aTurnaroundTime, Phy802_15_4Timer::cancel(), CURRENT_TIME, Packet::free(), getRate(), HDR_CMN, HDR_LRWPAN, Phy::index_, mac, p802_15_4macDA(), p802_15_4macSA(), p_BUSY, p_BUSY_RX, p_BUSY_TX, p_FORCE_TRX_OFF, p_IDLE, p_RX_ON, p_SUCCESS, p_TRX_OFF, p_TX_ON, Mac802_15_4::PD_DATA_confirm(), Mac802_15_4::PLME_SET_TRX_STATE_confirm(), rxPkt, sendOverH, hdr_cmn::size(), Phy802_15_4Timer::start(), trx_state, trx_state_defer_set, trx_state_turnaround, TRXH, tx_state, txPkt, txPktCopy, hdr_lrwpan::uid, hdr_cmn::uid(), and wpan_pName().

Referenced by Mac802_15_4::MLME_SET_request(), and Mac802_15_4::set_trx_state_request().

00303 {
00304     bool delay;
00305     PHYenum t_status;
00306     
00307     //ignore any pending request
00308     if (trx_state_defer_set != p_IDLE)
00309         trx_state_defer_set = p_IDLE;
00310     else if (TRXH.active)
00311     {
00312         TRXH.cancel();
00313     }
00314 
00315     t_status = trx_state;
00316     if (state != trx_state)
00317     {
00318         delay = false;
00319         if (((state == p_RX_ON)||(state == p_TRX_OFF))&&(tx_state == p_BUSY))
00320         {
00321             t_status = p_BUSY_TX;
00322             trx_state_defer_set = state;
00323         }
00324         else if (((state == p_TX_ON)||(state == p_TRX_OFF))
00325                 &&(rxPkt)&&(!HDR_CMN(rxPkt)->error()))          //if after received a valid SFD
00326         {
00327             t_status = p_BUSY_RX;
00328             trx_state_defer_set = state;
00329         }
00330         else if (state == p_FORCE_TRX_OFF)
00331         {
00332             t_status = (trx_state == p_TRX_OFF)?p_TRX_OFF:p_SUCCESS;
00333             trx_state = p_TRX_OFF;
00334             //terminate reception if needed
00335             if (rxPkt)
00336             {
00337 #ifdef DEBUG802_15_4
00338                 hdr_cmn *ch = HDR_CMN(rxPkt);
00339                 hdr_lrwpan *wph = HDR_LRWPAN(rxPkt);
00340                 fprintf(stdout,"[%s::%s][%f](node %d) FORCE_TRX_OFF sets error bit for incoming pkt: type = %s, src = %d, dst = %d, uid = %d, mac_uid = %ld, size = %d\n",__FILE__,__FUNCTION__,CURRENT_TIME,index_,wpan_pName(rxPkt),p802_15_4macSA(rxPkt),p802_15_4macDA(rxPkt),ch->uid(),wph->uid,ch->size());
00341 #endif
00342                 HDR_CMN(rxPkt)->error() = 1;    //incomplete reception -- force packet discard
00343             }
00344             //terminate transmission if needed
00345             if (tx_state == p_BUSY)
00346             {
00347 #ifdef DEBUG802_15_4
00348                 hdr_cmn *ch = HDR_CMN(txPkt);
00349                 hdr_lrwpan *wph = HDR_LRWPAN(txPkt);
00350                 fprintf(stdout,"[%s::%s][%f](node %d) FORCE_TRX_OFF sets error bit for outgoing pkt: type = %s, src = %d, dst = %d, uid = %d, mac_uid = %ld, size = %d\n",__FILE__,__FUNCTION__,CURRENT_TIME,index_,wpan_pName(txPkt),p802_15_4macSA(txPkt),p802_15_4macDA(txPkt),ch->uid(),wph->uid,ch->size());
00351 #endif
00352                 HDR_CMN(txPkt)->error() = 1;
00353                 sendOverH.cancel();
00354                 Packet::free(txPktCopy);
00355                 tx_state = p_IDLE;
00356                 mac->PD_DATA_confirm(p_TRX_OFF);
00357                 if (trx_state_defer_set != p_IDLE)
00358                     trx_state_defer_set = p_IDLE;
00359             }
00360         }
00361         else
00362         {
00363             t_status = p_SUCCESS;
00364             if (((state == p_RX_ON)&&(trx_state == p_TX_ON))
00365               ||((state == p_TX_ON)&&(trx_state == p_RX_ON)))
00366             {
00367                 trx_state_turnaround = state;
00368                 delay = true;
00369             }
00370             else
00371                 trx_state = state;
00372         }
00373         //we need to delay <aTurnaroundTime> symbols if Tx2Rx or Rx2Tx
00374         if (delay)
00375         {
00376             trx_state = p_TRX_OFF;  //should be disabled immediately (further transmission/reception will not succeed)
00377             TRXH.start(aTurnaroundTime/getRate('s'));
00378         }
00379         else
00380             mac->PLME_SET_TRX_STATE_confirm(t_status);
00381     }
00382     else
00383         mac->PLME_SET_TRX_STATE_confirm(t_status);
00384 #ifdef DEBUG802_15_4
00385         fprintf(stdout,"[%s::%s][%f](node %d) SET TRX: old = %s req = %s ret = %s\n",__FILE__,__FUNCTION__,CURRENT_TIME,index_,
00386             (trx_state == p_RX_ON)?"RX_ON":
00387             (trx_state == p_TX_ON)?"TX_ON":
00388             (trx_state == p_TRX_OFF)?"TRX_OFF":"???",
00389             (state == p_RX_ON)?"RX_ON":
00390             (state == p_TX_ON)?"TX_ON":
00391             (state == p_TRX_OFF)?"TRX_OFF":
00392             (state == p_FORCE_TRX_OFF)?"FORCE_TRX_OFF":"???",
00393             (t_status == p_RX_ON)?"RX_ON":
00394             (t_status == p_TX_ON)?"TX_ON":
00395             (t_status == p_TRX_OFF)?"TRX_OFF":
00396             (t_status == p_BUSY_TX)?"BUSY_TX":
00397             (t_status == p_BUSY_RX)?"BUSY_RX":
00398             (t_status == p_SUCCESS)?"SUCCESS":"???");
00399 #endif
00400 }

Here is the call graph for this function:

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 Phy802_15_4::recv Packet p,
Handler h
[virtual]
 

Reimplemented from Phy.

Definition at line 500 of file p802_15_4phy.cc.

References Phy802_15_4Timer::active, EnergyModel::add_neighbor(), hdr_lrwpan::colFlag, CURRENT_TIME, defFrmCtrl_Type_Data, defSHR_SFD, hdr_cmn::direction(), hdr_cmn::DOWN, EDH, Node::energy_model(), fl_oper_est, Nam802_15_4::flashNodeColor(), Packet::free(), FrameCtrl::FrmCtrl, FrameCtrl::frmType, HDR_CMN, HDR_LRWPAN, Phy::index_, mac, MAC_BROADCAST, hdr_lrwpan::MHR_FrmCtrl, Mac802_15_4::nam, WirelessPhy::node(), p802_15_4macDA(), p802_15_4macSA(), p_RX_ON, FrameCtrl::parse(), PD_DATA_request(), phyCurrentChannel, PHY_PIB::phyCurrentChannel, hdr_lrwpan::phyCurrentChannel, ppib, rxEDPeakPower, rxPkt, PacketStamp::RxPr, rxThisTotNum, rxTotNum, rxTotPower, WirelessPhy::sendUp(), hdr_lrwpan::SHR_SFD, hdr_cmn::size(), Tap::tap(), Mac802_15_4::tap(), trx_state, Packet::txinfo_, hdr_lrwpan::uid, hdr_cmn::uid(), hdr_cmn::UP, updateLFailLink(), updateNFailLink(), and wpan_pName().

00501 {
00502     hdr_lrwpan* wph = HDR_LRWPAN(p);
00503     hdr_cmn *ch = HDR_CMN(p);
00504         FrameCtrl frmCtrl;
00505 
00506     switch(ch->direction())
00507     {
00508     case hdr_cmn::DOWN:
00509 #ifdef DEBUG802_15_4
00510         fprintf(stdout,"[%s::%s][%f](node %d) outgoing pkt: type = %s, src = %d, dst = %d, uid = %d, mac_uid = %ld, size = %d\n",__FILE__,__FUNCTION__,CURRENT_TIME,index_,wpan_pName(p),p802_15_4macSA(p),p802_15_4macDA(p),ch->uid(),wph->uid,ch->size());
00511 #endif
00512         PD_DATA_request((UINT_8) ch->size(),p);
00513         break;
00514     case hdr_cmn::UP:
00515     default:
00516         if (sendUp(p) == 0) 
00517         {
00518             Packet::free(p);
00519             return;
00520         }
00521 
00522         if (updateNFailLink(fl_oper_est,index_) == 0)
00523         {
00524             Packet::free(p);
00525             return;
00526         }
00527 
00528                 if (updateLFailLink(fl_oper_est,p802_15_4macSA(p),index_) == 0) //broadcast packets can still reach here
00529                 {
00530                         Packet::free(p);
00531                         return;
00532                 }
00533 
00534                 frmCtrl.FrmCtrl = wph->MHR_FrmCtrl;
00535                 frmCtrl.parse();
00536         //tap out
00537         if (mac->tap() && frmCtrl.frmType == defFrmCtrl_Type_Data)
00538             mac->tap()->tap(p);
00539 
00540         if (node()->energy_model() && node()->energy_model()->adaptivefidelity())
00541             node()->energy_model()->add_neighbor(p802_15_4macSA(p));
00542 
00543         //Under whatever condition, we should mark the media as busy.
00544         // --no matter the packet(s) is for this node or not, no matter
00545         //   what state the transceiver is in, RX_ON,TX_ON or TRX_OFF, and
00546         //   no matter which channel is being used.
00547         //Note that current WirelessPhy->sendUp() prevents packets with (Pr < CSThresh_)
00548         //from reaching here --. need to modify.WirelessPhy->sendUp() if we want to see
00549         //all the packets here (but seems no reason to do that).
00550         //  in dB as can be seen from following:
00551         //  not very clear (now CPThresh_ is just a ratio, not in dB?)
00552         rxTotPower[wph->phyCurrentChannel] += p->txinfo_.RxPr;
00553         rxTotNum[wph->phyCurrentChannel]++;
00554         if (EDH.active)
00555         if(rxEDPeakPower < rxTotPower[ppib.phyCurrentChannel])
00556             rxEDPeakPower = rxTotPower[ppib.phyCurrentChannel];
00557         
00558         if ((p802_15_4macDA(p) == index_)           //packet for this node
00559           ||(p802_15_4macDA(p) == ((int)MAC_BROADCAST)))        //broadcast packet
00560             rxThisTotNum[wph->phyCurrentChannel]++;
00561 
00562         if (trx_state == p_RX_ON)
00563         if (wph->phyCurrentChannel == ppib.phyCurrentChannel)   //current channel
00564         if ((p802_15_4macDA(p) == index_)           //packet for this node
00565           ||(p802_15_4macDA(p) == ((int)MAC_BROADCAST)))        //broadcast packet
00566         if (wph->SHR_SFD == defSHR_SFD)             //valid SFD
00567         {
00568 #ifdef DEBUG802_15_4
00569             fprintf(stdout,"[%s::%s][%f](node %d) incoming pkt: type = %s, src = %d, dst = %d, uid = %d, mac_uid = %ld, size = %d\n",__FILE__,__FUNCTION__,CURRENT_TIME,index_,wpan_pName(p),p802_15_4macSA(p),p802_15_4macDA(p),ch->uid(),wph->uid,ch->size());
00570 #endif
00571             wph->colFlag = false;
00572             if (rxPkt == 0)
00573             {
00574                 rxPkt = p;
00575                 HDR_LRWPAN(rxPkt)->rxTotPower = rxTotPower[wph->phyCurrentChannel];
00576             }
00577             else
00578             {
00579 #ifdef DEBUG802_15_4
00580                 fprintf(stdout,"[D][COL][%s::%s][%f](node %d) COLLISION:\n\t First (power:%f): type = %s, src = %d, dst = %d, uid = %d, mac_uid = %ld, size = %d\n\tSecond (power:%f): type = %s, src = %d, dst = %d, uid = %d, mac_uid = %ld, size = %d\n",
00581                     __FILE__,__FUNCTION__,CURRENT_TIME,index_,
00582                     rxPkt->txinfo_.RxPr,wpan_pName(rxPkt),p802_15_4macSA(rxPkt),p802_15_4macDA(rxPkt),HDR_CMN(rxPkt)->uid(),HDR_LRWPAN(rxPkt)->uid,HDR_CMN(rxPkt)->size(),
00583                     p->txinfo_.RxPr,wpan_pName(p),p802_15_4macSA(p),p802_15_4macDA(p),ch->uid(),wph->uid,ch->size());
00584 #endif
00585                 wph->colFlag = true;
00586                 HDR_LRWPAN(rxPkt)->colFlag = true;
00587                 mac->nam->flashNodeColor(CURRENT_TIME);
00588                 if (p->txinfo_.RxPr > rxPkt->txinfo_.RxPr)
00589                 {
00590                     //What should we do if there is a transceiver state set pending?
00591                     //  1. continue defering (could be unbounded delay)
00592                     //..2. set transceiver state now (the incoming packet ignored)
00593                     //We select choice 1, as the traffic rate is supposed to be low.
00594                     rxPkt = p;
00595                     HDR_LRWPAN(rxPkt)->rxTotPower = rxTotPower[wph->phyCurrentChannel];
00596                 }
00597             }
00598 
00599         }
00600         if (rxPkt)
00601         if (HDR_LRWPAN(rxPkt)->rxTotPower < rxTotPower[HDR_LRWPAN(rxPkt)->phyCurrentChannel])
00602             HDR_LRWPAN(rxPkt)->rxTotPower = rxTotPower[HDR_LRWPAN(rxPkt)->phyCurrentChannel];
00603         assert(ch->size() > 0);
00604         if (ch->direction() != hdr_cmn::UP)
00605         {
00606             printf("Packet-flow direction not specified: sending up the stack on default.\n\n");
00607             ch->direction() = hdr_cmn::UP;  //we don't want MAC to handle the same problem
00608         }
00609         Scheduler::instance().schedule(&recvOverH, (Event *)p, trxTime(p,true));
00610         break;
00611     }
00612 }

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 Phy802_15_4::recvOverHandler Packet p  )  [protected]
 

Definition at line 677 of file p802_15_4phy.cc.

References aMaxPHYPacketSize, aTurnaroundTime, CURRENT_TIME, defPHY_HEADER_LEN, BiConnector::drop(), hdr_cmn::error(), Packet::free(), getRate(), HDR_CMN, HDR_LRWPAN, Phy::index_, mac, MAC_BROADCAST, measureLinkQ(), p802_15_4macDA(), p802_15_4macSA(), p_IDLE, p_TRX_OFF, PD_DATA_indication(), PHY_PIB::phyCurrentChannel, hdr_lrwpan::phyCurrentChannel, Mac802_15_4::PLME_SET_TRX_STATE_confirm(), ppib, rxPkt, PacketStamp::RxPr, rxThisTotNum, rxTotNum, rxTotPower, hdr_cmn::size(), Phy802_15_4Timer::start(), trx_state, trx_state_defer_set, trx_state_turnaround, TRXH, Packet::txinfo_, hdr_lrwpan::uid, hdr_cmn::uid(), and wpan_pName().

Referenced by Phy802_15_4Timer::handle().

00678 {
00679     UINT_8 lq;
00680     hdr_lrwpan* wph = HDR_LRWPAN(p);
00681     hdr_cmn *ch = HDR_CMN(p);
00682     
00683     rxTotPower[wph->phyCurrentChannel] -= p->txinfo_.RxPr;
00684     rxTotNum[wph->phyCurrentChannel]--;
00685     
00686     if (rxTotNum[wph->phyCurrentChannel] == 0)
00687         rxTotPower[wph->phyCurrentChannel] = 0.0;
00688 
00689     if ((p802_15_4macDA(p) != index_)
00690       &&(p802_15_4macDA(p) != ((int)MAC_BROADCAST)))    //packet not for this node (interference)
00691         Packet::free(p);
00692     else if (p != rxPkt)                //packet corrupted (not the strongest one) or un-detectable
00693     {
00694 #ifdef DEBUG802_15_4
00695         fprintf(stdout,"[D][%s][%s::%s::%d][%f](node %d) dropping pkt: type = %s, src = %d, dst = %d, uid = %d, mac_uid = %ld, size = %d\n",(wph->phyCurrentChannel != ppib.phyCurrentChannel)?"CHN":"NOT",__FILE__,__FUNCTION__,__LINE__,CURRENT_TIME,index_,wpan_pName(p),p802_15_4macSA(p),p802_15_4macDA(p),ch->uid(),wph->uid,ch->size());
00696 #endif
00697         rxThisTotNum[wph->phyCurrentChannel]--;
00698         drop(p,(wph->phyCurrentChannel != ppib.phyCurrentChannel)?"CHN":"NOT");
00699     }
00700     else
00701     {
00702         rxThisTotNum[wph->phyCurrentChannel]--;
00703         //measure (here calculate) the link quality
00704         lq = measureLinkQ(p);
00705         ch->size() -= defPHY_HEADER_LEN;
00706         rxPkt = 0;
00707         if ((ch->size() <= 0) 
00708             ||(ch->size() > aMaxPHYPacketSize)
00709             ||ch->error())      //incomplete reception (due to FORCE_TRX_OFF),data packet received during ED or other errors
00710         {
00711 #ifdef DEBUG802_15_4
00712             fprintf(stdout,"[D][ERR][%s::%s::%d][%f](node %d) dropping pkt: type = %s, src = %d, dst = %d, uid = %d, mac_uid = %ld, size = %d\n",__FILE__,__FUNCTION__,CURRENT_TIME,__LINE__,index_,wpan_pName(p),p802_15_4macSA(p),p802_15_4macDA(p),ch->uid(),wph->uid,ch->size());
00713 #endif
00714             drop(p,"ERR");
00715         }
00716         else
00717         {
00718 
00719 #ifdef DEBUG802_15_4
00720             fprintf(stdout,"[%s::%s][%f](node %d) incoming pkt: type = %s, src = %d, dst = %d, uid = %d, mac_uid = %ld, size = %d --> PD_DATA_indication()\n",__FILE__,__FUNCTION__,CURRENT_TIME,index_,wpan_pName(p),p802_15_4macSA(p),p802_15_4macDA(p),ch->uid(),wph->uid,ch->size());
00721 #endif
00722             PD_DATA_indication(ch->size(),p,lq);    //MAC sublayer need to further check if the packet
00723                                 //is really received successfully or not.
00724         }
00725         if (trx_state_defer_set != p_IDLE)
00726         {
00727             trx_state_turnaround = trx_state_defer_set;
00728             trx_state_defer_set = p_IDLE;
00729             if (trx_state_turnaround == p_TRX_OFF)
00730             {
00731                 trx_state = trx_state_turnaround;
00732                 mac->PLME_SET_TRX_STATE_confirm(trx_state);
00733             }
00734             else
00735             {
00736                 //we need to delay <aTurnaroundTime> symbols for Rx2Tx
00737                 trx_state = p_TRX_OFF;  //should be disabled immediately (further reception will not succeed)
00738                 TRXH.start(aTurnaroundTime/getRate('s'));
00739             }
00740         }
00741     }
00742 }

Here is the call graph for this function:

void Phy::removechnl  )  [inline, inherited]
 

Definition at line 99 of file phy.h.

References LIST_REMOVE.

Referenced by 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, Queue< T >, and XcpSink.

Definition at line 70 of file object.cc.

Referenced by NsObject::command().

00071 {
00072 }

Packet* Phy802_15_4::rxPacket void   )  [inline]
 

Definition at line 143 of file p802_15_4phy.h.

References rxPkt.

Referenced by Mac802_15_4::command().

00143 {return rxPkt;}

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

Reimplemented in Mac802_3, and Mac802_15_4.

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:

void WirelessPhy::sendDown Packet p  )  [virtual, inherited]
 

Implements Phy.

Definition at line 200 of file wireless-phy.cc.

References hdr_cmn::access(), WirelessPhy::ant_, Phy::channel_, WirelessPhy::channel_idle_time_, Antenna::copy(), EnergyModel::DecrIdleEnergy(), EnergyModel::DecrTxEnergy(), WirelessPhy::em(), Packet::free(), WirelessPhy::IDLE, WirelessPhy::initialized(), WirelessPhy::Is_node_on(), WirelessPhy::Is_sleeping(), WirelessPhy::lambda_, WirelessPhy::last_send_time_, MAX, MIN, WirelessPhy::node(), Phy::node_, NOW, WirelessPhy::P_idle_, WirelessPhy::P_sleep_, WirelessPhy::Pr_consume_, WirelessPhy::Pt_, WirelessPhy::Pt_consume_, Channel::recv(), WirelessPhy::RECV, EnergyModel::setenergy(), PacketStamp::stamp(), WirelessPhy::status_, Packet::txinfo_, hdr_cmn::txtime(), Phy::txtime(), and WirelessPhy::update_energy_time_.

Referenced by PD_DATA_request().

00201 {
00202     /*
00203      * Sanity Check
00204      */
00205     assert(initialized());
00206     
00207     if (em()) {
00208             //node is off here...
00209             if (Is_node_on() != true ) {
00210             Packet::free(p);
00211             return;
00212             }
00213             if(Is_node_on() == true && Is_sleeping() == true){
00214             em()-> DecrSleepEnergy(NOW-update_energy_time_,
00215                             P_sleep_);
00216             update_energy_time_ = NOW;
00217 
00218             }
00219 
00220     }
00221     /*
00222      * Decrease node's energy
00223      */
00224     if(em()) {
00225         if (em()->energy() > 0) {
00226 
00227             double txtime = hdr_cmn::access(p)->txtime();
00228             double start_time = MAX(channel_idle_time_, NOW);
00229             double end_time = MAX(channel_idle_time_, NOW+txtime);
00230             double actual_txtime = end_time-start_time;
00231 
00232             if (start_time > update_energy_time_) {
00233                 em()->DecrIdleEnergy(start_time - 
00234                          update_energy_time_, P_idle_);
00235                 update_energy_time_ = start_time;
00236             }
00237 
00238             /* It turns out that MAC sends packet even though, it's
00239                receiving some packets.
00240             
00241             if (txtime-actual_txtime > 0.000001) {
00242                 fprintf(stderr,"Something may be wrong at MAC\n");
00243                 fprintf(stderr,"act_tx = %lf, tx = %lf\n", actual_txtime, txtime);
00244             }
00245             */
00246 
00247            // Sanity check
00248            double temp = MAX(NOW,last_send_time_);
00249 
00250            /*
00251            if (NOW < last_send_time_) {
00252                fprintf(stderr,"Argggg !! Overlapping transmission. NOW %lf last %lf temp %lf\n", NOW, last_send_time_, temp);
00253            }
00254            */
00255            
00256            double begin_adjust_time = MIN(channel_idle_time_, temp);
00257            double finish_adjust_time = MIN(channel_idle_time_, NOW+txtime);
00258            double gap_adjust_time = finish_adjust_time - begin_adjust_time;
00259            if (gap_adjust_time < 0.0) {
00260                fprintf(stderr,"What the heck ! negative gap time.\n");
00261            }
00262 
00263            if ((gap_adjust_time > 0.0) && (status_ == RECV)) {
00264                em()->DecrTxEnergy(gap_adjust_time,
00265                           Pt_consume_-Pr_consume_);
00266            }
00267 
00268            em()->DecrTxEnergy(actual_txtime,Pt_consume_);
00269 //         if (end_time > channel_idle_time_) {
00270 //             status_ = SEND;
00271 //         }
00272 //
00273            status_ = IDLE;
00274 
00275            last_send_time_ = NOW+txtime;
00276            channel_idle_time_ = end_time;
00277            update_energy_time_ = end_time;
00278 
00279            if (em()->energy() <= 0) {
00280                em()->setenergy(0);
00281                ((MobileNode*)node())->log_energy(0);
00282            }
00283 
00284         } else {
00285 
00286             // log node energy
00287             if (em()->energy() > 0) {
00288                 ((MobileNode *)node_)->log_energy(1);
00289             } 
00290 //
00291             Packet::free(p);
00292             return;
00293         }
00294     }
00295 
00296     /*
00297      *  Stamp the packet with the interface arguments
00298      */
00299     p->txinfo_.stamp((MobileNode*)node(), ant_->copy(), Pt_, lambda_);
00300     
00301     // Send the packet
00302     channel_->recv(p, this);
00303 }

Here is the call graph for this function:

void Phy802_15_4::sendOverHandler void   )  [protected]
 

Definition at line 744 of file p802_15_4phy.cc.

References aTurnaroundTime, CURRENT_TIME, Packet::free(), getRate(), HDR_CMN, HDR_LRWPAN, Phy::index_, mac, p802_15_4macDA(), p802_15_4macSA(), p_BUSY, p_IDLE, p_SUCCESS, p_TRX_OFF, Mac802_15_4::PD_DATA_confirm(), Mac802_15_4::PLME_SET_TRX_STATE_confirm(), Phy802_15_4Timer::start(), trx_state, trx_state_defer_set, trx_state_turnaround, TRXH, tx_state, txPktCopy, and wpan_pName().

Referenced by Phy802_15_4Timer::handle().

00745 {
00746 #ifdef DEBUG802_15_4
00747     fprintf(stdout,"[%s::%s][%f](node %d) sending over: type = %s, src = %d, dst = %d, uid = %d, mac_uid = %ld, size = %d\n",__FILE__,__FUNCTION__,CURRENT_TIME,index_,wpan_pName(txPktCopy),p802_15_4macSA(txPktCopy),p802_15_4macDA(txPktCopy),HDR_CMN(txPktCopy)->uid(),HDR_LRWPAN(txPktCopy)->uid,HDR_CMN(txPktCopy)->size());
00748 #endif
00749     assert(tx_state == p_BUSY);
00750     assert(txPktCopy);
00751     Packet::free(txPktCopy);
00752     tx_state = p_IDLE;
00753     mac->PD_DATA_confirm(p_SUCCESS);
00754     if (trx_state_defer_set != p_IDLE)
00755     {
00756         trx_state_turnaround = trx_state_defer_set;
00757         trx_state_defer_set = p_IDLE;
00758         if (trx_state_turnaround == p_TRX_OFF)
00759         {
00760             trx_state = trx_state_turnaround;
00761             mac->PLME_SET_TRX_STATE_confirm(trx_state);
00762         }
00763         else
00764         {
00765             //we need to delay <aTurnaroundTime> symbols for Rx2Tx
00766             trx_state = p_TRX_OFF;  //should be disabled immediately (further transmission will not succeed)
00767             TRXH.start(aTurnaroundTime/getRate('s'));
00768         }
00769     }
00770 }

Here is the call graph for this function:

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:

int WirelessPhy::sendUp Packet p  )  [virtual, inherited]
 

Implements Phy.

Definition at line 306 of file wireless-phy.cc.

References hdr_cmn::access(), WirelessPhy::ant_, Modulation::BitError(), WirelessPhy::channel_idle_time_, PacketStamp::CPThresh, WirelessPhy::CPThresh_, WirelessPhy::CSThresh_, EnergyModel::DecrIdleEnergy(), EnergyModel::DecrRcvEnergy(), WirelessPhy::em(), hdr_cmn::error(), PacketStamp::getAntenna(), PacketStamp::getNode(), PacketStamp::getTxPr(), HDR_CMN, WirelessPhy::IDLE, WirelessPhy::initialized(), Scheduler::instance(), WirelessPhy::Is_node_on(), WirelessPhy::Is_sleeping(), WirelessPhy::lambda_, MAX, WirelessPhy::modulation_, WirelessPhy::node(), Phy::node_, NOW, WirelessPhy::P_idle_, Propagation::Pr(), WirelessPhy::Pr_consume_, WirelessPhy::propagation_, Antenna::release(), PacketStamp::RxPr, WirelessPhy::RXThresh_, EnergyModel::setenergy(), PacketStamp::stamp(), WirelessPhy::status_, Packet::txinfo_, hdr_cmn::txtime(), and WirelessPhy::update_energy_time_.

Referenced by PD_DATA_indication(), and recv().

00307 {
00308     /*
00309      * Sanity Check
00310      */
00311     assert(initialized());
00312 
00313     PacketStamp s;
00314     double Pr;
00315     int pkt_recvd = 0;
00316 
00317     Pr = p->txinfo_.getTxPr();
00318     
00319     // if the node is in sleeping mode, drop the packet simply
00320     if (em()) {
00321             if (Is_node_on()!= true){
00322             pkt_recvd = 0;
00323             goto DONE;
00324             }
00325 
00326             if (Is_sleeping()==true && (Is_node_on() == true)) {
00327                 pkt_recvd = 0;
00328                 goto DONE;
00329             }
00330             
00331     }
00332     // if the energy goes to ZERO, drop the packet simply
00333     if (em()) {
00334         if (em()->energy() <= 0) {
00335             pkt_recvd = 0;
00336             goto DONE;
00337         }
00338     }
00339 
00340     if(propagation_) {
00341         s.stamp((MobileNode*)node(), ant_, 0, lambda_);
00342         Pr = propagation_->Pr(&p->txinfo_, &s, this);
00343         if (Pr < CSThresh_) {
00344             pkt_recvd = 0;
00345             goto DONE;
00346         }
00347         if (Pr < RXThresh_) {
00348             /*
00349              * We can detect, but not successfully receive
00350              * this packet.
00351              */
00352             hdr_cmn *hdr = HDR_CMN(p);
00353             hdr->error() = 1;
00354 #if DEBUG > 3
00355             printf("SM %f.9 _%d_ drop pkt from %d low POWER %e/%e\n",
00356                    Scheduler::instance().clock(), node()->index(),
00357                    p->txinfo_.getNode()->index(),
00358                    Pr,RXThresh);
00359 #endif
00360         }
00361     }
00362     if(modulation_) {
00363         hdr_cmn *hdr = HDR_CMN(p);
00364         hdr->error() = modulation_->BitError(Pr);
00365     }
00366     
00367     /*
00368      * The MAC layer must be notified of the packet reception
00369      * now - ie; when the first bit has been detected - so that
00370      * it can properly do Collision Avoidance / Detection.
00371      */
00372     pkt_recvd = 1;
00373 
00374 DONE:
00375     p->txinfo_.getAntenna()->release();
00376 
00377     /* WILD HACK: The following two variables are a wild hack.
00378        They will go away in the next release...
00379        They're used by the mac-802_11 object to determine
00380        capture.  This will be moved into the net-if family of 
00381        objects in the future. */
00382     p->txinfo_.RxPr = Pr;
00383     p->txinfo_.CPThresh = CPThresh_;
00384 
00385     /*
00386      * Decrease energy if packet successfully received
00387      */
00388     if(pkt_recvd && em()) {
00389 
00390         double rcvtime = hdr_cmn::access(p)->txtime();
00391         // no way to reach here if the energy level < 0
00392         
00393         double start_time = MAX(channel_idle_time_, NOW);
00394         double end_time = MAX(channel_idle_time_, NOW+rcvtime);
00395         double actual_rcvtime = end_time-start_time;
00396 
00397         if (start_time > update_energy_time_) {
00398             em()->DecrIdleEnergy(start_time-update_energy_time_,
00399                          P_idle_);
00400             update_energy_time_ = start_time;
00401         }
00402         
00403         em()->DecrRcvEnergy(actual_rcvtime,Pr_consume_);
00404 /*
00405   if (end_time > channel_idle_time_) {
00406   status_ = RECV;
00407   }
00408 */
00409         channel_idle_time_ = end_time;
00410         update_energy_time_ = end_time;
00411 
00412         status_ = IDLE;
00413 
00414         /*
00415           hdr_diff *dfh = HDR_DIFF(p);
00416           printf("Node %d receives (%d, %d, %d) energy %lf.\n",
00417           node()->address(), dfh->sender_id.addr_, 
00418           dfh->sender_id.port_, dfh->pk_num, node()->energy());
00419         */
00420 
00421         // log node energy
00422         if (em()->energy() > 0) {
00423         ((MobileNode *)node_)->log_energy(1);
00424             } 
00425 
00426         if (em()->energy() <= 0) {  
00427             // saying node died
00428             em()->setenergy(0);
00429             ((MobileNode*)node())->log_energy(0);
00430         }
00431     }
00432     
00433     return pkt_recvd;
00434 }

Here is the call graph for this function:

void Phy::setchnl Channel chnl  )  [inline, inherited]
 

Definition at line 102 of file phy.h.

References Phy::channel_.

Referenced by SatChannel::add_interface(), and SatChannel::remove_interface().

00102 { channel_ = chnl; }

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

Definition at line 103 of file phy.h.

References Phy::node(), and Phy::node_.

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

00103 { node_ = node; }

Here is the call graph for this function:

void Phy802_15_4::TRXHandler void   )  [protected]
 

Definition at line 670 of file p802_15_4phy.cc.

References mac, Mac802_15_4::PLME_SET_TRX_STATE_confirm(), trx_state, and trx_state_turnaround.

Referenced by Phy802_15_4Timer::handle().

00671 {
00672     trx_state = trx_state_turnaround;
00673     //send a confirm
00674     mac->PLME_SET_TRX_STATE_confirm(trx_state);
00675 }

Here is the call graph for this function:

double Phy802_15_4::trxTime Packet p,
bool  phyPkt = false
 

Definition at line 171 of file p802_15_4phy.cc.

References defPHY_HEADER_LEN, getRate(), HDR_CMN, and hdr_cmn::size().

Referenced by Mac802_15_4::canProceedWOcsmaca(), construct_PPDU(), PD_DATA_request(), Mac802_15_4::recvBeacon(), and Mac802_15_4::taskSuccess().

00172 {
00173     int phyHeaderLen;
00174     double trx;
00175     hdr_cmn* ch = HDR_CMN(p);
00176     
00177     phyHeaderLen = (phyPkt)?0:defPHY_HEADER_LEN;
00178     trx = ((ch->size() + phyHeaderLen)*8/getRate('d'));
00179     return trx;
00180 }

Here is the call graph for this function:

double Phy::txtime int  bytes  )  [inline, inherited]
 

Definition at line 83 of file phy.h.

References Phy::bandwidth_.

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

double Phy::txtime Packet p  )  [inline, inherited]
 

Definition at line 81 of file phy.h.

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

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

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_.

00048 { return uptarget_; }


Friends And Related Function Documentation

friend class Phy802_15_4Timer [friend]
 

Definition at line 126 of file p802_15_4phy.h.


Field Documentation

Antenna* WirelessPhy::ant_ [protected, inherited]
 

Definition at line 122 of file wireless-phy.h.

Referenced by WirelessPhy::command(), WirelessPhy::dump(), WirelessPhy::getAntennaZ(), WirelessPhy::sendDown(), WirelessPhy::sendUp(), and WirelessPhy::WirelessPhy().

double Phy::bandwidth_ [protected, inherited]
 

Definition at line 137 of file phy.h.

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

Phy802_15_4Timer Phy802_15_4::CCAH [private]
 

Definition at line 172 of file p802_15_4phy.h.

Referenced by PLME_CCA_request().

Channel* Phy::channel_ [protected, inherited]
 

Definition at line 138 of file phy.h.

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

double WirelessPhy::channel_idle_time_ [protected, inherited]
 

Definition at line 111 of file wireless-phy.h.

Referenced by WirelessPhy::sendDown(), WirelessPhy::sendUp(), and WirelessPhy::WirelessPhy().

double WirelessPhy::CPThresh_ [protected, inherited]
 

Definition at line 120 of file wireless-phy.h.

Referenced by WirelessPhy::sendUp(), and WirelessPhy::WirelessPhy().

double WirelessPhy::CSThresh_ [protected, inherited]
 

Definition at line 119 of file wireless-phy.h.

Referenced by CCAHandler(), WirelessPhy::getCSThresh(), WirelessPhy::sendUp(), and WirelessPhy::WirelessPhy().

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(), PushbackQueue::enque(), NsObject::isdebug(), NsObject::NsObject(), TfrcAgent::recv(), PushbackQueue::reportDrop(), SctpAgent::Reset(), REDQueue::reset(), DropTail::shrink_queue(), and Delayer::try_send().

NsObject* BiConnector::downtarget_ [protected, inherited]
 

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

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

NsObject* BiConnector::drop_ [protected, inherited]
 

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

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

Phy802_15_4Timer Phy802_15_4::EDH [private]
 

Definition at line 173 of file p802_15_4phy.h.

Referenced by PLME_ED_request(), and recv().

double WirelessPhy::freq_ [protected, inherited]
 

Definition at line 114 of file wireless-phy.h.

Referenced by WirelessPhy::getFreq(), and WirelessPhy::WirelessPhy().

LinkHead* Phy::head_ [protected, inherited]
 

Definition at line 116 of file phy.h.

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

int Phy::index_ [protected, inherited]
 

Definition at line 113 of file phy.h.

Referenced by Phy::command(), Phy::dump(), PD_DATA_request(), Phy::Phy(), PLME_SET_request(), PLME_SET_TRX_STATE_request(), recv(), recvOverHandler(), and sendOverHandler().

double WirelessPhy::L_ [protected, inherited]
 

Definition at line 116 of file wireless-phy.h.

Referenced by WirelessPhy::dump(), WirelessPhy::getL(), and WirelessPhy::WirelessPhy().

double WirelessPhy::lambda_ [protected, inherited]
 

Definition at line 115 of file wireless-phy.h.

Referenced by WirelessPhy::dump(), WirelessPhy::getLambda(), WirelessPhy::sendDown(), WirelessPhy::sendUp(), and WirelessPhy::WirelessPhy().

double WirelessPhy::last_send_time_ [protected, inherited]
 

Definition at line 110 of file wireless-phy.h.

Referenced by WirelessPhy::sendDown(), and WirelessPhy::WirelessPhy().

Mac802_15_4* Phy802_15_4::mac [private]
 

Definition at line 171 of file p802_15_4phy.h.

Referenced by CCAHandler(), EDHandler(), macObj(), PD_DATA_request(), PLME_CCA_request(), PLME_ED_request(), PLME_GET_request(), PLME_SET_request(), PLME_SET_TRX_STATE_request(), recv(), recvOverHandler(), sendOverHandler(), and TRXHandler().

Modulation* WirelessPhy::modulation_ [protected, inherited]
 

Definition at line 124 of file wireless-phy.h.

Referenced by WirelessPhy::sendUp(), and WirelessPhy::WirelessPhy().

Node* Phy::node_ [protected, inherited]
 

Definition at line 115 of file phy.h.

Referenced by WirelessPhy::command(), Phy::command(), WirelessPhy::initialized(), WiredPhy::initialized(), WirelessPhy::node(), Phy::node(), WirelessPhy::node_sleep(), WirelessPhy::node_wakeup(), Phy::Phy(), WirelessPhy::sendDown(), WirelessPhy::sendUp(), Phy::setnode(), WirelessPhy::UpdateIdleEnergy(), WirelessPhy::UpdateSleepEnergy(), and WirelessPhy::WirelessPhy().

bool WirelessPhy::node_on_ [protected, inherited]
 

Definition at line 130 of file wireless-phy.h.

Referenced by WirelessPhy::Is_node_on(), WirelessPhy::node_off(), WirelessPhy::node_on(), and WirelessPhy::WirelessPhy().

double WirelessPhy::P_idle_ [protected, inherited]
 

Definition at line 104 of file wireless-phy.h.

Referenced by WirelessPhy::command(), WirelessPhy::node_off(), WirelessPhy::node_sleep(), WirelessPhy::sendDown(), WirelessPhy::sendUp(), WirelessPhy::UpdateIdleEnergy(), and WirelessPhy::WirelessPhy().

double WirelessPhy::P_sleep_ [protected, inherited]
 

Definition at line 105 of file wireless-phy.h.

Referenced by WirelessPhy::command(), WirelessPhy::node_wakeup(), WirelessPhy::sendDown(), WirelessPhy::UpdateSleepEnergy(), and WirelessPhy::WirelessPhy().

double WirelessPhy::P_transition_ [protected, inherited]
 

Definition at line 106 of file wireless-phy.h.

Referenced by WirelessPhy::command(), WirelessPhy::node_sleep(), WirelessPhy::node_wakeup(), and WirelessPhy::WirelessPhy().

PHY_PIB Phy802_15_4::ppib [private]
 

Definition at line 156 of file p802_15_4phy.h.

Referenced by CCAHandler(), channelSupported(), construct_PPDU(), getRate(), Phy802_15_4(), PLME_ED_request(), PLME_GET_request(), PLME_SET_request(), recv(), and recvOverHandler().

PHY_PIB Phy802_15_4::PPIB [static]
 

Initial value:

Definition at line 146 of file p802_15_4phy.h.

Referenced by Phy802_15_4Class::create().

double WirelessPhy::Pr_consume_ [protected, inherited]
 

Definition at line 103 of file wireless-phy.h.

Referenced by WirelessPhy::command(), WirelessPhy::sendDown(), WirelessPhy::sendUp(), and WirelessPhy::WirelessPhy().

Propagation* WirelessPhy::propagation_ [protected, inherited]
 

Definition at line 123 of file wireless-phy.h.

Referenced by WirelessPhy::command(), WirelessPhy::getDist(), WirelessPhy::initialized(), WirelessPhy::sendUp(), and WirelessPhy::WirelessPhy().

double WirelessPhy::Pt_ [protected, inherited]
 

Definition at line 101 of file wireless-phy.h.

Referenced by WirelessPhy::dump(), WirelessPhy::getPt(), WirelessPhy::sendDown(), and WirelessPhy::WirelessPhy().

double WirelessPhy::Pt_consume_ [protected, inherited]
 

Definition at line 102 of file wireless-phy.h.

Referenced by WirelessPhy::command(), WirelessPhy::getPtconsume(), WirelessPhy::sendDown(), and WirelessPhy::WirelessPhy().

Phy802_15_4Timer Phy802_15_4::recvOverH [private]
 

Definition at line 175 of file p802_15_4phy.h.

double Phy802_15_4::rxEDPeakPower [private]
 

Definition at line 168 of file p802_15_4phy.h.

Referenced by EDHandler(), PLME_ED_request(), and recv().

Packet* Phy802_15_4::rxPkt [private]
 

Definition at line 161 of file p802_15_4phy.h.

Referenced by Phy802_15_4(), PLME_SET_request(), PLME_SET_TRX_STATE_request(), recv(), recvOverHandler(), and rxPacket().

UINT_32 Phy802_15_4::rxThisTotNum[27] [private]
 

Definition at line 170 of file p802_15_4phy.h.

Referenced by Phy802_15_4(), recv(), and recvOverHandler().

double WirelessPhy::RXThresh_ [protected, inherited]
 

Definition at line 118 of file wireless-phy.h.

Referenced by EDHandler(), WirelessPhy::getRXThresh(), measureLinkQ(), WirelessPhy::sendUp(), and WirelessPhy::WirelessPhy().

UINT_32 Phy802_15_4::rxTotNum[27] [private]
 

Definition at line 169 of file p802_15_4phy.h.

Referenced by CCAHandler(), Phy802_15_4(), recv(), and recvOverHandler().

double Phy802_15_4::rxTotPower[27] [private]
 

Definition at line 167 of file p802_15_4phy.h.

Referenced by CCAHandler(), Phy802_15_4(), PLME_ED_request(), recv(), and recvOverHandler().

Phy802_15_4Timer Phy802_15_4::sendOverH [private]
 

Definition at line 176 of file p802_15_4phy.h.

Referenced by PD_DATA_request(), PLME_SET_request(), and PLME_SET_TRX_STATE_request().

Sleep_Timer WirelessPhy::sleep_timer_ [protected, inherited]
 

Definition at line 131 of file wireless-phy.h.

Referenced by WirelessPhy::UpdateSleepEnergy(), and WirelessPhy::WirelessPhy().

int WirelessPhy::status_ [protected, inherited]
 

Definition at line 132 of file wireless-phy.h.

Referenced by WirelessPhy::Is_sleeping(), WirelessPhy::node_off(), WirelessPhy::node_on(), WirelessPhy::node_sleep(), WirelessPhy::node_wakeup(), WirelessPhy::sendDown(), WirelessPhy::sendUp(), and WirelessPhy::UpdateIdleEnergy().

double WirelessPhy::T_transition_ [protected, inherited]
 

Definition at line 107 of file wireless-phy.h.

Referenced by WirelessPhy::command(), WirelessPhy::node_sleep(), and WirelessPhy::node_wakeup().

PHYenum Phy802_15_4::trx_state [private]
 

Definition at line 157 of file p802_15_4phy.h.

Referenced by PD_DATA_request(), Phy802_15_4(), PLME_CCA_request(), PLME_ED_request(), PLME_SET_TRX_STATE_request(), recv(), recvOverHandler(), sendOverHandler(), and TRXHandler().

PHYenum Phy802_15_4::trx_state_defer_set [private]
 

Definition at line 158 of file p802_15_4phy.h.

Referenced by Phy802_15_4(), PLME_SET_request(), PLME_SET_TRX_STATE_request(), recvOverHandler(), and sendOverHandler().

PHYenum Phy802_15_4::trx_state_turnaround [private]
 

Definition at line 159 of file p802_15_4phy.h.

Referenced by PLME_SET_TRX_STATE_request(), recvOverHandler(), sendOverHandler(), and TRXHandler().

Phy802_15_4Timer Phy802_15_4::TRXH [private]
 

Definition at line 174 of file p802_15_4phy.h.

Referenced by PLME_SET_TRX_STATE_request(), recvOverHandler(), and sendOverHandler().

PHYenum Phy802_15_4::tx_state [private]
 

Definition at line 160 of file p802_15_4phy.h.

Referenced by CCAHandler(), PD_DATA_request(), Phy802_15_4(), PLME_SET_request(), PLME_SET_TRX_STATE_request(), and sendOverHandler().

Packet* Phy802_15_4::txPkt [private]
 

Definition at line 165 of file p802_15_4phy.h.

Referenced by PD_DATA_request(), PLME_SET_request(), and PLME_SET_TRX_STATE_request().

Packet* Phy802_15_4::txPktCopy [private]
 

Definition at line 166 of file p802_15_4phy.h.

Referenced by PD_DATA_request(), PLME_SET_request(), PLME_SET_TRX_STATE_request(), and sendOverHandler().

double WirelessPhy::update_energy_time_ [protected, inherited]
 

Definition at line 112 of file wireless-phy.h.

Referenced by WirelessPhy::command(), WirelessPhy::node_off(), WirelessPhy::node_on(), WirelessPhy::node_sleep(), WirelessPhy::node_wakeup(), WirelessPhy::sendDown(), WirelessPhy::sendUp(), WirelessPhy::UpdateIdleEnergy(), WirelessPhy::UpdateSleepEnergy(), and WirelessPhy::WirelessPhy().

NsObject* BiConnector::uptarget_ [protected, inherited]
 

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

Referenced by BiConnector::command(), Phy::dump(), UnslottedAlohaMac::end_of_contention(), WirelessPhy::initialized(), WiredPhy::initialized(), Mac::initialized(), God::initialized(), Mac802_15_4::MCPS_DATA_indication(), PD_DATA_indication(), RepeaterPhy::recv(), Phy::recv(), MacTdma::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 Mar 6 17:24:53 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6