<div dir="ltr"><div dir="ltr">Hi Andre<div><br></div><div>See NDN contributing guide:</div><div><a href="https://github.com/named-data/.github/blob/main/CONTRIBUTING.md">https://github.com/named-data/.github/blob/main/CONTRIBUTING.md</a><br></div><div><br></div><div>Please submit your code to Gerrit system:</div><div><a href="https://gerrit.named-data.net/admin/repos/ndnSIM,general">https://gerrit.named-data.net/admin/repos/ndnSIM,general</a><br></div><div><br></div><div>Yours, Junxiao</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jun 9, 2023 at 7:07 PM Andre Madureira via ndnSIM <<a href="mailto:ndnsim@lists.cs.ucla.edu">ndnsim@lists.cs.ucla.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p style="text-align:center"><font color="red"><strong>External Email</strong><br></font></p><div dir="ltr">Hello,<div><br></div><div>I've tried building a custom forwarding strategy that checks the LinkType to see if the NDN face is operating as Adhoc, Multi-access or Point-to-Point. But to my surprise this link type field was not working, as the NDN Face was always being created as if the NS3 network device is a Point-to-Point one. I figured that the function responsible by the NDN Face creation was the following:</div><div><br></div><div><span style="background-color:rgb(30,30,30);font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap;color:rgb(78,201,176)">shared_ptr</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap"><</span><span style="background-color:rgb(30,30,30);font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap;color:rgb(78,201,176)">Face</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap">></span></div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(78,201,176)">StackHelper</span>::<span style="color:rgb(220,220,170)">DefaultNetDeviceCallback</span>(<span style="color:rgb(78,201,176)">Ptr</span><<span style="color:rgb(78,201,176)">Node</span>> <span style="color:rgb(156,220,254)">node</span>, <span style="color:rgb(78,201,176)">Ptr</span><<span style="color:rgb(78,201,176)">L3Protocol</span>> <span style="color:rgb(156,220,254)">ndn</span>,</div><div>                                      <span style="color:rgb(78,201,176)">Ptr</span><<span style="color:rgb(78,201,176)">NetDevice</span>> <span style="color:rgb(156,220,254)">netDevice</span>)</div></div><div><br></div><div>So I've checked the function and found that no checks have been done to identify the NS3's network device operation (Adhoc, Multiaccess or Point-to-point). So I've modified the function to look like this:</div><div><br></div><div><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Consolas,"Courier New",monospace;font-size:14px;line-height:19px;white-space:pre-wrap"><div><span style="color:rgb(78,201,176)">shared_ptr</span><<span style="color:rgb(78,201,176)">Face</span>></div><div><span style="color:rgb(78,201,176)">StackHelper</span>::<span style="color:rgb(220,220,170)">DefaultNetDeviceCallback</span>(<span style="color:rgb(78,201,176)">Ptr</span><<span style="color:rgb(78,201,176)">Node</span>> <span style="color:rgb(156,220,254)">node</span>, <span style="color:rgb(78,201,176)">Ptr</span><<span style="color:rgb(78,201,176)">L3Protocol</span>> <span style="color:rgb(156,220,254)">ndn</span>,</div><div>                                      <span style="color:rgb(78,201,176)">Ptr</span><<span style="color:rgb(78,201,176)">NetDevice</span>> <span style="color:rgb(156,220,254)">netDevice</span>) <span style="color:rgb(86,156,214)">const</span></div><div>{</div><div>  <span style="color:rgb(86,156,214)">NS_LOG_DEBUG</span>(<span style="color:rgb(206,145,120)">"Creating default Face on node "</span> << <span style="color:rgb(156,220,254)">node</span><span style="color:rgb(220,220,170)">-></span><span style="color:rgb(220,220,170)">GetId</span>());</div><br><div><span style="color:rgb(106,153,85)">  // Create an ndnSIM-specific transport instance</span></div><div>  ::<span style="color:rgb(78,201,176)">nfd</span>::<span style="color:rgb(78,201,176)">face</span>::<span style="color:rgb(78,201,176)">GenericLinkService</span>::<span style="color:rgb(78,201,176)">Options</span> <span style="color:rgb(156,220,254)">opts</span>;</div><div>  <span style="color:rgb(156,220,254)">opts</span>.<span style="color:rgb(156,220,254)">allowFragmentation</span> = <span style="color:rgb(86,156,214)">true</span>;</div><div>  <span style="color:rgb(156,220,254)">opts</span>.<span style="color:rgb(156,220,254)">allowReassembly</span> = <span style="color:rgb(86,156,214)">true</span>;</div><div>  <span style="color:rgb(156,220,254)">opts</span>.<span style="color:rgb(156,220,254)">allowCongestionMarking</span> = <span style="color:rgb(86,156,214)">true</span>;</div><br><div>  <span style="color:rgb(86,156,214)">auto</span> <span style="color:rgb(156,220,254)">linkService</span> = <span style="color:rgb(220,220,170)">make_unique</span><::<span style="color:rgb(78,201,176)">nfd</span>::<span style="color:rgb(78,201,176)">face</span>::<span style="color:rgb(78,201,176)">GenericLinkService</span>>(<span style="color:rgb(156,220,254)">opts</span>);</div><br><div>  <span style="color:rgb(86,156,214)">auto</span> <span style="color:rgb(156,220,254)">linkType</span> = ::<span style="color:rgb(78,201,176)">ndn</span>::<span style="color:rgb(78,201,176)">nfd</span>::<span style="color:rgb(79,193,255)">LINK_TYPE_POINT_TO_POINT</span>;</div><div>  <span style="color:rgb(197,134,192)">if</span> (<span style="color:rgb(156,220,254)">netDevice</span><span style="color:rgb(220,220,170)">-></span><span style="color:rgb(220,220,170)">IsPointToPoint</span>() == <span style="color:rgb(181,206,168)">0</span>)</div><div>    <span style="color:rgb(156,220,254)">linkType</span> = ::<span style="color:rgb(78,201,176)">ndn</span>::<span style="color:rgb(78,201,176)">nfd</span>::<span style="color:rgb(79,193,255)">LINK_TYPE_MULTI_ACCESS</span>;</div><div><span style="color:rgb(106,153,85)">  // check for Adhoc communication</span></div><div>  <span style="color:rgb(86,156,214)">auto</span> <span style="color:rgb(156,220,254)">wifiNetDev</span> = <span style="color:rgb(86,156,214)">dynamic_cast</span><<span style="color:rgb(78,201,176)">ns3</span>::<span style="color:rgb(78,201,176)">WifiNetDevice</span>*>(&(<span style="color:rgb(220,220,170)">*</span><span style="color:rgb(156,220,254)">netDevice</span>));</div><div>  <span style="color:rgb(197,134,192)">if</span> (<span style="color:rgb(156,220,254)">wifiNetDev</span> != <span style="color:rgb(86,156,214)">NULL</span>) {</div><div>    <span style="color:rgb(86,156,214)">auto</span> <span style="color:rgb(156,220,254)">wifiMac</span> = <span style="color:rgb(156,220,254)">wifiNetDev</span>-><span style="color:rgb(220,220,170)">GetMac</span>();</div><div>    <span style="color:rgb(197,134,192)">if</span> (<span style="color:rgb(86,156,214)">dynamic_cast</span><<span style="color:rgb(78,201,176)">ns3</span>::<span style="color:rgb(78,201,176)">AdhocWifiMac</span>*>(&(<span style="color:rgb(220,220,170)">*</span><span style="color:rgb(156,220,254)">wifiMac</span>)) != <span style="color:rgb(86,156,214)">NULL</span>)</div><div>      <span style="color:rgb(156,220,254)">linkType</span> = ::<span style="color:rgb(78,201,176)">ndn</span>::<span style="color:rgb(78,201,176)">nfd</span>::<span style="color:rgb(79,193,255)">LINK_TYPE_AD_HOC</span>;</div><div>  }</div><br><div>  <span style="color:rgb(86,156,214)">auto</span> <span style="color:rgb(156,220,254)">transport</span> =</div><div>    <span style="color:rgb(220,220,170)">make_unique</span><<span style="color:rgb(78,201,176)">NetDeviceTransport</span>>(<span style="color:rgb(156,220,254)">node</span>, <span style="color:rgb(156,220,254)">netDevice</span>, <span style="color:rgb(220,220,170)">constructFaceUri</span>(<span style="color:rgb(156,220,254)">netDevice</span>),</div><div>                                    <span style="color:rgb(206,145,120)">"netdev://[ff:ff:ff:ff:ff:ff]"</span>,</div><div>                                    ::<span style="color:rgb(78,201,176)">ndn</span>::<span style="color:rgb(78,201,176)">nfd</span>::<span style="color:rgb(79,193,255)">FACE_SCOPE_NON_LOCAL</span>,</div><div>                                    ::<span style="color:rgb(78,201,176)">ndn</span>::<span style="color:rgb(78,201,176)">nfd</span>::<span style="color:rgb(79,193,255)">FACE_PERSISTENCY_PERSISTENT</span>, <span style="color:rgb(156,220,254)">linkType</span>);</div><br><div>  <span style="color:rgb(86,156,214)">auto</span> <span style="color:rgb(156,220,254)">face</span> = <span style="color:rgb(78,201,176)">std</span>::<span style="color:rgb(220,220,170)">make_shared</span><<span style="color:rgb(78,201,176)">Face</span>>(<span style="color:rgb(78,201,176)">std</span>::<span style="color:rgb(220,220,170)">move</span>(<span style="color:rgb(156,220,254)">linkService</span>), <span style="color:rgb(78,201,176)">std</span>::<span style="color:rgb(220,220,170)">move</span>(<span style="color:rgb(156,220,254)">transport</span>));</div><div>  <span style="color:rgb(156,220,254)">face</span><span style="color:rgb(220,220,170)">-></span><span style="color:rgb(220,220,170)">setMetric</span>(<span style="color:rgb(181,206,168)">1</span>);</div><br><div>  <span style="color:rgb(156,220,254)">ndn</span><span style="color:rgb(220,220,170)">-></span><span style="color:rgb(220,220,170)">addFace</span>(<span style="color:rgb(156,220,254)">face</span>);</div><div>  <span style="color:rgb(86,156,214)">NS_LOG_LOGIC</span>(<span style="color:rgb(206,145,120)">"Node "</span> << <span style="color:rgb(156,220,254)">node</span><span style="color:rgb(220,220,170)">-></span><span style="color:rgb(220,220,170)">GetId</span>() << <span style="color:rgb(206,145,120)">": added Face as face #"</span> << <span style="color:rgb(156,220,254)">face</span><span style="color:rgb(220,220,170)">-></span><span style="color:rgb(220,220,170)">getLocalUri</span>()</div><div>                       << <span style="color:rgb(206,145,120)">" - remoteURI = "</span> << <span style="color:rgb(156,220,254)">face</span><span style="color:rgb(220,220,170)">-></span><span style="color:rgb(220,220,170)">getRemoteUri</span>() << <span style="color:rgb(206,145,120)">" - linkType "</span> << <span style="color:rgb(156,220,254)">linkType</span>);</div><br><div>  <span style="color:rgb(197,134,192)">return</span> <span style="color:rgb(156,220,254)">face</span>;</div><div>}</div></div></div><div><br></div><div>I've tested the code with Point-to-Point network devices and WifiNetDevice with <span style="background-color:rgb(30,30,30);font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap;color:rgb(78,201,176)">ns3</span><span style="background-color:rgb(30,30,30);color:rgb(212,212,212);font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap">::</span><span style="background-color:rgb(30,30,30);font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap;color:rgb(78,201,176)">AdhocWifiMac</span> configured and in both cases the linkType was properly identified when the NDN Face was created. But I don't know if it will work under other network devices or MAC's. I'm sending this message in the hopes that there's another way to solve this problem and as an attempt to improve ndnSIM code.</div><div><br></div><div>Best regards,</div><div>Andre Madureira</div></div>
_______________________________________________<br>
ndnSIM mailing list<br>
<a href="mailto:ndnSIM@lists.cs.ucla.edu" target="_blank">ndnSIM@lists.cs.ucla.edu</a><br>
<a href="https://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim" rel="noreferrer" target="_blank">https://www.lists.cs.ucla.edu/mailman/listinfo/ndnsim</a><br>
</blockquote></div></div>