25 #include "ns3/net-device.h" 27 #include "ns3/packet.h" 29 #include "ns3/pointer.h" 32 #include "ns3/point-to-point-net-device.h" 33 #include "ns3/channel.h" 35 #include "../utils/ndn-fw-hop-count-tag.hpp" 37 NS_LOG_COMPONENT_DEFINE(
"ndn.NetDeviceLinkService");
44 , m_netDevice(netDevice)
46 NS_LOG_FUNCTION(
this << netDevice);
48 NS_ASSERT_MSG(m_netDevice != 0,
"NetDeviceFace needs to be assigned a valid NetDevice");
50 m_node->RegisterProtocolHandler(MakeCallback(&NetDeviceLinkService::receiveFromNetDevice,
this),
57 NS_LOG_FUNCTION_NOARGS();
73 NetDeviceLinkService::doSendInterest(
const Interest& interest)
75 NS_LOG_FUNCTION(
this << &interest);
82 NetDeviceLinkService::doSendData(
const Data& data)
84 NS_LOG_FUNCTION(
this << &data);
91 NetDeviceLinkService::doSendNack(
const lp::Nack& nack)
93 NS_LOG_FUNCTION(
this << &nack);
102 NetDeviceLinkService::receiveFromNetDevice(Ptr<NetDevice> device, Ptr<const Packet> p, uint16_t protocol,
103 const Address& from,
const Address& to,
104 NetDevice::PacketType packetType)
106 NS_LOG_FUNCTION(device << p << protocol << from << to << packetType);
108 Ptr<Packet> packet = p->Copy();
112 shared_ptr<const Interest> i = Convert::FromPacket<Interest>(packet);
117 shared_ptr<const Data> d = Convert::FromPacket<Data>(packet);
126 NS_LOG_ERROR(
"Unsupported TLV packet");
129 catch (const ::ndn::tlv::Error& e) {
130 NS_LOG_ERROR(
"Unrecognized TLV packet " << e.what());
135 NetDeviceLinkService::send(Ptr<Packet> packet)
137 NS_ASSERT_MSG(packet->GetSize() <= m_netDevice->GetMtu(),
138 "Packet size " << packet->GetSize() <<
" exceeds device MTU " 139 << m_netDevice->GetMtu());
142 packet->RemovePacketTag(tag);
144 packet->AddPacketTag(tag);
static Ptr< Packet > ToPacket(const T &pkt)
Copyright (c) 2011-2015 Regents of the University of California.
Packet tag that is used to track hop count for Interest-Data pairs.
static const uint16_t ETHERNET_FRAME_TYPE
Ethernet Frame Type of Ndn.
represents a Network Nack
static uint32_t getPacketType(Ptr< const Packet > packet)
Ptr< NetDevice > GetNetDevice() const
Get NetDevice associated with the LinkService.
Copyright (c) 2011-2015 Regents of the University of California.
virtual ~NetDeviceLinkService()
void Increment()
Increment hop count.
Ptr< Node > GetNode() const
Get Node associated with the LinkService.
void receiveData(const Data &data)
delivers received Data to forwarding
NetDeviceLinkService(Ptr< Node > node, const Ptr< NetDevice > &netDevice)
Constructor.
void receiveInterest(const Interest &interest)
delivers received Interest to forwarding