#include <physical_layer.hpp>
Inheritance diagram for PhysicalLayer:
Public Types | |
typedef boost::shared_ptr< PhysicalLayer > | PhysicalLayerPtr |
Smart pointer that clients should use. | |
Public Member Functions | |
virtual | ~PhysicalLayer () |
A destructor A virtual destructor is recommended since the class has virtual functions. | |
virtual PhysicalLayerPtr | thisPhysicalLayer ()=0 |
Gives this pointer as a PhysicalLayer object. | |
void | setWirelessChannelManager (WirelessChannelManagerPtr wirelessChannelManager) |
Add the channel manager. | |
bool | recvPendingSignal (WirelessCommSignalPtr signal, double recvdSignalStrength) |
Handle the successfully received signal. | |
virtual bool | sendSignal (WirelessCommSignalPtr signal) |
Send a wireless signal on the channel. | |
bool | isTransmitting () const |
Determine if this layer is currently transmitting a signal. | |
void | setSignalSendingDelay (SimTime signalSendingDelay) |
Set the delay for how long it takes before a signal is transmitted on the channel. | |
SimTime | getSignalSendingDelay () const |
Get the delay for how long it takes to send a signal on the channel. | |
bool | recvFromLayer (CommunicationLayer::Directions direction, PacketPtr packet, t_uint sendingLayerIdx) |
Receives a packet from a sending layer. | |
Location | getLocation () const |
Return the geographic location of this physical layer. | |
void | addSignal (WirelessCommSignalPtr signal, double signalStrength) |
Add a signal currently being received and its computed signal strength. | |
void | removeSignal (WirelessCommSignalPtr signal) |
Remove a signal from the signals currently being received by this object. | |
bool | pendingSignalIsWeak () |
Determine if the currently pending signal is still sufficiently strong to be captured at this object. | |
bool | captureSignal (double signalStrength) const |
Determine whether of not a given signal is strong enough to be captured at this object. | |
double | getCulmulativeSignalStrength () const |
Return the total signal strength of all signals currently being received by this object. | |
double | getNoiseFloor () const |
Return the noise floor for the radio. | |
void | setPendingSignal (WirelessCommSignalPtr signal) |
Set a signal as the signal which would be received if it were to end right now. | |
void | setPendingSignalError (bool hasError) |
Set whether or not the currently pending signal will have an error when/if received. | |
bool | getPendingSignalError () const |
Get whether or not the currently pending signal will have an error upon reception. | |
ConstWirelessCommSignalPtr | getPendingSignal () const |
Get a pointer to the signal which would be received if it were to end right now. | |
double | getPendingSignalStrength () |
Get the signal strength of the signal which would be received if it were to end right now. | |
double | getPendingSignalSinr () |
Get the SINR of the signal which would be received if it were to end right now. | |
void | resetPendingSignal () |
Reset this object such that there is no currently pending signal which is strong enough to receive right now. | |
void | resetRecvSignals () |
Reset this object such that there are no signals currently pending. | |
bool | channelCarrierSensedBusy () const |
Determine whether the channel is carrier sensed busy. | |
void | setCurrentTxPower (double txPower) |
Set the current transmit power for the physical layer. | |
double | getCurrentTxPower () const |
Get the current transmit power in watts. | |
double | getMaxTxPower () const |
Get the maximum transmit power in watts. | |
void | setRxThreshold (double rxThreshold) |
Set the power threshold for receiving a packet. | |
double | getRxThreshold () const |
Get the power threshold for receiving a packet. | |
void | setCsThreshold (double csThreshold) |
Set the power threshold for carrier sensing a channel busy. | |
double | getCsThreshold () const |
Get the power threshold for carrier sensing a channel busy. | |
void | setCaptureThreshold (double captureThreshold) |
Set the capture threshold for considering a SINR sufficiently strong. | |
double | getCaptureThreshold () const |
Get the capture threshold for considering a SINR sufficiently strong. | |
void | setMinimumSignalStrength (double minimumSignalStrength) |
Set the minimum signal strength for considering a signal stronger than thermal noise. | |
double | getMinimumSignalStrength () const |
Get the minimum signal strength for considering a signal stronger than thermal noise. | |
void | setDataRate (double dataRate) |
Set the current data rate in bits per second. | |
double | getDataRate () const |
Get the current data rate. | |
void | setBandwidth (double bandwidth) |
Set the current radio bandwidth in Hz. | |
double | getBandwidth () const |
Get the current radio bandwidth in Hz. | |
double | getGain () const |
Get the gain of the antenna. | |
double | getWavelength () const |
Get the wavelength of the antenna based on the current bandwidth. | |
CommunicationLayer::Types | getLayerType () const |
Get the layer type for an object. | |
Protected Member Functions | |
PhysicalLayer (NodePtr node) | |
A constructor This is protected to ensure that all objects are created via new since we are using smart pointers. | |
virtual void | recvdErrorFreeSignal (WirelessCommSignalPtr signal, double recvdSignalStrength) |
This function is called when an error free signal is received, just before its packet is passed to the upper layer. | |
void | setMaxTxPower (double txPower) |
Set the maximum transmit power for the physical layer. | |
bool | scheduleSignal (WirelessCommSignalPtr signal) |
Schedule the signal to be received by the channel manager. | |
Protected Attributes | |
WirelessChannelManagerPtr | m_wirelessChannelManagerPtr |
The channel manager being used by this object. | |
Friends | |
class | SignalRecvEvent |
Definition at line 22 of file physical_layer.hpp.
void PhysicalLayer::addSignal | ( | WirelessCommSignalPtr | signal, | |
double | signalStrength | |||
) |
Add a signal currently being received and its computed signal strength.
signal | a pointer to the signal to add. | |
signalStrength | the strength of the signal. |
Definition at line 144 of file physical_layer.cpp.
References getMinimumSignalStrength().
bool PhysicalLayer::captureSignal | ( | double | signalStrength | ) | const |
Determine whether of not a given signal is strong enough to be captured at this object.
signalStrength | the strength of the signal at this receiver. This signal should not have been added (via addSignal) at the time this function is called. |
Definition at line 202 of file physical_layer.cpp.
References getCaptureThreshold(), getCsThreshold(), getCulmulativeSignalStrength(), CommunicationLayer::getNodeId(), getNoiseFloor(), getRxThreshold(), LogStreamManager::instance(), and LogStreamManager::logDebugItem().
bool PhysicalLayer::channelCarrierSensedBusy | ( | ) | const |
Determine whether the channel is carrier sensed busy.
Definition at line 284 of file physical_layer.cpp.
References getCsThreshold(), and getCulmulativeSignalStrength().
double PhysicalLayer::getBandwidth | ( | ) | const [inline] |
Get the current radio bandwidth in Hz.
Definition at line 617 of file physical_layer.hpp.
Referenced by getNoiseFloor().
double PhysicalLayer::getCaptureThreshold | ( | ) | const [inline] |
Get the capture threshold for considering a SINR sufficiently strong.
Definition at line 583 of file physical_layer.hpp.
Referenced by captureSignal(), and pendingSignalIsWeak().
double PhysicalLayer::getCsThreshold | ( | ) | const [inline] |
Get the power threshold for carrier sensing a channel busy.
Definition at line 572 of file physical_layer.hpp.
Referenced by captureSignal(), and channelCarrierSensedBusy().
double PhysicalLayer::getCulmulativeSignalStrength | ( | ) | const |
Return the total signal strength of all signals currently being received by this object.
Definition at line 235 of file physical_layer.cpp.
Referenced by captureSignal(), channelCarrierSensedBusy(), and getPendingSignalSinr().
double PhysicalLayer::getCurrentTxPower | ( | ) | const [inline] |
Get the current transmit power in watts.
Definition at line 538 of file physical_layer.hpp.
double PhysicalLayer::getDataRate | ( | ) | const [inline] |
Get the current data rate.
Definition at line 606 of file physical_layer.hpp.
Referenced by recvFromLayer().
double PhysicalLayer::getGain | ( | ) | const [inline] |
Get the gain of the antenna.
Definition at line 628 of file physical_layer.hpp.
Referenced by TwoRay::getRecvdStrength(), FreeSpace::getRecvdStrength(), and recvFromLayer().
CommunicationLayer::Types PhysicalLayer::getLayerType | ( | ) | const [inline, virtual] |
Get the layer type for an object.
Implements CommunicationLayer.
Definition at line 660 of file physical_layer.hpp.
References CommunicationLayer::Types_Physical.
Referenced by recvPendingSignal().
Location PhysicalLayer::getLocation | ( | ) | const |
Return the geographic location of this physical layer.
This is needed to compute received signal strength.
Definition at line 290 of file physical_layer.cpp.
References CommunicationLayer::getNode().
Referenced by TwoRay::getRecvdStrength(), FreeSpace::getRecvdStrength(), and Channel::propagationDelay().
double PhysicalLayer::getMaxTxPower | ( | ) | const [inline] |
Get the maximum transmit power in watts.
Definition at line 550 of file physical_layer.hpp.
double PhysicalLayer::getMinimumSignalStrength | ( | ) | const [inline] |
Get the minimum signal strength for considering a signal stronger than thermal noise.
Definition at line 595 of file physical_layer.hpp.
Referenced by addSignal().
double PhysicalLayer::getNoiseFloor | ( | ) | const [inline] |
Return the noise floor for the radio.
Definition at line 622 of file physical_layer.hpp.
References getBandwidth().
Referenced by captureSignal(), and getPendingSignalSinr().
ConstWirelessCommSignalPtr PhysicalLayer::getPendingSignal | ( | ) | const |
Get a pointer to the signal which would be received if it were to end right now.
Definition at line 252 of file physical_layer.cpp.
bool PhysicalLayer::getPendingSignalError | ( | ) | const [inline] |
Get whether or not the currently pending signal will have an error upon reception.
Definition at line 639 of file physical_layer.hpp.
double PhysicalLayer::getPendingSignalSinr | ( | ) |
Get the SINR of the signal which would be received if it were to end right now.
Definition at line 171 of file physical_layer.cpp.
References getCulmulativeSignalStrength(), getNoiseFloor(), and getPendingSignalStrength().
Referenced by pendingSignalIsWeak().
double PhysicalLayer::getPendingSignalStrength | ( | ) |
Get the signal strength of the signal which would be received if it were to end right now.
Definition at line 257 of file physical_layer.cpp.
Referenced by getPendingSignalSinr(), and pendingSignalIsWeak().
double PhysicalLayer::getRxThreshold | ( | ) | const [inline] |
Get the power threshold for receiving a packet.
Definition at line 561 of file physical_layer.hpp.
Referenced by captureSignal(), and pendingSignalIsWeak().
SimTime PhysicalLayer::getSignalSendingDelay | ( | ) | const [inline] |
Get the delay for how long it takes to send a signal on the channel.
Definition at line 655 of file physical_layer.hpp.
Referenced by scheduleSignal().
double PhysicalLayer::getWavelength | ( | ) | const [inline] |
Get the wavelength of the antenna based on the current bandwidth.
Definition at line 644 of file physical_layer.hpp.
References SPEED_OF_LIGHT.
Referenced by recvFromLayer().
bool PhysicalLayer::isTransmitting | ( | ) | const |
Determine if this layer is currently transmitting a signal.
Definition at line 123 of file physical_layer.cpp.
bool PhysicalLayer::pendingSignalIsWeak | ( | ) |
Determine if the currently pending signal is still sufficiently strong to be captured at this object.
Definition at line 190 of file physical_layer.cpp.
References getCaptureThreshold(), getPendingSignalSinr(), getPendingSignalStrength(), and getRxThreshold().
void PhysicalLayer::recvdErrorFreeSignal | ( | WirelessCommSignalPtr | signal, | |
double | recvdSignalStrength | |||
) | [protected, virtual] |
This function is called when an error free signal is received, just before its packet is passed to the upper layer.
This gives subclasses an opportunity to adjust their state in response to the signal reception if need be.
signal | the signal that was successfully received. | |
recvdSignalStrength | the strength at which the signal was received. |
Reimplemented in RfidTagPhy.
Definition at line 84 of file physical_layer.cpp.
Referenced by recvPendingSignal().
bool PhysicalLayer::recvFromLayer | ( | CommunicationLayer::Directions | direction, | |
PacketPtr | packet, | |||
t_uint | sendingLayerIdx | |||
) | [virtual] |
Receives a packet from a sending layer.
direction | the direction the packet was sent. | |
packet | a pointer to the received packet. | |
sendingLayerIdx | the index of the layer that sent the packet. |
Reimplemented from CommunicationLayer.
Definition at line 90 of file physical_layer.cpp.
References WirelessCommSignal::create(), CommunicationLayer::Directions_Upper, getDataRate(), getGain(), CommunicationLayer::getNode(), getWavelength(), LogStreamManager::instance(), LogStreamManager::logDebugItem(), powerToDecibels(), and sendSignal().
bool PhysicalLayer::recvPendingSignal | ( | WirelessCommSignalPtr | signal, | |
double | recvdSignalStrength | |||
) |
Handle the successfully received signal.
The caller of this function should ensure that a deep copy of the signal is being passed to this object since the signal may be modified locally and changes should not affect the signal globally.
signal | a pointer to a deep copy of the signal being received. | |
recvdSignalStrength | the strength of the signal at the receiver. |
Definition at line 65 of file physical_layer.cpp.
References CommunicationLayer::Directions_Upper, getLayerType(), CommunicationLayer::getNodeId(), LogStreamManager::instance(), LogStreamManager::logPktRecvItem(), recvdErrorFreeSignal(), and CommunicationLayer::sendToLayer().
void PhysicalLayer::removeSignal | ( | WirelessCommSignalPtr | signal | ) |
Remove a signal from the signals currently being received by this object.
signal | a pointer to the signal to remove. |
Definition at line 163 of file physical_layer.cpp.
void PhysicalLayer::resetPendingSignal | ( | ) |
Reset this object such that there is no currently pending signal which is strong enough to receive right now.
Definition at line 272 of file physical_layer.cpp.
Referenced by resetRecvSignals().
void PhysicalLayer::resetRecvSignals | ( | ) |
Reset this object such that there are no signals currently pending.
Definition at line 278 of file physical_layer.cpp.
References resetPendingSignal().
bool PhysicalLayer::scheduleSignal | ( | WirelessCommSignalPtr | signal | ) | [protected] |
Schedule the signal to be received by the channel manager.
signal | the signal to be scheduled. |
Definition at line 134 of file physical_layer.cpp.
References CommunicationLayer::getNode(), getSignalSendingDelay(), m_wirelessChannelManagerPtr, SignalRecvEvent, and thisPhysicalLayer().
Referenced by sendSignal().
bool PhysicalLayer::sendSignal | ( | WirelessCommSignalPtr | signal | ) | [virtual] |
Send a wireless signal on the channel.
signal | the signal to send. |
Definition at line 129 of file physical_layer.cpp.
References scheduleSignal().
Referenced by recvFromLayer().
void PhysicalLayer::setBandwidth | ( | double | bandwidth | ) | [inline] |
Set the current radio bandwidth in Hz.
bandwidth | the new radio bandwidth. |
Definition at line 611 of file physical_layer.hpp.
void PhysicalLayer::setCaptureThreshold | ( | double | captureThreshold | ) | [inline] |
Set the capture threshold for considering a SINR sufficiently strong.
captureThreshold | the new capture threshold. |
Definition at line 577 of file physical_layer.hpp.
void PhysicalLayer::setCsThreshold | ( | double | csThreshold | ) | [inline] |
Set the power threshold for carrier sensing a channel busy.
csThreshold | the new carrier sense power threshold. |
Definition at line 566 of file physical_layer.hpp.
Referenced by RfidReaderPhy::RfidReaderPhy().
void PhysicalLayer::setCurrentTxPower | ( | double | txPower | ) | [inline] |
Set the current transmit power for the physical layer.
txPower | the new power level in watts. Must be greater than zero. |
Definition at line 532 of file physical_layer.hpp.
Referenced by RfidTagPhy::recvdErrorFreeSignal().
void PhysicalLayer::setDataRate | ( | double | dataRate | ) | [inline] |
Set the current data rate in bits per second.
dataRate | the new data rate. |
Definition at line 600 of file physical_layer.hpp.
void PhysicalLayer::setMaxTxPower | ( | double | txPower | ) | [inline, protected] |
Set the maximum transmit power for the physical layer.
If the current transmit power level is less than the new max value, then it will be set to the new max value.
txPower | the new maximum power level in watts. Must be greater than zero. |
Definition at line 543 of file physical_layer.hpp.
void PhysicalLayer::setMinimumSignalStrength | ( | double | minimumSignalStrength | ) | [inline] |
Set the minimum signal strength for considering a signal stronger than thermal noise.
minimumSignalStrength | the new minimum signal strength. |
Definition at line 588 of file physical_layer.hpp.
void PhysicalLayer::setPendingSignal | ( | WirelessCommSignalPtr | signal | ) |
Set a signal as the signal which would be received if it were to end right now.
signal | a pointer to the signal. |
Definition at line 246 of file physical_layer.cpp.
void PhysicalLayer::setPendingSignalError | ( | bool | hasError | ) | [inline] |
Set whether or not the currently pending signal will have an error when/if received.
hasError | true if the signal will have an error. |
Definition at line 634 of file physical_layer.hpp.
void PhysicalLayer::setRxThreshold | ( | double | rxThreshold | ) | [inline] |
Set the power threshold for receiving a packet.
rxThreshold | the new receive power threshold. |
Definition at line 555 of file physical_layer.hpp.
Referenced by RfidReaderPhy::RfidReaderPhy().
void PhysicalLayer::setSignalSendingDelay | ( | SimTime | signalSendingDelay | ) | [inline] |
Set the delay for how long it takes before a signal is transmitted on the channel.
signalSendingDelay | the delay from the time a signal is sent by this object until it actually reaches the channel. |
Definition at line 649 of file physical_layer.hpp.
void PhysicalLayer::setWirelessChannelManager | ( | WirelessChannelManagerPtr | wirelessChannelManager | ) | [inline] |
Add the channel manager.
wirelessChannelManager | a pointer to the channel manager being added. |
Definition at line 526 of file physical_layer.hpp.
References m_wirelessChannelManagerPtr.
virtual PhysicalLayerPtr PhysicalLayer::thisPhysicalLayer | ( | ) | [pure virtual] |
Gives this
pointer as a PhysicalLayer
object.
This is used to deal with shared_ptr's
, this
, and inheritance.
this
object. Implemented in RfidReaderPhy, and RfidTagPhy.
Referenced by scheduleSignal().
WirelessChannelManagerPtr PhysicalLayer::m_wirelessChannelManagerPtr [protected] |
The channel manager being used by this object.
Definition at line 368 of file physical_layer.hpp.
Referenced by RfidTagPhy::resetAllListenersChannel(), RfidReaderPhy::resetAllSendersChannel(), RfidReaderPhy::resetRegularChannel(), RfidTagPhy::resetSendingChannel(), RfidReaderPhy::RfidReaderPhy(), RfidTagPhy::RfidTagPhy(), scheduleSignal(), RfidTagPhy::setAllListenersChannel(), RfidReaderPhy::setAllSendersChannel(), RfidReaderPhy::setRegularChannel(), RfidTagPhy::setSendingChannel(), setWirelessChannelManager(), RfidReaderPhy::~RfidReaderPhy(), and RfidTagPhy::~RfidTagPhy().