MacProtocol Class Reference

The class for handling medium access control (MAC) on a channel. More...

#include <mac_protocol.hpp>

Inheritance diagram for MacProtocol:

SimulationEndListener SlottedMac RfidReaderMac RfidTagMac List of all members.

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< LinkLayerm_linkLayer
 A pointer to the link layer associated with this MAC object.

Friends

class SendToLinkLayerEvent

Detailed Description

The class for handling medium access control (MAC) on a channel.

Definition at line 17 of file mac_protocol.hpp.


Constructor & Destructor Documentation

MacProtocol::MacProtocol ( NodePtr  node  )  [protected]

A constructor.

Parameters:
node the node that owns this MAC.

Definition at line 8 of file mac_protocol.cpp.


Member Function Documentation

NodePtr MacProtocol::getNode (  )  const [inline]

Get a pointer to the node associated with this MAC layer.

Returns:
a pointer to the node.

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.

Returns:
true if the are 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.

Parameters:
packet the packet whose transmission was being attmpted.
See also:
handlePacketSent()

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.

Parameters:
packet the packet whose transmission was being attmpted.
See also:
handleChannelBusy()

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.

Parameters:
packet a pointer to the received packet.
sendingLayerIdx the index of the layer that sent the packet.
Returns:
true if the packet was able to be handled.

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.

Parameters:
packet a pointer to the received packet.
sendingLayerIdx the index of the layer that sent the packet.
Returns:
true if the packet was able to be handled.

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.

Parameters:
direction the direction the packet was sent.
packet a pointer to the received packet.
sendingLayerIdx the index of the layer that sent the packet.
Returns:
true if the specified layer was able to receive 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.

Parameters:
direction the direction the packet was sent.
packet a pointer to the received packet.
Returns:
true if the specified layer was able to receive the 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.

Parameters:
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.

Parameters:
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.
Returns:
true if the timer is set successfully.

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.

Returns:
a pointer to 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.

Returns:
a pointer to this object.

Implemented in RfidReaderMac, and RfidTagMac.


Member Data Documentation

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().


The documentation for this class was generated from the following files:
Generated on Tue Dec 12 17:04:40 2006 for rfidsim by  doxygen 1.4.7