#include <rfid_tag_mac.hpp>
Inheritance diagram for RfidTagMac:
Public Types | |
typedef boost::shared_ptr< RfidTagMac > | RfidTagMacPtr |
Smart pointer that clients should use. | |
Public Member Functions | |
virtual | ~RfidTagMac () |
A destructor. | |
virtual RfidTagMacPtr | thisRfidTagMac () |
Gives this pointer as a RfidTagMac object. | |
virtual SlottedMacPtr | thisSlottedMac () |
Gives this pointer as a SlottedMac object. | |
virtual MacProtocolPtr | thisMacProtocol () |
Gives this pointer as a MacProtocol object. | |
virtual SimulationEndListenerPtr | thisSimulationEndListener () |
Gives this pointer as a SimulationEndListenerPtr object. | |
virtual void | simulationEndHandler () |
The function called when the simulation ends. | |
bool | handleRecvdMacPacket (PacketPtr packet, t_uint sendingLayerIdx) |
Handle a MAC packet the is received. | |
bool | handleRecvdUpperLayerPacket (PacketPtr packet, t_uint sendingLayerIdx) |
Handle a packet received from an upper layer. | |
virtual void | handleChannelBusy (PacketPtr packet) |
This is called when the MAC is scheduled to transmit a packet on the channel but the channel is busy. | |
virtual void | handlePacketSent (PacketPtr packet) |
This is called when the MAC is scheduled to transmit a packet on the channel and it is sent on the channel. | |
Static Public Member Functions | |
static RfidTagMacPtr | create (NodePtr node, RfidTagAppPtr tagApp) |
A factory method to ensure that all objects are created via new since we are using smart pointers. | |
Protected Member Functions | |
RfidTagMac (NodePtr node, RfidTagAppPtr tagApp) | |
A constructor. | |
virtual void | beginSlotEvent () |
The function called when a slot begins. | |
bool | handleRequestPacket (RfidReaderMacDataPtr macData, t_uint sendingLayerIdx) |
Handle the request packet by generating a reply packet and choosing a packet in which to send it. | |
PacketPtr | createReplyPacket (NodeId receiverId) const |
Create a reply packet for the node. | |
void | addGenericHeader (PacketPtr packet, NodeId receiverId) const |
Add a generic header to the packet. | |
bool | packetIsForMe (RfidReaderMacDataPtr macData) const |
Determine if the packet is for me based on the receiver address (i.e., has my address or the broadcast address). | |
bool | isPacketType (PacketPtr packet, RfidTagMacData::Types type) const |
Determine whether the packet is a packet of the given type by looking at it's header. | |
Protected Attributes | |
RfidTagAppPtr | m_tagApp |
A pointer to the application that uses this MAC. | |
Static Protected Attributes | |
static const double | m_TAG_GENERIC_IFS = 15e-6 |
The time which the node defers before transmitting an upper layer packet in a slot. | |
static const double | m_TAG_REPLY_IFS = 20e-6 |
The time which the node defers before transmitting an reply packet in a slot. |
Definition at line 145 of file rfid_tag_mac.hpp.
void RfidTagMac::addGenericHeader | ( | PacketPtr | packet, | |
NodeId | receiverId | |||
) | const [protected] |
Add a generic header to the packet.
packet | a pointer to the packet to which the header will be added. | |
receiverId | the ID of the packet's destination. |
Definition at line 195 of file rfid_tag_mac.cpp.
References RfidTagMacData::create(), Packet::DataTypes_Link, MacProtocol::getNode(), and RfidTagMacData::Types_Generic.
Referenced by handleRecvdUpperLayerPacket().
RfidTagMacPtr RfidTagMac::create | ( | NodePtr | node, | |
RfidTagAppPtr | tagApp | |||
) | [inline, static] |
A factory method to ensure that all objects are created via new
since we are using smart pointers.
node | the node that owns this object. | |
tagApp | a pointer to the application using this MAC. |
Definition at line 317 of file rfid_tag_mac.hpp.
References Simulator::addSimulationEndListener(), Timer::create(), SlottedMacSlotEvent::create(), Simulator::instance(), and RfidTagMac().
PacketPtr RfidTagMac::createReplyPacket | ( | NodeId | receiverId | ) | const [protected] |
Create a reply packet for the node.
receiverId | the ID of the destination for the packet. |
Definition at line 85 of file rfid_tag_mac.cpp.
References Packet::create(), RfidTagMacData::create(), Packet::DataTypes_Link, MacProtocol::getNode(), and RfidTagMacData::Types_Reply.
Referenced by handleRequestPacket().
void RfidTagMac::handleChannelBusy | ( | PacketPtr | packet | ) | [virtual] |
This is called when the MAC is scheduled to transmit a packet on the channel but the channel is busy.
packet | the packet whose transmission was being attempted. |
Implements MacProtocol.
Definition at line 57 of file rfid_tag_mac.cpp.
References isPacketType(), SlottedMac::stopContentionCycle(), RfidTagMacData::Types_Reply, and MacProtocol::unblockUpperQueues().
void RfidTagMac::handlePacketSent | ( | PacketPtr | packet | ) | [virtual] |
This is called when the MAC is scheduled to transmit a packet on the channel and it is sent on the channel.
packet | the packet whose transmission was being attmpted. |
Implements MacProtocol.
Definition at line 64 of file rfid_tag_mac.cpp.
References isPacketType(), SlottedMac::stopContentionCycle(), RfidTagMacData::Types_Generic, and MacProtocol::unblockUpperQueues().
bool RfidTagMac::handleRecvdMacPacket | ( | PacketPtr | packet, | |
t_uint | sendingLayerIdx | |||
) | [virtual] |
Handle a MAC packet the is received.
packet | a pointer to the received packet. | |
sendingLayerIdx | the index of the layer that sent the packet. |
Implements MacProtocol.
Definition at line 141 of file rfid_tag_mac.cpp.
References NodeId::broadcastDestination(), Packet::DataTypes_Link, CommunicationLayer::Directions_Upper, MacProtocol::getNode(), handleRequestPacket(), SlottedMac::m_packetToTransmit, m_tagApp, packetIsForMe(), MacProtocol::sendToLinkLayer(), SlottedMac::stopContentionCycle(), RfidReaderMacData::Types_Ack, RfidReaderMacData::Types_Generic, RfidReaderMacData::Types_Request, RfidReaderMacData::Types_Select, and MacProtocol::unblockUpperQueues().
bool RfidTagMac::handleRecvdUpperLayerPacket | ( | PacketPtr | packet, | |
t_uint | sendingLayerIdx | |||
) | [virtual] |
Handle a packet received from an upper layer.
packet | a pointer to the received packet. | |
sendingLayerIdx | the index of the layer that sent the packet. |
Implements MacProtocol.
Definition at line 205 of file rfid_tag_mac.cpp.
References addGenericHeader(), MacProtocol::blockUpperQueues(), Packet::DataTypes_Application, SlottedMac::inContentionCycle(), LogStreamManager::instance(), LogStreamManager::logDebugItem(), SlottedMac::m_currentSlotNumber, SlottedMac::m_numberOfSlots, SlottedMac::m_packetToTransmit, SlottedMac::m_slotTimer, and SlottedMac::m_txSlotNumber.
bool RfidTagMac::handleRequestPacket | ( | RfidReaderMacDataPtr | macData, | |
t_uint | sendingLayerIdx | |||
) | [protected] |
Handle the request packet by generating a reply packet and choosing a packet in which to send it.
macData | the MAC data from the reader's packet. | |
sendingLayerIdx | the layer from which the packet was received. |
Definition at line 96 of file rfid_tag_mac.cpp.
References createReplyPacket(), MacProtocol::getNode(), Simulator::getRandNumGenerator(), SlottedMac::inContentionCycle(), LogStreamManager::instance(), Simulator::instance(), LogStreamManager::logDebugItem(), SlottedMac::m_currentSlotNumber, SlottedMac::m_numberOfSlots, SlottedMac::m_packetToTransmit, m_tagApp, and SlottedMac::m_txSlotNumber.
Referenced by handleRecvdMacPacket().
bool RfidTagMac::isPacketType | ( | PacketPtr | packet, | |
RfidTagMacData::Types | type | |||
) | const [protected] |
Determine whether the packet is a packet of the given type by looking at it's header.
packet | a pointer to the packet under consideration. | |
type | the type for which we are checking. |
Definition at line 72 of file rfid_tag_mac.cpp.
References Packet::DataTypes_Link.
Referenced by beginSlotEvent(), handleChannelBusy(), and handlePacketSent().
bool RfidTagMac::packetIsForMe | ( | RfidReaderMacDataPtr | macData | ) | const [protected] |
Determine if the packet is for me based on the receiver address (i.e., has my address or the broadcast address).
macData | the MAC header of the packet. |
Definition at line 135 of file rfid_tag_mac.cpp.
References NodeId::broadcastDestination(), and MacProtocol::getNode().
Referenced by handleRecvdMacPacket().
MacProtocolPtr RfidTagMac::thisMacProtocol | ( | ) | [inline, virtual] |
Gives this
pointer as a MacProtocol
object.
This is used to deal with shared_ptr's
, this
, and inheritance.
this
object. Implements MacProtocol.
Definition at line 347 of file rfid_tag_mac.hpp.
RfidTagMacPtr RfidTagMac::thisRfidTagMac | ( | ) | [inline, virtual] |
Gives this
pointer as a RfidTagMac
object.
This is used to deal with shared_ptr's
, this
, and inheritance.
this
object. Definition at line 335 of file rfid_tag_mac.hpp.
SimulationEndListenerPtr RfidTagMac::thisSimulationEndListener | ( | ) | [inline, virtual] |
Gives this
pointer as a SimulationEndListenerPtr
object.
This is used to deal with shared_ptr's
, this
, and inheritance.
this
object. Implements MacProtocol.
Definition at line 353 of file rfid_tag_mac.hpp.
SlottedMacPtr RfidTagMac::thisSlottedMac | ( | ) | [inline, virtual] |
Gives this
pointer as a SlottedMac
object.
This is used to deal with shared_ptr's
, this
, and inheritance.
this
object. Definition at line 341 of file rfid_tag_mac.hpp.