22 #include "ndn-net-device-face.h" 
   23 #include "ndn-l3-protocol.h" 
   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" 
   34 #include "ns3/ndn-name.h" 
   36 NS_LOG_COMPONENT_DEFINE (
"ndn.NetDeviceFace");
 
   41 NS_OBJECT_ENSURE_REGISTERED (NetDeviceFace);
 
   44 NetDeviceFace::GetTypeId ()
 
   46   static TypeId tid = TypeId (
"ns3::ndn::NetDeviceFace")
 
   59   , m_netDevice (netDevice)
 
   61   NS_LOG_FUNCTION (
this << netDevice);
 
   65   NS_ASSERT_MSG (m_netDevice != 0, 
"NetDeviceFace needs to be assigned a valid NetDevice");
 
   68 NetDeviceFace::~NetDeviceFace ()
 
   70   NS_LOG_FUNCTION_NOARGS ();
 
   73 NetDeviceFace& NetDeviceFace::operator= (
const NetDeviceFace &)
 
   87   NS_LOG_FUNCTION (
this);
 
   91   m_node->RegisterProtocolHandler (MakeCallback (&NetDeviceFace::ReceiveFromNetDevice, 
this),
 
   98   m_node->UnregisterProtocolHandler (MakeCallback (&NetDeviceFace::ReceiveFromNetDevice, 
this));
 
  110   NS_LOG_FUNCTION (
this << packet);
 
  112   NS_ASSERT_MSG (packet->GetSize () <= m_netDevice->GetMtu (),
 
  113                  "Packet size " << packet->GetSize () << 
" exceeds device MTU " 
  114                  << m_netDevice->GetMtu ()
 
  115                  << 
" for Ndn; fragmentation not supported");
 
  117   bool ok = m_netDevice->Send (packet, m_netDevice->GetBroadcast (),
 
  124 NetDeviceFace::ReceiveFromNetDevice (Ptr<NetDevice> device,
 
  129                                      NetDevice::PacketType packetType)
 
  131   NS_LOG_FUNCTION (device << p << protocol << from << to << packetType);
 
  139 #ifdef NS3_LOG_ENABLE 
  140   os << 
"dev[" << 
GetNode ()->GetId () << 
"]=net(" << 
GetId ();
 
  142   if (DynamicCast<PointToPointNetDevice> (m_netDevice))
 
  146       os << DynamicCast<PointToPointNetDevice> (m_netDevice)->GetChannel ()->GetDevice (0)->GetNode ()->GetId ();
 
  148       os << DynamicCast<PointToPointNetDevice> (m_netDevice)->GetChannel ()->GetDevice (1)->GetNode ()->GetId ();
 
  152   os << 
"dev=net(" << 
GetId () << 
")";
 
virtual bool Send(Ptr< Packet > p)
Send packet down to the stack (towards app or network) 
 
Ptr< Node > m_node
Smart pointer to Node. 
 
virtual std::ostream & Print(std::ostream &os) const 
Print out name of the NdnFace to the stream. 
 
uint32_t GetId() const 
Get face Id. 
 
virtual void UnRegisterProtocolHandlers()
Un-Register callback to call when new packet arrives on the face. 
 
virtual void RegisterProtocolHandlers(const InterestHandler &interestHandler, const DataHandler &dataHandler)
Register callback to call when new packet arrives on the face. 
 
virtual void RegisterProtocolHandlers(const InterestHandler &interestHandler, const DataHandler &dataHandler)
Register callback to call when new packet arrives on the face. 
 
Virtual class defining NDN face. 
 
virtual void SetMetric(uint16_t metric)
Assign routing/forwarding metric with face. 
 
virtual bool Receive(Ptr< const Packet > p)
Send packet up to the stack (towards forwarding strategy) 
 
static const uint16_t ETHERNET_FRAME_TYPE
Ethernet Frame Type of Ndn. 
 
virtual bool Send(Ptr< Packet > packet)
Send packet down to the stack (towards app or network) 
 
Face(Ptr< Node > node)
Default constructor. 
 
Ptr< Node > GetNode() const 
Get node to which this face is associated. 
 
Callback< void, Ptr< Face >, Ptr< Interest > > InterestHandler
NDN protocol handlers. 
 
NetDeviceFace(Ptr< Node > node, const Ptr< NetDevice > &netDevice)
Constructor. 
 
virtual void UnRegisterProtocolHandlers()
Un-Register callback to call when new packet arrives on the face. 
 
Ptr< NetDevice > GetNetDevice() const 
Get NetDevice associated with the face.