[ndnSIM] [Nfd-dev] getting the Neighbors nodes Ids of the current node

Klaus Schneider klaus at cs.arizona.edu
Tue Jul 31 13:46:31 PDT 2018


I wrote this helper function to get the neighborId for a face, assuming 
the involved links are PointToPointNetDevices:

>   static int getNeighborId(const shared_ptr<const Face> &face)
>   {
>     if (face == nullptr || face->isLocal()){
>       return -1;
>     }
> 
>     const auto hostDevice {getPtpNetDevFromFace(face)};
>     const auto channel {hostDevice->GetChannel()};
>     const auto ptpChan {ns3::DynamicCast<const ns3::PointToPointChannel>(channel)};
>     assert(ptpChan != nullptr && ptpChan->GetNDevices() == 2);
> 
>     auto neighbor {ptpChan->GetPointToPointDevice(0)};
>     if (neighbor == hostDevice) {
>       neighbor = ptpChan->GetPointToPointDevice(1);
>     }
> 
>     assert(neighbor->GetNode()->GetId() <= INT_MAX);
>     return static_cast<int>(neighbor->GetNode()->GetId());
>   }
> 
>   // Face can't be local!
>   static const ns3::Ptr<const ns3::PointToPointNetDevice>
>   getPtpNetDevFromFace(
>       const shared_ptr<const Face> &face)
>   {
>     assert(face != nullptr && !face->isLocal());
> 
>     const auto netDeviceFace {std::dynamic_pointer_cast<const ns3::ndn::NetDeviceFace>(face)};
>     assert(netDeviceFace != nullptr);
> 
>     const ns3::Ptr<const ns3::NetDevice> netdevice {netDeviceFace->GetNetDevice()};
>     assert(netdevice != nullptr);
> 
>     const auto ptp {ns3::DynamicCast<const ns3::PointToPointNetDevice>(netdevice)};
>     assert(ptp != nullptr);
> 
>     return ptp;
>   }

Please let me know if that works for you.

Klaus



On 30/07/18 06:36, george assaf wrote:
> Dear Forks,
> I am trying to implement Neighbor table in each ndn node .my question is :
> how can I get the direct neighbor nodes of the current node .
> Hope to help me achieve my goal
> thank you in advance
> 
> 
> _______________________________________________
> Nfd-dev mailing list
> Nfd-dev at lists.cs.ucla.edu
> http://www.lists.cs.ucla.edu/mailman/listinfo/nfd-dev
> 


More information about the ndnSIM mailing list