#include <uan-phy.h>
Inheritance diagram for UanPhy:
Public Types | |
enum | TransState { IDLE, RX, TX, CHIDLE, CHBUSY } |
Enumeration used to describe MAC states. CHIDLE and CHBUSY are used to report CS events. | |
enum | TransEvent { ECOLL, EERR, ENORX, EOK } |
Packet reception events. Not currently used by anybody. | |
Public Member Functions | |
UanPhy (void) | |
Constructor creates UanPhy class. | |
virtual void | recv (Packet *p, Handler *h) |
Standard NS2 receive function. Routes packets to rx or tx for further handling. | |
virtual void | sendDown (Packet *p) |
Puts p out on the channel. | |
virtual int | sendUp (Packet *p) |
Notifies MAC layer of received packet p. | |
virtual int | command (int argc, const char *const *argv) |
bool | initialized () |
Returns true if the Phy is correctly initialized. | |
bool | isIdle (bool cs=false) |
void | setMac (UanMac *m) |
Sets a link to the MAC layer. | |
double | txtime (Packet *p) |
Returns transmit time of packet using CMN_HDR(p)->size() instead of precomputed txtime. | |
double | txtime (int bytes) |
Returns transmit time of bytes number of bytes. | |
double | getAntennaZ () |
Stupid hack to keep non UAN channels from erroring out. Antenna is not used in UAN classes. | |
bool | csIdle () |
Returns true if channel is sensed to be idle. Bases decision off of combined strength of packets. | |
double | getFreq () |
Returns transmit frequency of this interface. | |
double | getTxPower () |
Returns the output power of this interface. | |
virtual TransEvent | rx (Packet *p) |
Logs an incoming packet. | |
virtual TransEvent | tx (Packet *p) |
Transmit packet p This method sends a packet out on the channel. If a packet is currently being received when this method is called, it will drop the incoming packet and note an ALOHA DROP in the trace file. | |
virtual double | pktNoise (void) |
Returns combined strength (assuming constructive energy) of all packets passing node. | |
TransState | getState (void) |
Returns current interface state (TX, RX, IDLE). | |
double | getColTime (void) |
Return maximum interference time that packets may overlap and still be decoded correctly. | |
void | setColTime (double c) |
Sets maximum time packets may overlap and still be decoded correctly. | |
Protected Member Functions | |
virtual void | debugf (char *fmt,...) |
Method for outputting debugging information on stderr. | |
virtual void | powerTrace (void) |
Sends current joules used and state information to power trace file. | |
virtual void | updatePower (void) |
Updates the calculation of joules used until now. | |
void | trace (char *fmt,...) |
Sends fmt to trace file. Uses printf format specifiers. | |
void | setState (TransState newState) |
Sets state of PHY to newState, also notifies MAC of state change. | |
double | getChBusyTime (void) |
Returns the time until the last packet which has arrived at this node will finish passing this node. | |
Static Protected Member Functions | |
static void | rxHandler (void *t) |
Handler called by rxTimer. t should point to this. | |
static void | txHandler (void *t) |
Handler called by txTimer. t should point to this. | |
Protected Attributes | |
UanMac * | mac |
Link to the MAC layer. | |
Modulation * | modulation |
Not used. | |
Antenna * | ant_ |
Unused ant pointer. Only here to keep non UAN channel from erroring. | |
double | txPower |
Output power in dB. | |
double | txFreq |
Output frequency in kHz. | |
double | rxThresh |
Threshold SINR in dB for packet reception and detection. | |
double | csThresh |
Threshold dB for sensing channel to be busy or idle. | |
double | txConsume |
mW consumed while transmitting. | |
double | rxConsume |
mW consumed while receiving | |
double | idleConsume |
mW consumed while idle | |
double | powerTime |
time in seconds when last power calculation was done. | |
double | joulesUsed |
joules used at time when last power calculation was done. | |
int | tracePower |
Boolean (int only because used in bind), wether power should be traced. | |
Trace * | et |
Trace target setup with log-target command from TCL. | |
double | colTime |
Time to allow packets to overlap before signalling a collision. | |
bool | collision |
True if packet currently being received should be dropped due to a collision. | |
UanEventTimer * | rxTimer |
Timer used to time when a packet currently being received should finish. | |
UanEventTimer * | txTimer |
Timer used to measure when an outgoing packet will finish transmitting. | |
Packet * | pktRx |
Pointer to packet currently being received. | |
TransState | state |
Current State (RX/TX/IDLE) of this PHY. | |
std::list< PacketInfo * > | pktList |
List of all packets currently crossing the hydraphone. | |
PktHandler * | pktHandler |
Pointer to helper class that removes packets from pktList when they are finished passing this node. | |
Friends | |
class | PktHandler |
Structure: In the UAN framework, the PHY class handles collisions and only sends complete incoming packets to the MAC layer. In order for the MAC to make decisions based upon PHY state, the PHY calls the MAC with state transition information (i.e. RX, TX, IDLE).
This PHY layer simply handles collision conditions. Collision decisions are based upon SNR information received from the channel.
This class is also responsible for tracing power events. Currently power events are traced in the following format: P <time> <state name>=""> <total joules="" used="" in="" the="" sim="" until="" this="" time>="">
int UanPhy::command | ( | int | argc, | |
const char *const * | argv | |||
) | [virtual] |
Standard NS2 command function The only special command handled here is the log-target or tracetarget command. This command specifies and event tracer used for tracing power events.
bool UanPhy::isIdle | ( | bool | cs = false |
) |
Returns true if in idle state. If CS is true, then channel state information only perceptible if carrier sensing is possible (Not possible with the WHOI MicroModem)
UanPhy::TransEvent UanPhy::rx | ( | Packet * | p | ) | [virtual] |
Logs an incoming packet.
This method starts reception of packet p. It logs this packet to be used in future interference calculations and decides if the packet is strong enough to be decoded.
Reimplemented in UanPhyBhpFsk.