The BasePhyLayer represents the physical layer of a nic. More...
#include <BasePhyLayer.h>
Inherits ChannelAccess, DeciderToPhyInterface, and MacToPhyInterface.
Inherited by PhyLayer, and PhyLayerUWBIR.
Public Member Functions | |
virtual | ~BasePhyLayer () |
virtual void | finish () |
Only calls the deciders finish method. | |
MacToPhyInterface implementation | |
These methods implement the MacToPhyInterface. | |
virtual int | getRadioState () |
Returns the current state the radio is in. | |
virtual simtime_t | setRadioState (int rs) |
Tells the BasePhyLayer to switch to the specified radio state. | |
virtual ChannelState | getChannelState () |
Returns the current state of the channel. | |
virtual int | getPhyHeaderLength () |
Returns the length of the phy header in bits. | |
virtual void | setCurrentRadioChannel (int newRadioChannel) |
Sets the channel currently used by the radio. | |
virtual int | getCurrentRadioChannel () |
Returns the channel currently used by the radio. | |
virtual int | getNbRadioChannels () |
Returns the number of channels available on this radio. | |
DeciderToPhyInterface implementation | |
These methods implement the DeciderToPhyInterface. | |
virtual void | getChannelInfo (simtime_t from, simtime_t to, AirFrameVector &out) |
Fills the passed AirFrameVector with all AirFrames that intersect with the time interval [from, to]. | |
virtual ConstMapping * | getThermalNoise (simtime_t from, simtime_t to) |
Returns a Mapping which defines the thermal noise in the passed time frame (in mW). | |
virtual void | sendControlMsg (cMessage *msg) |
Called by the Decider to send a control message to the MACLayer. | |
virtual void | sendUp (AirFrame *packet, DeciderResult *result) |
Called to send an AirFrame with DeciderResult to the MACLayer. | |
virtual simtime_t | getSimTime () |
Returns the current simulation time. | |
virtual void | cancelScheduledMessage (cMessage *msg) |
Tells the PhyLayer to cancel a scheduled message (AirFrame or ControlMessage). | |
virtual void | rescheduleMessage (cMessage *msg, simtime_t t) |
Tells the PhyLayer to reschedule a message (AirFrame or ControlMessage). | |
virtual void | drawCurrent (double amount, int activity) |
Does nothing. For an actual power supporting phy see "PhyLayerBattery". | |
virtual BaseUtility * | getUtility () |
Returns a pointer to the hosts utility-module. | |
virtual BaseWorldUtility * | getWorldUtility () |
Returns a pointer to the simulations world-utility-module. | |
void | recordScalar (const char *name, double value, const char *unit=NULL) |
Records a double into the scalar result file. | |
Protected Types | |
enum | ProtocolIds { GENERIC = 0 } |
enum | AirFrameStates { START_RECEIVE = 1, RECEIVING, END_RECEIVE } |
The states of the receiving process for AirFrames. More... | |
typedef std::vector < AnalogueModel * > | AnalogueModelList |
Used to store the AnalogueModels to be used as filters. | |
typedef std::map< std::string, cMsgPar > | ParameterMap |
Used at initialisation to pass the parameters to the AnalogueModel and Decider. | |
Protected Member Functions | |
template<class T > | |
T | readPar (const char *parName, const T defaultValue) |
Reads and returns the parameter with the passed name. | |
virtual void | initialize (int stage) |
OMNeT++ initialization function. | |
virtual void | handleMessage (cMessage *msg) |
OMNeT++ handle message function. | |
virtual Radio * | initializeRadio () |
Initializes and returns the radio class to use. | |
virtual AnalogueModel * | getAnalogueModelFromName (std::string name, ParameterMap ¶ms) |
Creates and returns an instance of the AnalogueModel with the specified name. | |
virtual Decider * | getDeciderFromName (std::string name, ParameterMap ¶ms) |
Creates and returns an instance of the Decider with the specified name. | |
virtual AirFrame * | encapsMsg (cPacket *msg) |
This function encapsulates messages from the upper layer into an AirFrame and sets all necessary attributes. | |
virtual void | filterSignal (Signal &s) |
Filters the passed Signal by every registered AnalogueModel. | |
virtual void | finishRadioSwitching () |
Called the moment the simulated switching process of the Radio is finished. | |
virtual int | myProtocolId () |
Returns the identifier of the protocol this phy uses to send messages. | |
virtual bool | isKnownProtocolId (int id) |
Returns true if the protocol with the passed identifier is decodeable by the decider. | |
Handle Messages | |
virtual void | handleAirFrame (cMessage *msg) |
Handles messages received from the channel (probably AirFrames). | |
virtual void | handleUpperMessage (cMessage *msg) |
Handles messages received from the upper layer through the data gate. | |
virtual void | handleUpperControlMessage (cMessage *msg) |
Handles messages received from the upper layer through the control gate. | |
virtual void | handleSelfMessage (cMessage *msg) |
Handles self scheduled messages. | |
virtual void | handleChannelSenseRequest (cMessage *msg) |
Handles reception of a ChannelSenseRequest by forwarding it to the decider and scheduling it to the point in time returned by the decider. | |
void | handleAirFrameFirstReceive (AirFrame *msg) |
Handles incoming AirFrames with the state FIRST_RECEIVE. | |
virtual void | handleAirFrameStartReceive (AirFrame *msg) |
Handles incoming AirFrames with the state START_RECEIVE. | |
virtual void | handleAirFrameReceiving (AirFrame *msg) |
Handles incoming AirFrames with the state RECEIVING. | |
virtual void | handleAirFrameEndReceive (AirFrame *msg) |
Handles incoming AirFrames with the state END_RECEIVE. | |
Send Messages | |
void | sendControlMessageUp (cMessage *msg) |
Sends the passed control message to the upper layer. | |
void | sendMacPktUp (cMessage *pkt) |
Sends the passed MacPkt to the upper layer. | |
void | sendMessageDown (AirFrame *pkt) |
Sends the passed AirFrame to the channel. | |
void | sendSelfMessage (cMessage *msg, simtime_t time) |
Schedule self message to passed point in time. | |
Protected Attributes | |
int | protocolId |
ConstantSimpleConstMapping * | thermalNoise |
Defines the strength of the thermal noise. | |
double | maxTXPower |
The maximum transmission power a message can be send with. | |
double | sensitivity |
The sensitivity describes the minimum strength a signal must have to be received. | |
bool | recordStats |
Stores if tracking of statistics (esp. cOutvectors) is enabled. | |
ChannelInfo | channelInfo |
Channel info keeps track of received AirFrames and provides information about currently active AirFrames at the channel. | |
Radio * | radio |
The state machine storing the current radio state (TX, RX, SLEEP). | |
Decider * | decider |
Pointer to the decider module. | |
AnalogueModelList | analogueModels |
List of the analogue models to use. | |
int | upperGateIn |
The id of the in-data gate from the Mac layer. | |
int | upperGateOut |
The id of the out-data gate to the Mac layer. | |
int | upperControlOut |
The id of the out-control gate to the Mac layer. | |
int | upperControlIn |
The id of the in-control gate from the Mac layer. | |
cMessage * | radioSwitchingOverTimer |
Self message scheduled to the point in time when the switching process of the radio is over. | |
cMessage * | txOverTimer |
Self message scheduled to the point in time when the transmission of an AirFrame is over. | |
int | headerLength |
Stores the length of the phy header in bits. | |
BaseWorldUtility * | world |
Pointer to the World Utility, to obtain some global information. | |
Static Protected Attributes | |
static short | airFramePriority = 10 |
Defines the scheduling priority of AirFrames. | |
Private Member Functions | |
void | getParametersFromXML (cXMLElement *xmlData, ParameterMap &outputMap) |
Utility function. Reads the parameters of a XML element and stores them in the passed ParameterMap reference. | |
void | initializeAnalogueModels (cXMLElement *xmlConfig) |
Initializes the AnalogueModels with the data from the passed XML-config data. | |
void | initializeDecider (cXMLElement *xmlConfig) |
Initializes the Decider with the data from the passed XML-config data. |
The BasePhyLayer represents the physical layer of a nic.
The BasePhyLayer is directly connected to the mac layer via OMNeT channels and is able to send messages to other physical layers through sub-classing from ChannelAcces.
The BasePhyLayer encapsulates two sub modules. The AnalogueModels, which are responsible for simulating the attenuation of received signals and the Decider which provides the main functionality of the physical layer like signal classification (noise or not noise) and demodulation (calculating transmission errors).
The BasePhyLayer itself is responsible for the OMNeT depended parts of the physical layer which are the following:
Module initialization:
Message handling:
The actual evaluation of incoming signals is done by the Decider.
base class ChannelAccess:
base class DeciderToPhyInterface:
base class MacToPhyInterface:
Definition at line 68 of file BasePhyLayer.h.
enum BasePhyLayer::AirFrameStates [protected] |
The states of the receiving process for AirFrames.
START_RECEIVE |
Start of actual receiving process of the AirFrame. |
RECEIVING |
AirFrame is being received. |
END_RECEIVE |
Receiving process over. |
Definition at line 151 of file BasePhyLayer.h.
{ START_RECEIVE = 1, RECEIVING, END_RECEIVE };
BasePhyLayer::~BasePhyLayer | ( | ) | [virtual] |
Free the pointer to the decider and the AnalogueModels and the Radio.
Definition at line 661 of file BasePhyLayer.cc.
References analogueModels, channelInfo, decider, ChannelInfo::getAirFrames(), Radio::getAnalogueModel(), radio, radioSwitchingOverTimer, thermalNoise, and txOverTimer.
{ //get AirFrames from ChannelInfo and delete //(although ChannelInfo normally owns the AirFrames it //is not able to cancel and delete them itself AirFrameVector channel; channelInfo.getAirFrames(0, simTime(), channel); for(AirFrameVector::iterator it = channel.begin(); it != channel.end(); ++it) { cancelAndDelete(*it); } //free timer messages if(txOverTimer) { cancelAndDelete(txOverTimer); } if(radioSwitchingOverTimer) { cancelAndDelete(radioSwitchingOverTimer); } //free thermal noise mapping if(thermalNoise) { delete thermalNoise; } //free Decider if(decider != 0) { delete decider; } /* * get a pointer to the radios RSAM again to avoid deleting it, * it is not created by calling new (BasePhyLayer is not the owner)! */ AnalogueModel* rsamPointer = radio->getAnalogueModel(); //free AnalogueModels for(AnalogueModelList::iterator it = analogueModels.begin(); it != analogueModels.end(); it++) { AnalogueModel* tmp = *it; // do not delete the RSAM, it's not allocated by new! if (tmp == rsamPointer) { rsamPointer = 0; continue; } if(tmp != 0) { delete tmp; } } // free radio if(radio != 0) { delete radio; } }
void BasePhyLayer::cancelScheduledMessage | ( | cMessage * | msg | ) | [virtual] |
Tells the PhyLayer to cancel a scheduled message (AirFrame or ControlMessage).
Used by the Decider if it doesn't need to handle an AirFrame or ControlMessage again anymore.
Definition at line 837 of file BasePhyLayer.cc.
Referenced by rescheduleMessage().
{ if(msg->isScheduled()){ cancelEvent(msg); } else { EV << "Warning: Decider wanted to cancel a scheduled message but message" << " wasn't actually scheduled. Message is: " << msg << endl; } }
void BasePhyLayer::finishRadioSwitching | ( | ) | [protected, virtual] |
Called the moment the simulated switching process of the Radio is finished.
The Radio is set the new RadioState and the MAC Layer is sent a confirmation message.
Reimplemented in PhyLayerBattery, and PhyLayerUWBIR.
Definition at line 732 of file BasePhyLayer.cc.
References Radio::endSwitch(), radio, MacToPhyInterface::RADIO_SWITCHING_OVER, and sendControlMsg().
Referenced by handleSelfMessage(), and setRadioState().
{ radio->endSwitch(simTime()); sendControlMsg(new cMessage("Radio switching over", RADIO_SWITCHING_OVER)); }
AnalogueModel * BasePhyLayer::getAnalogueModelFromName | ( | std::string | name, | |
ParameterMap & | params | |||
) | [protected, virtual] |
Creates and returns an instance of the AnalogueModel with the specified name.
The returned AnalogueModel has to be generated with the "new" command. The BasePhyLayer keeps the ownership of the returned AnalogueModel.
This method is used by the BasePhyLayer during initialisation to load the AnalogueModels which has been specified in the ned file.
This method has to be overridden if you want to be able to load your own AnalogueModels.
Reimplemented in PhyLayer, PhyLayerUWBIR, and SamplePhyLayer.
Definition at line 316 of file BasePhyLayer.cc.
References Radio::getAnalogueModel(), and radio.
Referenced by initializeAnalogueModels().
{ // add default analogue models here // case "RSAM", pointer is valid as long as the radio exists if (name == "RadioStateAnalogueModel") { return radio->getAnalogueModel(); } return 0; }
ChannelState BasePhyLayer::getChannelState | ( | ) | [virtual] |
Returns the current state of the channel.
See ChannelState for details.
Implements MacToPhyInterface.
Definition at line 766 of file BasePhyLayer.cc.
References decider, and Decider::getChannelState().
{ Enter_Method_Silent(); assert(decider); return decider->getChannelState(); }
Decider * BasePhyLayer::getDeciderFromName | ( | std::string | name, | |
ParameterMap & | params | |||
) | [protected, virtual] |
Creates and returns an instance of the Decider with the specified name.
The returned Decider has to be generated with the "new" command. The BasePhyLayer keeps the ownership of the returned Decider.
This method is used by the BasePhyLayer during initialisation to load the Decider which has been specified in the ned file.
This method has to be overridden if you want to be able to load your own Decider.
Reimplemented in PhyLayer, PhyLayerBattery, PhyLayerUWBIR, and SamplePhyLayer.
Definition at line 238 of file BasePhyLayer.cc.
Referenced by initializeDecider().
{
return 0;
}
int BasePhyLayer::getPhyHeaderLength | ( | ) | [virtual] |
Returns the length of the phy header in bits.
Since the MAC layer has to create the signal for a transmission it has to know the total length of the packet and therefore needs the length of the phy header.
Implements MacToPhyInterface.
Definition at line 772 of file BasePhyLayer.cc.
{ Enter_Method_Silent(); return par("headerLength").longValue(); }
int BasePhyLayer::getRadioState | ( | ) | [virtual] |
Returns the current state the radio is in.
See RadioState for possible values.
This method is mainly used by the mac layer.
Implements MacToPhyInterface.
Definition at line 726 of file BasePhyLayer.cc.
References Radio::getCurrentState(), and radio.
{ Enter_Method_Silent(); assert(radio); return radio->getCurrentState(); }
ConstMapping * BasePhyLayer::getThermalNoise | ( | simtime_t | from, | |
simtime_t | to | |||
) | [virtual] |
Returns a Mapping which defines the thermal noise in the passed time frame (in mW).
The implementing class of this method keeps ownership of the Mapping.
This implementation returns a constant mapping with the value of the "thermalNoise" module parameter
Override this method if you want to define a more complex thermal noise.
Definition at line 801 of file BasePhyLayer.cc.
References SimpleConstMapping::initializeArguments(), and thermalNoise.
{ if(thermalNoise) thermalNoise->initializeArguments(Argument(from)); return thermalNoise; }
void BasePhyLayer::handleMessage | ( | cMessage * | msg | ) | [protected, virtual] |
OMNeT++ handle message function.
Classify and forward message to subroutines.
Reimplemented in SamplePhyLayer.
Definition at line 333 of file BasePhyLayer.cc.
References handleAirFrame(), handleSelfMessage(), handleUpperControlMessage(), handleUpperMessage(), upperControlIn, and upperGateIn.
{ //self messages if(msg->isSelfMessage()) { handleSelfMessage(msg); //MacPkts <- MacToPhyControlInfo } else if(msg->getArrivalGateId() == upperGateIn) { handleUpperMessage(msg); //controlmessages } else if(msg->getArrivalGateId() == upperControlIn) { handleUpperControlMessage(msg); //AirFrames } else if(msg->getKind() == AIR_FRAME){ handleAirFrame(msg); //unknown message } else { ev << "Unknown message received." << endl; delete msg; } }
void BasePhyLayer::initialize | ( | int | stage | ) | [protected, virtual] |
OMNeT++ initialization function.
Read simple parameters. Read and parse xml file for decider and analogue models configuration.
Reimplemented in PhyLayerBattery, PhyLayerUWBIR, and SamplePhyLayer.
Definition at line 42 of file BasePhyLayer.cc.
References ChannelAccess::cc, FWMath::dBm2mW(), headerLength, initializeAnalogueModels(), initializeDecider(), initializeRadio(), maxTXPower, radio, MacToPhyInterface::RADIO_SWITCHING_OVER, radioSwitchingOverTimer, recordStats, sensitivity, thermalNoise, DimensionSet::timeDomain, MacToPhyInterface::TX_OVER, txOverTimer, upperControlIn, upperControlOut, upperGateIn, upperGateOut, and world.
{ ChannelAccess::initialize(stage); if (stage == 0) { // if using sendDirect, make sure that messages arrive without delay gate("radioIn")->setDeliverOnReceptionStart(true); //get gate ids upperGateIn = findGate("upperGateIn"); upperGateOut = findGate("upperGateOut"); upperControlOut = findGate("upperControlOut"); upperControlIn = findGate("upperControlIn"); //read simple ned-parameters // - initialize basic parameters if(par("useThermalNoise").boolValue()) { double thermalNoiseVal = FWMath::dBm2mW(par("thermalNoise").doubleValue()); thermalNoise = new ConstantSimpleConstMapping(DimensionSet::timeDomain, thermalNoiseVal); } else { thermalNoise = 0; } headerLength = par("headerLength").longValue(); sensitivity = par("sensitivity").doubleValue(); sensitivity = FWMath::dBm2mW(sensitivity); maxTXPower = par("maxTXPower").doubleValue(); recordStats = par("recordStats").boolValue(); // - initialize radio radio = initializeRadio(); // get pointer to the world module world = FindModule<BaseWorldUtility*>::findGlobalModule(); if (world == NULL) { opp_error("Could not find BaseWorldUtility module"); } if(cc->hasPar("sat") && (sensitivity - FWMath::dBm2mW(cc->par("sat").doubleValue())) < -0.000001) { opp_error("Sensitivity can't be smaller than the " "signal attenuation threshold (sat) in ConnectionManager. " "Please adjust your omnetpp.ini file accordingly."); } // } else if (stage == 1){ //read complex(xml) ned-parameters // - analogue model parameters initializeAnalogueModels(par("analogueModels").xmlValue()); // - decider parameters initializeDecider(par("decider").xmlValue()); //initialise timer messages radioSwitchingOverTimer = new cMessage("radio switching over", RADIO_SWITCHING_OVER); txOverTimer = new cMessage("transmission over", TX_OVER); } }
Radio * BasePhyLayer::initializeRadio | ( | ) | [protected, virtual] |
Initializes and returns the radio class to use.
Can be overridden by sub-classing phy layers to use their own Radio implementations.
Reimplemented in PhyLayerUWBIR.
Definition at line 102 of file BasePhyLayer.cc.
References Radio::createNewRadio(), radio, readPar(), recordStats, Radio::RX, Radio::setSwitchTime(), Radio::SLEEP, and Radio::TX.
Referenced by initialize().
{ int initialRadioState = par("initialRadioState").longValue(); double radioMinAtt = par("radioMinAtt").doubleValue(); double radioMaxAtt = par("radioMaxAtt").doubleValue(); int nbRadioChannels = readPar("nbRadioChannels", 1); int initialRadioChannel = readPar("initialRadioChannel", 0); Radio* radio = Radio::createNewRadio(recordStats, initialRadioState, radioMinAtt, radioMaxAtt, initialRadioChannel, nbRadioChannels); // - switch times to TX simtime_t rxToTX = par("timeRXToTX").doubleValue(); simtime_t sleepToTX = par("timeSleepToTX").doubleValue(); //if no RX to TX defined asume same time as sleep to TX radio->setSwitchTime(Radio::RX, Radio::TX, par("timeRXToTX").doubleValue()); //if no sleep to TX defined asume same time as RX to TX radio->setSwitchTime(Radio::SLEEP, Radio::TX, par("timeSleepToTX").doubleValue()); // - switch times to RX simtime_t txToRX = par("timeTXToRX").doubleValue(); simtime_t sleepToRX = par("timeSleepToRX").doubleValue(); //if no TX to RX defined asume same time as sleep to RX radio->setSwitchTime(Radio::TX, Radio::RX, par("timeTXToRX").doubleValue()); //if no sleep to RX defined asume same time as TX to RX radio->setSwitchTime(Radio::SLEEP, Radio::RX, par("timeSleepToRX").doubleValue()); // - switch times to sleep simtime_t txToSleep = par("timeTXToSleep").doubleValue(); simtime_t rxToSleep = par("timeRXToSleep").doubleValue(); //if no TX to sleep defined asume same time as RX to sleep radio->setSwitchTime(Radio::TX, Radio::SLEEP, par("timeTXToSleep").doubleValue()); //if no RX to sleep defined asume same time as TX to sleep radio->setSwitchTime(Radio::RX, Radio::SLEEP, par("timeRXToSleep").doubleValue()); return radio; }
virtual bool BasePhyLayer::isKnownProtocolId | ( | int | id | ) | [inline, protected, virtual] |
Returns true if the protocol with the passed identifier is decodeable by the decider.
If the protocol with the passed id is not understood by this phy layers decider the according AirFrame is not passed to the it but only is added to channel info to be available as interference to the decider.
Default implementation checks only if the passed id is the same as the one returned by "myProtocolId()".
id | The identifier of the protocol of an AirFrame. |
Definition at line 392 of file BasePhyLayer.h.
References myProtocolId().
Referenced by handleAirFrameStartReceive().
{ return id == myProtocolId(); }
virtual int BasePhyLayer::myProtocolId | ( | ) | [inline, protected, virtual] |
Returns the identifier of the protocol this phy uses to send messages.
Definition at line 375 of file BasePhyLayer.h.
Referenced by PhyLayerUWBIR::encapsMsg(), encapsMsg(), and isKnownProtocolId().
{ return protocolId; }
T BasePhyLayer::readPar | ( | const char * | parName, | |
const T | defaultValue | |||
) | [protected] |
Reads and returns the parameter with the passed name.
If the parameter couldn't be found the value of defaultValue is returned.
parName | - the name of the ned-parameter | |
defaultValue | - the value to be returned if the parameter couldn't be found |
Definition at line 26 of file BasePhyLayer.cc.
Referenced by PhyLayerUWBIR::initializeRadio(), and initializeRadio().
{ if(hasPar(parName)) return par(parName); else return defaultValue; }
void BasePhyLayer::recordScalar | ( | const char * | name, | |
double | value, | |||
const char * | unit = NULL | |||
) |
Records a double into the scalar result file.
Implements the method from DeciderToPhyInterface, method-calls are forwarded to OMNeT-method 'recordScalar'.
Definition at line 863 of file BasePhyLayer.cc.
{ ChannelAccess::recordScalar(name, value, unit); }
void BasePhyLayer::rescheduleMessage | ( | cMessage * | msg, | |
simtime_t | t | |||
) | [virtual] |
Tells the PhyLayer to reschedule a message (AirFrame or ControlMessage).
Used by the Decider if it has to handle an AirFrame or an control message earlier than it has returned to the PhyLayer the last time the Decider handled that message.
Definition at line 846 of file BasePhyLayer.cc.
References cancelScheduledMessage().
{ cancelScheduledMessage(msg); scheduleAt(t, msg); }
void BasePhyLayer::sendControlMsg | ( | cMessage * | msg | ) | [virtual] |
Called by the Decider to send a control message to the MACLayer.
This function can be used to answer a ChannelSenseRequest to the MACLayer
Definition at line 808 of file BasePhyLayer.cc.
References channelInfo, ChannelInfo::isRecording(), sendControlMessageUp(), and ChannelInfo::stopRecording().
Referenced by finishRadioSwitching(), and handleSelfMessage().
{ if(msg->getKind() == CHANNEL_SENSE_REQUEST) { if(channelInfo.isRecording()) { channelInfo.stopRecording(); } } sendControlMessageUp(msg); }
void BasePhyLayer::sendUp | ( | AirFrame * | packet, | |
DeciderResult * | result | |||
) | [virtual] |
Called to send an AirFrame with DeciderResult to the MACLayer.
When a packet is completely received and not noise, the Decider call this function to send the packet together with the corresponding DeciderResult up to MACLayer
Definition at line 817 of file BasePhyLayer.cc.
References sendMacPktUp().
{ coreEV << "Decapsulating MacPacket from Airframe with ID " << frame->getId() << " and sending it up to MAC." << endl; cMessage* packet = frame->decapsulate(); assert(packet); PhyToMacControlInfo* ctrlInfo = new PhyToMacControlInfo(result); packet->setControlInfo(ctrlInfo); sendMacPktUp(packet); }
simtime_t BasePhyLayer::setRadioState | ( | int | rs | ) | [virtual] |
Tells the BasePhyLayer to switch to the specified radio state.
The switching process can take some time depending on the specified switching times in the ned file.
Implements MacToPhyInterface.
Reimplemented in PhyLayerBattery, and PhyLayerUWBIR.
Definition at line 738 of file BasePhyLayer.cc.
References finishRadioSwitching(), radio, radioSwitchingOverTimer, sendSelfMessage(), Radio::switchTo(), and txOverTimer.
{ Enter_Method_Silent(); assert(radio); if(txOverTimer && txOverTimer->isScheduled()) { opp_warning("Switched radio while sending an AirFrame. The effects this would have on the transmission are not simulated by the BasePhyLayer!"); } simtime_t switchTime = radio->switchTo(rs, simTime()); //invalid switch time, we are probably already switching if(switchTime < 0) return switchTime; // if switching is done in exactly zero-time no extra self-message is scheduled if (switchTime == 0.0) { // TODO: in case of zero-time-switch, send no control-message to mac! // maybe call a method finishRadioSwitchingSilent() finishRadioSwitching(); } else { sendSelfMessage(radioSwitchingOverTimer, simTime() + switchTime); } return switchTime; }
short BasePhyLayer::airFramePriority = 10 [static, protected] |
Defines the scheduling priority of AirFrames.
AirFrames use a slightly higher priority than normal to ensure channel consistency. This means that before anything else happens at a time point t every AirFrame which ended at t has been removed and every AirFrame started at t has been added to the channel.
An example where this matters is a ChannelSenseRequest which ends at the same time as an AirFrame starts (or ends). Depending on which message is handled first the result of ChannelSenseRequest would differ.
Definition at line 91 of file BasePhyLayer.h.
Referenced by PhyLayerUWBIR::encapsMsg(), and encapsMsg().