link_layer.cpp

00001 
00002 #include "link_layer.hpp"
00003 #include "mac_protocol.hpp"
00004 #include "physical_layer.hpp"
00005 
00006 const t_uint LinkLayer::m_LINK_LAYER_QUEUE_LENGTH = 1;
00007 
00008 LinkLayer::LinkLayer(NodePtr node, MacProtocolPtr macProtocol)
00009    : CommunicationLayer(node), m_macProtocol(macProtocol)
00010 {
00011    setMaxQueueLength(m_LINK_LAYER_QUEUE_LENGTH);
00012 }
00013 
00014 void LinkLayer::simulationEndHandler()
00015 {
00016 
00017 }
00018 
00019 bool LinkLayer::channelIsBusy()
00020 {
00021    CommunicationLayer::Directions direction = 
00022       CommunicationLayer::Directions_Lower;
00023    PhysicalLayerPtr physicalLayer = 
00024       boost::dynamic_pointer_cast<PhysicalLayer>
00025       (getLayer(direction, getDefaultLayer(direction)));
00026    assert(physicalLayer.get() != 0);
00027    return physicalLayer->channelCarrierSensedBusy();
00028 }
00029 
00030 bool LinkLayer::recvFromMacProtocol(
00031    CommunicationLayer::Directions direction, PacketPtr packet)
00032 {
00033    // Use the default function with packet passed back from
00034    // the MAC.
00035    return CommunicationLayer::sendToLayer(direction, packet);
00036 }
00037 
00038 bool LinkLayer::recvFromLayer(
00039    CommunicationLayer::Directions direction, PacketPtr packet,
00040    t_uint sendingLayerIdx)
00041 {
00042    assert(m_macProtocol.get() != 0);
00043    return m_macProtocol->recvFromLinkLayer(
00044       direction, packet, sendingLayerIdx);
00045 }
00046 
00047 

Generated on Tue Dec 12 17:04:37 2006 for rfidsim by  doxygen 1.4.7