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

WirelessPhy Class Reference

#include <wireless-phy.h>

Inheritance diagram for WirelessPhy:

Inheritance graph
[legend]
Collaboration diagram for WirelessPhy:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 WirelessPhy ()
void sendDown (Packet *p)
int sendUp (Packet *p)
double getL () const
double getLambda () const
Nodenode (void) const
double getPtconsume ()
virtual int command (int argc, const char *const *argv)
virtual void dump (void) const
void node_on ()
void node_off ()
void recv (Packet *p, Handler *h)
virtual void recv (Packet *p, const char *s)
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 Channelchannel (void) const
LinkHeadhead ()
NsObjectuptarget ()
NsObjectdowntarget ()
virtual void drop (Packet *p)
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 Types

enum  ChannelStatus { IDLE, RECV, SEND }

Protected Member Functions

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

Protected Attributes

double Pt_
double Pt_consume_
double Pr_consume_
double P_idle_
double last_send_time_
double channel_idle_time_
double update_energy_time_
double freq_
double lambda_
double L_
double RXThresh_
double CSThresh_
double CPThresh_
Antennaant_
Propagationpropagation_
Modulationmodulation_
Idle_Timer idle_timer_
int status_
int index_
Nodenode_
LinkHeadhead_
double bandwidth_
Channelchannel_
NsObjectuptarget_
NsObjectdowntarget_
NsObjectdrop_
int debug_

Private Member Functions

int initialized ()
void UpdateIdleEnergy ()
EnergyModelem ()

Friends

class Idle_Timer

Member Enumeration Documentation

enum WirelessPhy::ChannelStatus [protected]
 

Enumeration values:
IDLE 
RECV 
SEND 

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

00110 { IDLE, RECV, SEND };


Constructor & Destructor Documentation

WirelessPhy::WirelessPhy  ) 
 

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

References ant_, channel_idle_time_, CPThresh_, CSThresh_, freq_, IDLE, idle_timer_, L_, lambda_, last_send_time_, modulation_, Phy::node_, NOW, P_idle_, Pr_consume_, propagation_, Pt_, Pt_consume_, TimerHandler::resched(), RXThresh_, SPEED_OF_LIGHT, and update_energy_time_.

00077                          : Phy(), idle_timer_(this), status_(IDLE)
00078 {
00079         /*
00080          *  It sounds like 10db should be the capture threshold.
00081          *
00082          *  If a node is presently receiving a packet a a power level
00083          *  Pa, and a packet at power level Pb arrives, the following
00084          *  comparion must be made to determine whether or not capture
00085          *  occurs:
00086          *
00087          *    10 * log(Pa) - 10 * log(Pb) > 10db
00088          *
00089          *  OR equivalently
00090          *
00091          *    Pa/Pb > 10.
00092          *
00093          */
00094         bind("CPThresh_", &CPThresh_);
00095         bind("CSThresh_", &CSThresh_);
00096         bind("RXThresh_", &RXThresh_);
00097         //bind("bandwidth_", &bandwidth_);
00098         bind("Pt_", &Pt_);
00099         bind("freq_", &freq_);
00100         bind("L_", &L_);
00101         
00102         lambda_ = SPEED_OF_LIGHT / freq_;
00103 
00104         node_ = 0;
00105         ant_ = 0;
00106         propagation_ = 0;
00107         modulation_ = 0;
00108 
00109         // Assume AT&T's Wavelan PCMCIA card -- Chalermek
00110         //      Pt_ = 8.5872e-4; // For 40m transmission range.
00111         //      Pt_ = 7.214e-3;  // For 100m transmission range.
00112         //      Pt_ = 0.2818; // For 250m transmission range.
00113         //      Pt_ = pow(10, 2.45) * 1e-3;         // 24.5 dbm, ~ 281.8mw
00114         
00115         Pt_consume_ = 0.660;  // 1.6 W drained power for transmission
00116         Pr_consume_ = 0.395;  // 1.2 W drained power for reception
00117 
00118         //      P_idle_ = 0.035; // 1.15 W drained power for idle
00119 
00120         P_idle_ = 0.0;
00121 
00122         channel_idle_time_ = NOW;
00123         update_energy_time_ = NOW;
00124         last_send_time_ = NOW;
00125         
00126         idle_timer_.resched(1.0);
00127 }

Here is the call graph for this function:


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_; }

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(), 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 WirelessPhy::command int  argc,
const char *const *  argv
[virtual]
 

Reimplemented from Phy.

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

References ant_, Phy::command(), EnergyModel::DecrIdleEnergy(), em(), Phy::node_, NOW, P_idle_, Pr_consume_, propagation_, Pt_consume_, and update_energy_time_.

00131 {
00132         TclObject *obj; 
00133 
00134         if (argc==2) {
00135                 if (strcasecmp(argv[1], "NodeOn") == 0) {
00136                         if (em() == NULL) 
00137                                 return TCL_OK;
00138                         if (NOW > update_energy_time_) {
00139                                 update_energy_time_ = NOW;
00140                         }
00141                         return TCL_OK;
00142                 } else if (strcasecmp(argv[1], "NodeOff") == 0) {
00143                         if (em() == NULL) 
00144                                 return TCL_OK;
00145                         if (NOW > update_energy_time_) {
00146                                 em()->DecrIdleEnergy(NOW-update_energy_time_,
00147                                                      P_idle_);
00148                                 update_energy_time_ = NOW;
00149                         }
00150                         return TCL_OK;
00151                 }
00152         } else if(argc == 3) {
00153                 if (strcasecmp(argv[1], "setTxPower") == 0) {
00154                         Pt_consume_ = atof(argv[2]);
00155                         return TCL_OK;
00156                 } else if (strcasecmp(argv[1], "setRxPower") == 0) {
00157                         Pr_consume_ = atof(argv[2]);
00158                         return TCL_OK;
00159                 } else if (strcasecmp(argv[1], "setIdlePower") == 0) {
00160                         P_idle_ = atof(argv[2]);
00161                         return TCL_OK;
00162                 } else if( (obj = TclObject::lookup(argv[2])) == 0) {
00163                         fprintf(stderr,"WirelessPhy: %s lookup of %s failed\n", 
00164                                 argv[1], argv[2]);
00165                         return TCL_ERROR;
00166                 } else if (strcmp(argv[1], "propagation") == 0) {
00167                         assert(propagation_ == 0);
00168                         propagation_ = (Propagation*) obj;
00169                         return TCL_OK;
00170                 } else if (strcasecmp(argv[1], "antenna") == 0) {
00171                         ant_ = (Antenna*) obj;
00172                         return TCL_OK;
00173                 } else if (strcasecmp(argv[1], "node") == 0) {
00174                         assert(node_ == 0);
00175                         node_ = (Node *)obj;
00176                         return TCL_OK;
00177                 }
00178         }
00179         return Phy::command(argc,argv);
00180 }

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 WirelessPhy::dump void   )  const [virtual]
 

Reimplemented from Phy.

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

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

00416 {
00417         Phy::dump();
00418         fprintf(stdout,
00419                 "\tPt: %f, Gt: %f, Gr: %f, lambda: %f, L: %f\n",
00420                 Pt_, ant_->getTxGain(0,0,0,lambda_), ant_->getRxGain(0,0,0,lambda_), lambda_, L_);
00421         //fprintf(stdout, "\tbandwidth: %f\n", bandwidth_);
00422         fprintf(stdout, "--------------------------------------------------\n");
00423 }

Here is the call graph for this function:

EnergyModel* WirelessPhy::em  )  [inline, private]
 

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

References Node::energy_model(), and node().

Referenced by command(), node_off(), node_on(), sendDown(), sendUp(), and UpdateIdleEnergy().

00118 { return node()->energy_model(); }

Here is the call graph for this function:

double WirelessPhy::getL  )  const [inline]
 

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

References L_.

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

00073 {return L_;}

double WirelessPhy::getLambda  )  const [inline]
 

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

References lambda_.

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

00074 {return lambda_;}

double WirelessPhy::getPtconsume  )  [inline]
 

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

References Pt_consume_.

00076 { return Pt_consume_; }

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(), LinkHandoffMgr::get_peer_linkhead(), and SatPhy::sendDown().

00108 { return head_; }

int WirelessPhy::initialized  )  [inline, private]
 

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

References BiConnector::downtarget_, Phy::node_, propagation_, and BiConnector::uptarget_.

Referenced by sendDown(), and sendUp().

00113                                  {
00114                 return (node_ && uptarget_ && downtarget_ && propagation_);
00115         }

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(), 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, 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         }

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]
 

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

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

Definition at line 94 of file phy.h.

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

00094 { return node_link_.le_next; }

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

Reimplemented from Phy.

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

References Phy::node_.

Referenced by em(), sendDown(), and sendUp().

00075 { return node_; }

void WirelessPhy::node_off  ) 
 

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

References EnergyModel::DecrIdleEnergy(), em(), NOW, P_idle_, and update_energy_time_.

00404 {
00405         if (em() == NULL)
00406             return;
00407         if (NOW > update_energy_time_) {
00408             em()->DecrIdleEnergy(NOW-update_energy_time_,
00409                                 P_idle_);
00410             update_energy_time_ = NOW;
00411         }
00412 }

Here is the call graph for this function:

void WirelessPhy::node_on  ) 
 

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

References em(), NOW, and update_energy_time_.

00394 {
00395         if (em() == NULL)
00396             return;     
00397         if (NOW > update_energy_time_) {
00398             update_energy_time_ = NOW;
00399         }
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 Phy::recv Packet p,
Handler h
[virtual, inherited]
 

Reimplemented from BiConnector.

Reimplemented in RepeaterPhy.

Definition at line 106 of file phy.cc.

References hdr_cmn::DOWN, Packet::free(), HDR_CMN, NsObject::recv(), Phy::sendDown(), Phy::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, inherited]
 

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:

void WirelessPhy::sendDown Packet p  )  [virtual]
 

Implements Phy.

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

References hdr_cmn::access(), ant_, Phy::channel_, channel_idle_time_, Antenna::copy(), EnergyModel::DecrIdleEnergy(), EnergyModel::DecrTxEnergy(), em(), EnergyModel::energy(), Packet::free(), initialized(), lambda_, last_send_time_, max, min, node(), EnergyModel::node_on(), NOW, P_idle_, Pr_consume_, Pt_, Pt_consume_, Channel::recv(), RECV, SEND, EnergyModel::setenergy(), EnergyModel::sleep(), PacketStamp::stamp(), status_, Packet::txinfo_, hdr_cmn::txtime(), Phy::txtime(), and update_energy_time_.

00184 {
00185         /*
00186          * Sanity Check
00187          */
00188         assert(initialized());
00189         
00190         if (em()) 
00191                 if ((em()->node_on() != true) || (em()->sleep())) {
00192                         Packet::free(p);
00193                         return;
00194                 }
00195 
00196         /*
00197          * Decrease node's energy
00198          */
00199         if(em()) {
00200                 if (em()->energy() > 0) {
00201                         //double txtime = (8.*hdr_cmn::access(p)->size())/bandwidth_;
00202                     double txtime = hdr_cmn::access(p)->txtime();
00203                     double start_time = max(channel_idle_time_, NOW);
00204                     double end_time = max(channel_idle_time_, NOW+txtime);
00205                     double actual_txtime = end_time-start_time;
00206 
00207                     if (start_time > update_energy_time_) {
00208                             em()->DecrIdleEnergy(start_time - 
00209                                                  update_energy_time_, P_idle_);
00210                             update_energy_time_ = start_time;
00211                     }
00212 
00213                     /* It turns out that MAC sends packet even though, it's
00214                        receiving some packets.
00215                     
00216                     if (txtime-actual_txtime > 0.000001) {
00217                             fprintf(stderr,"Something may be wrong at MAC\n");
00218                             fprintf(stderr,"act_tx = %lf, tx = %lf\n", actual_txtime, txtime);
00219                     }
00220                     */
00221 
00222                    // Sanity check
00223                    double temp = max(NOW,last_send_time_);
00224 
00225                    /*
00226                    if (NOW < last_send_time_) {
00227                            fprintf(stderr,"Argggg !! Overlapping transmission. NOW %lf last %lf temp %lf\n", NOW, last_send_time_, temp);
00228                    }
00229                    */
00230                    
00231                    double begin_adjust_time = min(channel_idle_time_, temp);
00232                    double finish_adjust_time = min(channel_idle_time_, NOW+txtime);
00233                    double gap_adjust_time = finish_adjust_time - begin_adjust_time;
00234                    if (gap_adjust_time < 0.0) {
00235                            fprintf(stderr,"What the heck ! negative gap time.\n");
00236                    }
00237 
00238                    if ((gap_adjust_time > 0.0) && (status_ == RECV)) {
00239                            em()->DecrTxEnergy(gap_adjust_time,
00240                                               Pt_consume_-Pr_consume_);
00241                    }
00242 
00243                    em()->DecrTxEnergy(actual_txtime,Pt_consume_);
00244                    if (end_time > channel_idle_time_) {
00245                            status_ = SEND;
00246                    }
00247                                                         
00248                    last_send_time_ = NOW+txtime;
00249                    channel_idle_time_ = end_time;
00250                    update_energy_time_ = end_time;
00251 
00252                    if (em()->energy() <= 0) {
00253                            em()->setenergy(0);
00254                            ((MobileNode*)node())->log_energy(0);
00255                    }
00256 
00257                 } else {
00258                         Packet::free(p);
00259                         return;
00260                 }
00261         }
00262 
00263         /*
00264          *  Stamp the packet with the interface arguments
00265          */
00266         p->txinfo_.stamp((MobileNode*)node(), ant_->copy(), Pt_, lambda_);
00267 
00268         // Send the packet
00269         channel_->recv(p, this);
00270 }

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]
 

Implements Phy.

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

References hdr_cmn::access(), ant_, Modulation::BitError(), channel_idle_time_, PacketStamp::CPThresh, CPThresh_, CSThresh_, EnergyModel::DecrIdleEnergy(), EnergyModel::DecrRcvEnergy(), em(), EnergyModel::energy(), hdr_cmn::error(), PacketStamp::getAntenna(), PacketStamp::getNode(), HDR_CMN, initialized(), Scheduler::instance(), lambda_, max, modulation_, node(), EnergyModel::node_on(), NOW, P_idle_, pow(), Propagation::Pr(), Pr_consume_, propagation_, RECV, Antenna::release(), PacketStamp::RxPr, RXThresh_, EnergyModel::setenergy(), EnergyModel::sleep(), PacketStamp::stamp(), status_, Packet::txinfo_, hdr_cmn::txtime(), and update_energy_time_.

00274 {
00275         /*
00276          * Sanity Check
00277          */
00278         assert(initialized());
00279 
00280         PacketStamp s;
00281         double Pr;
00282         int pkt_recvd = 0;
00283         
00284         // if the node is in sleeping mode, drop the packet simply
00285         if (em()) 
00286                 if (em()->sleep() || (em()->node_on() != true)) {
00287                         pkt_recvd = 0;
00288                         goto DONE;
00289                 }
00290         
00291         // if the energy goes to ZERO, drop the packet simply
00292         if (em()) {
00293                 if (em()->energy() <= 0) {
00294                         pkt_recvd = 0;
00295                         goto DONE;
00296                 }
00297         }
00298 
00299         if(propagation_) {
00300                 s.stamp((MobileNode*)node(), ant_, 0, lambda_);
00301                 Pr = propagation_->Pr(&p->txinfo_, &s, this);
00302                 if (Pr < CSThresh_) {
00303                         pkt_recvd = 0;
00304                         goto DONE;
00305                 }
00306                 if (Pr < RXThresh_) {
00307                         /*
00308                          * We can detect, but not successfully receive
00309                          * this packet.
00310                          */
00311                         hdr_cmn *hdr = HDR_CMN(p);
00312                         hdr->error() = 1;
00313 #if DEBUG > 3
00314                         printf("SM %f.9 _%d_ drop pkt from %d low POWER %e/%e\n",
00315                                Scheduler::instance().clock(), node()->index(),
00316                                p->txinfo_.getNode()->index(),
00317                                Pr,RXThresh);
00318 #endif
00319                 }
00320         }
00321         if(modulation_) {
00322                 hdr_cmn *hdr = HDR_CMN(p);
00323                 hdr->error() = modulation_->BitError(Pr);
00324         }
00325         
00326         /*
00327          * The MAC layer must be notified of the packet reception
00328          * now - ie; when the first bit has been detected - so that
00329          * it can properly do Collision Avoidance / Detection.
00330          */
00331         pkt_recvd = 1;
00332 
00333 DONE:
00334         p->txinfo_.getAntenna()->release();
00335 
00336         /* WILD HACK: The following two variables are a wild hack.
00337            They will go away in the next release...
00338            They're used by the mac-802_11 object to determine
00339            capture.  This will be moved into the net-if family of 
00340            objects in the future. */
00341         p->txinfo_.RxPr = Pr;
00342         p->txinfo_.CPThresh = pow(10,CPThresh_/10); /* CPThresh_ is in db */
00343 
00344         /*
00345          * Decrease energy if packet successfully received
00346          */
00347         if(pkt_recvd && em()) {
00348                 //double rcvtime = (8. * hdr_cmn::access(p)->size())/bandwidth_;
00349                 double rcvtime = hdr_cmn::access(p)->txtime();
00350                 // no way to reach here if the energy level < 0
00351                 
00352                 /*
00353                   node()->add_rcvtime(rcvtime);   
00354                   em()->DecrRcvEnergy(rcvtime,Pr_consume_);
00355                 */
00356 
00357                 double start_time = max(channel_idle_time_, NOW);
00358                 double end_time = max(channel_idle_time_, NOW+rcvtime);
00359                 double actual_rcvtime = end_time-start_time;
00360 
00361                 if (start_time > update_energy_time_) {
00362                         em()->DecrIdleEnergy(start_time-update_energy_time_,
00363                                              P_idle_);
00364                         update_energy_time_ = start_time;
00365                 }
00366                 
00367                 em()->DecrRcvEnergy(actual_rcvtime,Pr_consume_);
00368                 if (end_time > channel_idle_time_) {
00369                         status_ = RECV;
00370                 }
00371 
00372                 channel_idle_time_ = end_time;
00373                 update_energy_time_ = end_time;
00374 
00375                 /*
00376                   hdr_diff *dfh = HDR_DIFF(p);
00377                   printf("Node %d receives (%d, %d, %d) energy %lf.\n",
00378                   node()->address(), dfh->sender_id.addr_, 
00379                   dfh->sender_id.port_, dfh->pk_num, node()->energy());
00380                 */
00381                 
00382                 if (em()->energy() <= 0) {  
00383                         // saying node died
00384                         em()->setenergy(0);
00385                         ((MobileNode*)node())->log_energy(0);
00386                 }
00387         }
00388         
00389         return pkt_recvd;
00390 }

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(), SatLinkHandoffMgr::handoff(), TermLinkHandoffMgr::handoff(), 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_.

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

00103 { node_ = node; }

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(), Phy::bandwidth_, and hdr_cmn::size().

Referenced by Mac802_3::collision(), Mac8023HandlerSend::handle(), Mac802_3::recv_complete(), MacHandlerRetx::schedule(), 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:

void WirelessPhy::UpdateIdleEnergy  )  [private]
 

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

References em(), EnergyModel::energy(), idle_timer_, Phy::node_, EnergyModel::node_on(), NOW, P_idle_, TimerHandler::resched(), and update_energy_time_.

Referenced by Idle_Timer::expire().

00427 {
00428         if (em() == NULL) {
00429                 return;
00430         }
00431         if (NOW > update_energy_time_ && em()->node_on()) {
00432                   em()-> DecrIdleEnergy(NOW-update_energy_time_,
00433                                         P_idle_);
00434                   update_energy_time_ = NOW;
00435         }
00436 
00437         // log node energy
00438         if (em()->energy() > 0) {
00439                 ((MobileNode *)node_)->log_energy(1);
00440         } else {
00441                 ((MobileNode *)node_)->log_energy(0);   
00442         }
00443 
00444         idle_timer_.resched(10.0);
00445 }

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_; }


Friends And Related Function Documentation

friend class Idle_Timer [friend]
 

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


Member Data Documentation

Antenna* WirelessPhy::ant_ [protected]
 

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

Referenced by command(), dump(), sendDown(), sendUp(), and 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().

Channel* Phy::channel_ [protected, inherited]
 

Definition at line 138 of file phy.h.

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

double WirelessPhy::channel_idle_time_ [protected]
 

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

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

double WirelessPhy::CPThresh_ [protected]
 

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

Referenced by sendUp(), and WirelessPhy().

double WirelessPhy::CSThresh_ [protected]
 

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

Referenced by sendUp(), and 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(), 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 Phy::command(), BiConnector::command(), BiConnector::downtarget(), 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().

double WirelessPhy::freq_ [protected]
 

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

Referenced by WirelessPhy().

LinkHead* Phy::head_ [protected, inherited]
 

Definition at line 116 of file phy.h.

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

Idle_Timer WirelessPhy::idle_timer_ [protected]
 

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

Referenced by UpdateIdleEnergy(), and WirelessPhy().

int Phy::index_ [protected, inherited]
 

Definition at line 113 of file phy.h.

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

double WirelessPhy::L_ [protected]
 

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

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

double WirelessPhy::lambda_ [protected]
 

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

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

double WirelessPhy::last_send_time_ [protected]
 

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

Referenced by sendDown(), and WirelessPhy().

Modulation* WirelessPhy::modulation_ [protected]
 

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

Referenced by sendUp(), and WirelessPhy().

Node* Phy::node_ [protected, inherited]
 

Definition at line 115 of file phy.h.

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

double WirelessPhy::P_idle_ [protected]
 

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

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

double WirelessPhy::Pr_consume_ [protected]
 

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

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

Propagation* WirelessPhy::propagation_ [protected]
 

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

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

double WirelessPhy::Pt_ [protected]
 

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

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

double WirelessPhy::Pt_consume_ [protected]
 

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

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

double WirelessPhy::RXThresh_ [protected]
 

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

Referenced by sendUp(), and WirelessPhy().

int WirelessPhy::status_ [protected]
 

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

Referenced by sendDown(), and sendUp().

double WirelessPhy::update_energy_time_ [protected]
 

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

Referenced by command(), node_off(), node_on(), sendDown(), sendUp(), UpdateIdleEnergy(), and 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(), initialized(), WiredPhy::initialized(), SMAC::initialized(), Mac::initialized(), God::initialized(), RepeaterPhy::recv(), Phy::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:36:09 2004 for NS2.26SourcesOriginal by doxygen 1.3.3