#include <rfid_reader_mac.hpp>
Inheritance diagram for RfidReaderMac:

Public Types | |
|
typedef boost::shared_ptr< RfidReaderMac > | RfidReaderMacPtr |
| Smart pointer that clients should use. | |
Public Member Functions | |
| virtual | ~RfidReaderMac () |
| A destructor. | |
| virtual RfidReaderMacPtr | thisRfidReaderMac () |
Gives this pointer as a RfidReaderMac 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 that 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 RfidReaderMacPtr | create (NodePtr node, RfidReaderAppPtr readerApp) |
A factory method to ensure that all objects are created via new since we are using smart pointers. | |
Protected Member Functions | |
| RfidReaderMac (NodePtr node, RfidReaderAppPtr readerApp) | |
| A constructor. | |
| virtual void | beginSlotEvent () |
| The function called when a slot begins. | |
| virtual void | endRequestCycleEvent () |
| The function called when a request cycle ends. | |
| PacketPtr | createRequestPacket () const |
| Create a request packet for the node. | |
| PacketPtr | createAckPacket (NodeId destination) const |
| Create a acknowledgement packet for the node. | |
| void | addGenericHeader (PacketPtr packet, NodeId receiverId) const |
| Add a generic header to the packet. | |
| void | addSelectHeader (PacketPtr packet, NodeId receiverId) const |
Add a SELECT header to the packet. | |
| bool | packetIsForMe (RfidTagMacDataPtr macData) const |
| Determine if the packet is for me based on the receiver address (i.e., has my address or the broadcast address). | |
| bool | isEnoughTimeForContentionCycle () const |
| Determine if there is enough time left in the current request cycle to start a new contention cycle. | |
| void | startNextContentionCycle () |
| Send out a request packet to start a new contention cycle. | |
| bool | isPacketType (PacketPtr packet, RfidReaderMacData::Types type) const |
| Determine whether the packet is a packet of the given type by looking at it's header. | |
Protected Attributes | |
| bool | m_doResetSlot |
| Determines whether m_resetSlotNumber should be considered valid. | |
| t_uint | m_resetSlotNumber |
| If this slot number is reached, then the request cycle should be reset if m_doResetSlot is true. | |
| bool | m_doEntireReadCycle |
| Determines whether we should do the entire read cycle or stop early after several consecutive contention cycles are unsuccessful. | |
| t_uint | m_missedReadCount |
| Counts the number of consecutive times that we are unable to successfully read a packet in a contention cycle. | |
| TimerPtr | m_cycleTimer |
| A timer to keep track of when request cycles end. | |
| PacketPtr | m_currentAppReadPacket |
| The application packet for which we are currently doing the MAC. | |
| t_uint | m_nextCycleNumberOfSlots |
| The number of slots we are currently using in contention intervals. | |
| SimTime | m_nextCycleTime |
| How long the next cycle lasts. | |
| RfidReaderAppPtr | m_readerApp |
| A pointer to the application layer associated with this MAC. | |
| vector< pair< NodeId, t_uint > > | m_winningSlotNumbers |
| Keep track of the winning slot number for each received payload for statistics. | |
| vector< t_uint > | m_missedReads |
| Keep track of the slot number for when a missed read occurs for statistics. | |
Static Protected Attributes | |
| static const double | m_READER_IFS = 10e-6 |
| The interframe spacing of reader packets. | |
| static const t_uint | m_DEFAULT_NUMBER_OF_SLOTS = 10 |
| The default number of slots the reader will use in contention intervals. | |
| static const double | m_DEFAULT_CYCLE_TIME = 5.25 |
| The default time for how long a request cycle lasts. | |
| static const t_uint | m_MISSED_READ_THRESHOLD = 3 |
| The threshold for how many consecutive tag reads we can miss before we manually end a cycle. | |
| static const string | m_MISSED_READ_TOTAL_STRING = "missedReadTotal" |
| String for the stats file output. | |
| static const string | m_MISSED_READ_SLOT_AVG_STRING = "missedReadSlotAvg" |
| String for the stats file output. | |
| static const string | m_WINNING_SLOT_AVG_STRING = "winningSlotAvg" |
| String for the stats file output. | |
Friends | |
| class | RfidMacCycleEvent |
Definition at line 167 of file rfid_reader_mac.hpp.
| void RfidReaderMac::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 363 of file rfid_reader_mac.cpp.
References RfidReaderMacData::create(), Packet::DataTypes_Link, MacProtocol::getNode(), and RfidReaderMacData::Types_Generic.
Referenced by handleRecvdUpperLayerPacket().
| void RfidReaderMac::addSelectHeader | ( | PacketPtr | packet, | |
| NodeId | receiverId | |||
| ) | const [protected] |
Add a SELECT 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 373 of file rfid_reader_mac.cpp.
References RfidReaderMacData::create(), Packet::DataTypes_Link, MacProtocol::getNode(), and RfidReaderMacData::Types_Select.
Referenced by handleRecvdMacPacket().
| RfidReaderMacPtr RfidReaderMac::create | ( | NodePtr | node, | |
| RfidReaderAppPtr | readerApp | |||
| ) | [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. | |
| readerApp | the application using this MAC. |
Definition at line 468 of file rfid_reader_mac.hpp.
References Simulator::addSimulationEndListener(), RfidMacCycleEvent::create(), Timer::create(), SlottedMacSlotEvent::create(), Simulator::instance(), and RfidReaderMac().
| PacketPtr RfidReaderMac::createAckPacket | ( | NodeId | destination | ) | const [protected] |
Create a acknowledgement packet for the node.
| destination | the destination of the node to which we are sending the ACK. |
Definition at line 350 of file rfid_reader_mac.cpp.
References Packet::create(), RfidReaderMacData::create(), Packet::DataTypes_Link, MacProtocol::getNode(), and RfidReaderMacData::Types_Ack.
Referenced by handleRecvdMacPacket().
| PacketPtr RfidReaderMac::createRequestPacket | ( | ) | const [protected] |
Create a request packet for the node.
Definition at line 331 of file rfid_reader_mac.cpp.
References NodeId::broadcastDestination(), Packet::create(), RfidReaderMacData::create(), Packet::DataTypes_Link, MacProtocol::getNode(), m_currentAppReadPacket, m_nextCycleNumberOfSlots, and RfidReaderMacData::Types_Request.
Referenced by beginSlotEvent(), and startNextContentionCycle().
| void RfidReaderMac::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 attmpted. |
Implements MacProtocol.
Definition at line 186 of file rfid_reader_mac.cpp.
References isPacketType(), RfidReaderMacData::Types_Request, RfidReaderMacData::Types_Select, and MacProtocol::unblockUpperQueues().
| void RfidReaderMac::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 196 of file rfid_reader_mac.cpp.
References Packet::DataTypes_Link, isEnoughTimeForContentionCycle(), isPacketType(), SlottedMac::m_currentSlotNumber, m_doResetSlot, SlottedMac::m_numberOfSlots, m_resetSlotNumber, startNextContentionCycle(), RfidReaderMacData::Types_Ack, RfidReaderMacData::Types_Request, RfidReaderMacData::Types_Select, and MacProtocol::unblockUpperQueues().
| bool RfidReaderMac::handleRecvdMacPacket | ( | PacketPtr | packet, | |
| t_uint | sendingLayerIdx | |||
| ) | [virtual] |
Handle a MAC packet that is received.
| packet | a pointer to the received packet. | |
| sendingLayerIdx | the index of the layer that sent the packet. |
Implements MacProtocol.
Definition at line 264 of file rfid_reader_mac.cpp.
References addSelectHeader(), createAckPacket(), Packet::DataTypes_Link, CommunicationLayer::Directions_Upper, m_currentAppReadPacket, SlottedMac::m_currentSlotNumber, m_cycleTimer, SlottedMac::m_packetToTransmit, SlottedMac::m_slotTimer, SlottedMac::m_txSlotNumber, m_winningSlotNumbers, packetIsForMe(), MacProtocol::sendToLinkLayer(), RfidTagMacData::Types_Generic, and RfidTagMacData::Types_Reply.
| bool RfidReaderMac::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 384 of file rfid_reader_mac.cpp.
References addGenericHeader(), MacProtocol::blockUpperQueues(), NodeId::broadcastDestination(), Packet::DataTypes_Application, LogStreamManager::instance(), isEnoughTimeForContentionCycle(), LogStreamManager::logDebugItem(), m_currentAppReadPacket, SlottedMac::m_currentSlotNumber, m_cycleTimer, m_doEntireReadCycle, m_nextCycleTime, SlottedMac::m_packetToTransmit, SlottedMac::m_slotTimer, SlottedMac::m_txSlotNumber, startNextContentionCycle(), RfidReaderAppData::Types_Read, and RfidReaderAppData::Types_Reset.
| bool RfidReaderMac::isEnoughTimeForContentionCycle | ( | ) | const [protected] |
Determine if there is enough time left in the current request cycle to start a new contention cycle.
Definition at line 69 of file rfid_reader_mac.cpp.
References LogStreamManager::instance(), LogStreamManager::logDebugItem(), m_cycleTimer, SlottedMac::m_DEFAULT_SLOT_TIME, and m_nextCycleNumberOfSlots.
Referenced by beginSlotEvent(), handlePacketSent(), and handleRecvdUpperLayerPacket().
| bool RfidReaderMac::isPacketType | ( | PacketPtr | packet, | |
| RfidReaderMacData::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 225 of file rfid_reader_mac.cpp.
References Packet::DataTypes_Link.
Referenced by handleChannelBusy(), and handlePacketSent().
| bool RfidReaderMac::packetIsForMe | ( | RfidTagMacDataPtr | 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 238 of file rfid_reader_mac.cpp.
References NodeId::broadcastDestination(), and MacProtocol::getNode().
Referenced by handleRecvdMacPacket().
| MacProtocolPtr RfidReaderMac::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 502 of file rfid_reader_mac.hpp.
| RfidReaderMacPtr RfidReaderMac::thisRfidReaderMac | ( | ) | [inline, virtual] |
Gives this pointer as a RfidReaderMac object.
This is used to deal with shared_ptr's, this, and inheritance.
this object. Definition at line 490 of file rfid_reader_mac.hpp.
| SimulationEndListenerPtr RfidReaderMac::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 508 of file rfid_reader_mac.hpp.
| SlottedMacPtr RfidReaderMac::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 496 of file rfid_reader_mac.hpp.
const double RfidReaderMac::m_READER_IFS = 10e-6 [static, protected] |
The interframe spacing of reader packets.
The time which the node defers before transmitting a packet in a slot.
Definition at line 264 of file rfid_reader_mac.hpp.
Referenced by beginSlotEvent().
1.4.7