#include <mac_protocol.hpp>
Inheritance diagram for MacProtocol:
Public Types | |
typedef boost::shared_ptr< MacProtocol > | MacProtocolPtr |
Smart pointer that clients should use. | |
typedef boost::shared_ptr< SimulationEndListener > | SimulationEndListenerPtr |
Smart pointer that clients should use. | |
Public Member Functions | |
virtual | ~MacProtocol () |
A destructor. | |
virtual MacProtocolPtr | thisMacProtocol ()=0 |
Gives this pointer as a MacProtocol object. | |
virtual SimulationEndListenerPtr | thisSimulationEndListener ()=0 |
Gives this pointer as a SimulationEndListenerPtr object. | |
bool | startSendTimer (CommunicationLayer::Directions direction, PacketPtr packet, const SimTime &delay) |
Starts a timer to send the packet with the specified delay. | |
virtual bool | recvFromLinkLayer (CommunicationLayer::Directions direction, PacketPtr packet, t_uint sendingLayerIdx) |
Receives a packet from a sending layer. | |
virtual bool | handleRecvdMacPacket (PacketPtr packet, t_uint sendingLayerIdx)=0 |
Handle a MAC packet that is received. | |
virtual bool | handleRecvdUpperLayerPacket (PacketPtr packet, t_uint sendingLayerIdx)=0 |
Handle a packet received from upper layers. | |
virtual void | handleChannelBusy (PacketPtr packet)=0 |
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)=0 |
This is called when the MAC is scheduled to transmit a packet on the channel and it is sent on the channel. | |
void | setLinkLayer (LinkLayerPtr linkLayer) |
Set the LinkLayer associated with this MAC. | |
NodePtr | getNode () const |
Get a pointer to the node associated with this MAC layer. | |
Protected Member Functions | |
MacProtocol (NodePtr node) | |
A constructor. | |
bool | sendToLinkLayer (CommunicationLayer::Directions direction, PacketPtr packet) |
Send a packet to the default receiving layer. | |
void | blockUpperQueues () |
Block all incoming queues from upper layers. | |
void | unblockUpperQueues () |
Unblock all incoming queues from upper layers. | |
bool | getQueueIsBlocked () const |
Determine whether incoming queues are currently blocked. | |
Protected Attributes | |
TimerPtr | m_sendTimer |
A timer for when a packet is sent to the link layer. | |
boost::weak_ptr< LinkLayer > | m_linkLayer |
A pointer to the link layer associated with this MAC object. | |
Friends | |
class | SendToLinkLayerEvent |
Definition at line 17 of file mac_protocol.hpp.
MacProtocol::MacProtocol | ( | NodePtr | node | ) | [protected] |
A constructor.
node | the node that owns this MAC. |
Definition at line 8 of file mac_protocol.cpp.
NodePtr MacProtocol::getNode | ( | ) | const [inline] |
Get a pointer to the node associated with this MAC layer.
Definition at line 119 of file mac_protocol.hpp.
Referenced by RfidTagMac::addGenericHeader(), RfidReaderMac::addGenericHeader(), RfidReaderMac::addSelectHeader(), RfidReaderMac::createAckPacket(), RfidTagMac::createReplyPacket(), RfidReaderMac::createRequestPacket(), RfidTagMac::handleRecvdMacPacket(), RfidTagMac::handleRequestPacket(), RfidTagMac::packetIsForMe(), RfidReaderMac::packetIsForMe(), RfidReaderMac::simulationEndHandler(), and startSendTimer().
bool MacProtocol::getQueueIsBlocked | ( | ) | const [protected] |
Determine whether incoming queues are currently blocked.
Definition at line 37 of file mac_protocol.cpp.
References m_linkLayer.
Referenced by RfidReaderMac::beginSlotEvent().
virtual void MacProtocol::handleChannelBusy | ( | PacketPtr | packet | ) | [pure 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. |
Implemented in RfidReaderMac, and RfidTagMac.
Referenced by sendToLinkLayer().
virtual void MacProtocol::handlePacketSent | ( | PacketPtr | packet | ) | [pure 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. |
Implemented in RfidReaderMac, and RfidTagMac.
Referenced by sendToLinkLayer().
virtual bool MacProtocol::handleRecvdMacPacket | ( | PacketPtr | packet, | |
t_uint | sendingLayerIdx | |||
) | [pure 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. |
Implemented in RfidReaderMac, and RfidTagMac.
Referenced by recvFromLinkLayer().
virtual bool MacProtocol::handleRecvdUpperLayerPacket | ( | PacketPtr | packet, | |
t_uint | sendingLayerIdx | |||
) | [pure virtual] |
Handle a packet received from upper layers.
packet | a pointer to the received packet. | |
sendingLayerIdx | the index of the layer that sent the packet. |
Implemented in RfidReaderMac, and RfidTagMac.
Referenced by recvFromLinkLayer().
bool MacProtocol::recvFromLinkLayer | ( | 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. |
Definition at line 75 of file mac_protocol.cpp.
References CommunicationLayer::Directions_Lower, CommunicationLayer::Directions_Upper, handleRecvdMacPacket(), and handleRecvdUpperLayerPacket().
bool MacProtocol::sendToLinkLayer | ( | CommunicationLayer::Directions | direction, | |
PacketPtr | packet | |||
) | [protected] |
Send a packet to the default receiving layer.
direction | the direction the packet was sent. | |
packet | a pointer to the received packet. |
Definition at line 57 of file mac_protocol.cpp.
References CommunicationLayer::Directions_Lower, handleChannelBusy(), handlePacketSent(), and m_linkLayer.
Referenced by RfidTagMac::handleRecvdMacPacket(), and RfidReaderMac::handleRecvdMacPacket().
void MacProtocol::setLinkLayer | ( | LinkLayerPtr | linkLayer | ) |
Set the LinkLayer associated with this MAC.
A weak pointer to the layer is maintained to break a cyclic reference.
linkLayer | a point to the LinkLayer object. |
Definition at line 19 of file mac_protocol.cpp.
References m_linkLayer.
bool MacProtocol::startSendTimer | ( | CommunicationLayer::Directions | direction, | |
PacketPtr | packet, | |||
const SimTime & | delay | |||
) |
Starts a timer to send the packet with the specified delay.
direction | the direction the packet will be sent. | |
packet | a pointer to the packet being sent. | |
delay | the delay with which the packet should be sent. |
Definition at line 43 of file mac_protocol.cpp.
References Timer::create(), SendToLinkLayerEvent::create(), getNode(), m_sendTimer, and thisMacProtocol().
Referenced by RfidTagMac::beginSlotEvent(), and RfidReaderMac::beginSlotEvent().
virtual MacProtocolPtr MacProtocol::thisMacProtocol | ( | ) | [pure virtual] |
Gives this
pointer as a MacProtocol
object.
This is used to deal with shared_ptr's
, this
, and inheritance.
this
object. Implemented in RfidReaderMac, and RfidTagMac.
Referenced by startSendTimer().
virtual SimulationEndListenerPtr MacProtocol::thisSimulationEndListener | ( | ) | [pure virtual] |
Gives this
pointer as a SimulationEndListenerPtr
object.
This is used to deal with shared_ptr's
, this
, and inheritance.
this
object. Implemented in RfidReaderMac, and RfidTagMac.
boost::weak_ptr<LinkLayer> MacProtocol::m_linkLayer [protected] |
A pointer to the link layer associated with this MAC object.
This must be a weak pointer because there is a cyclic reference since MAC points to Link and Link points to MAC.
Definition at line 164 of file mac_protocol.hpp.
Referenced by blockUpperQueues(), getQueueIsBlocked(), sendToLinkLayer(), setLinkLayer(), and unblockUpperQueues().