mrcl_wireless-phy.h

00001 /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*-  *
00002  *
00003  * Copyright (c) 1997 Regents of the University of California.
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  * 3. All advertising materials mentioning features or use of this software
00015  *    must display the following acknowledgement:
00016  *      This product includes software developed by the Computer Systems
00017  *      Engineering Group at Lawrence Berkeley Laboratory.
00018  * 4. Neither the name of the University nor of the Laboratory may be used
00019  *    to endorse or promote products derived from this software without
00020  *    specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00023  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00025  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00026  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00028  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00031  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  *
00034  * $Header: /nfs/jade/vint/CVSROOT/ns-2/mac/wireless-phy.h,v 1.14 2005/06/13 17:50:41 haldar Exp $
00035  *
00036  * Ported from CMU/Monarch's code, nov'98 -Padma Haldar.
00037  *
00038  * wireless-phy.h
00039  * -- a SharedMedia network interface
00040  */
00041 
00042 #ifndef ns_MrclWirelessPhy_h
00043 #define ns_MrclWirelessPhy_h
00044 
00045 #include <modulation.h>
00046 #include <omni-antenna.h>
00047 #include <phy.h>
00048 //#include "mobilenode.h"
00049 #include <timer-handler.h>
00050 
00051 #include "mrcl_propagation.h"
00052 
00053 
00054 
00055 class Phy;
00056 class MrclPropagation;
00057 class MrclWirelessPhy;
00058 
00059 class MrclSleep_Timer : public TimerHandler {
00060  public:
00061         MrclSleep_Timer(MrclWirelessPhy *a) : TimerHandler() { a_ = a; }
00062  protected:
00063         virtual void expire(Event *e);
00064         MrclWirelessPhy *a_;
00065 };
00066 
00067 //
00068 class MrclWirelessPhy : public Phy {
00069 public:
00070         MrclWirelessPhy();
00071         
00072         void sendDown(Packet *p);
00073         int sendUp(Packet *p);
00074         
00075         inline double getL() const {return L_;}
00076         inline double getLambda() const {return lambda_;}
00077         inline Node* node(void) const { return node_; }
00078         inline double getPtconsume() { return Pt_consume_; }
00079 
00080         double getDist(double Pr, double Pt, double Gt, double Gr, double hr,
00081                        double ht, double L, double lambda);
00082   
00083         virtual int command(int argc, const char*const* argv);
00084         virtual void dump(void) const;
00085         
00086         //void setnode (MobileNode *node) { node_ = node; }
00087         void node_on();
00088         void node_off();        
00089 
00090         /* -NEW- */
00091         inline double getAntennaZ() { return ant_->getZ(); }
00092         inline double getPt() { return Pt_; }
00093         inline double getRXThresh() { return RXThresh_; }
00094         inline double getCSThresh() { return CSThresh_; }
00095         inline double getFreq() { return freq_; }
00096         /* End -NEW- */
00097 
00098         void node_sleep();
00099         void node_wakeup();
00100         inline bool& Is_node_on() { return node_on_; }
00101         inline bool Is_sleeping() { if (status_==SLEEP) return(1); else return(0); }
00102 
00103 protected:
00104         double Pt_;             // transmitted signal power (W)
00105         double Pt_consume_;     // power consumption for transmission (W)
00106         double Pr_consume_;     // power consumption for reception (W)
00107         double P_idle_;         // idle power consumption (W)
00108         double P_sleep_;        // sleep power consumption (W)
00109         double P_transition_;   // power consumed when transiting from SLEEP mode to IDLE mode and vice versa.
00110         double T_transition_;   // time period to transit from SLEEP mode to IDLE mode and vice versa.
00111 //
00112 
00113         double last_send_time_; // the last time the node sends somthing.
00114         double channel_idle_time_;      // channel idle time.
00115         double update_energy_time_;     // the last time we update energy.
00116 
00117         double freq_;           // frequency
00118         double lambda_;         // wavelength (m)
00119         double L_;              // system loss factor
00120   
00121         double RXThresh_;       // receive power threshold (W)
00122         double CSThresh_;       // carrier sense threshold (W)
00123         double CPThresh_;       // capture threshold (db)
00124   
00125         Antenna *ant_;
00126         DeiPropagation* propagation_;   // Propagation Model
00127         Modulation *modulation_;        // Modulation Schem
00128 
00129         // Why phy has a node_ and this guy has it all over again??
00130 //      MobileNode* node_;              // Mobile Node to which interface is attached .
00131 
00132         enum ChannelStatus { SLEEP, IDLE, RECV, SEND }; 
00133         bool node_on_; // on-off status of this node
00134         MrclSleep_Timer sleep_timer_;
00135         int status_;
00136 
00137 private:
00138         inline int initialized() {
00139                 return (uptarget_ && downtarget_ && propagation_);
00140         }
00141         void UpdateIdleEnergy();
00142         void UpdateSleepEnergy();
00143 
00144         // Convenience method
00145         EnergyModel* em() { return (NULL); }
00146 
00147         friend class MrclSleep_Timer;
00148 
00149 };
00150 
00151 #endif /* !ns_MrclWirelessPhy_h */

Generated on Wed Nov 26 15:47:28 2008 for NS-MIRACLE library by  doxygen 1.5.2