|
Bugzilla – Full Text Bug Listing |
| Summary: | Add IPv6 support to NetAnim | ||
|---|---|---|---|
| Product: | ns-3 | Reporter: | Tommaso Pecorella <tommaso.pecorella> |
| Component: | netanim | Assignee: | John Abraham <john.abraham.in> |
| Status: | RESOLVED FIXED | ||
| Severity: | enhancement | CC: | ns-bugs, riley |
| Priority: | P5 | ||
| Version: | ns-3-dev | ||
| Hardware: | All | ||
| OS: | All | ||
| Bug Depends on: | |||
| Bug Blocks: | 2190 | ||
| Attachments: |
animation example
changes suggested by John in the comment Ipv6 address displayed Multiple ipv6 addresses displayed under stats |
||
|
Description
Tommaso Pecorella
2015-10-04 16:34:54 UTC
(In reply to Tommaso Pecorella from comment #0) > Some networks (notably LrWpan) simply don't have IPv4. > It is not a blocker for LrWpan support, but it's not nice to see all the > nodes with a "0.0.0.0" address. Moreover, I am 110% sure that user will ask > why. This can be addressed in the short-term by Johns-MacBook-Pro:ns-3-dev john$ hg diff diff -r daa3bfadabef src/netanim/model/animation-interface.cc --- a/src/netanim/model/animation-interface.cc Mon Sep 28 20:23:11 2015 -0700 +++ b/src/netanim/model/animation-interface.cc Thu Oct 08 17:27:35 2015 -0700 @@ -48,6 +48,7 @@ #include "ns3/uan-net-device.h" #include "ns3/uan-mac.h" #include "ns3/ipv4.h" +#include "ns3/ipv6.h" #include "ns3/ipv4-routing-protocol.h" #include "ns3/energy-source-container.h" @@ -1520,23 +1521,35 @@ } std::string -AnimationInterface::GetIpv4Address (Ptr <NetDevice> nd) +AnimationInterface::GetIpAddress (Ptr <NetDevice> nd) { + std::ostringstream oss; + oss << ""; Ptr<Ipv4> ipv4 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv4> (); - if (!ipv4) + if (ipv4) { - NS_LOG_WARN ("Node: " << nd->GetNode ()->GetId () << " No ipv4 object found"); - return "0.0.0.0"; + int32_t ifIndex = ipv4->GetInterfaceForDevice (nd); + if (ifIndex != -1) + { + Ipv4InterfaceAddress addr = ipv4->GetAddress (ifIndex, 0); + oss << addr.GetLocal (); + } } - int32_t ifIndex = ipv4->GetInterfaceForDevice (nd); - if (ifIndex == -1) + oss << " "; + Ptr<Ipv6> ipv6 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv6> (); + if (ipv6) + { + int32_t ifIndex = ipv6->GetInterfaceForDevice (nd); + if (ifIndex != -1) + { + Ipv6InterfaceAddress addr = ipv6->GetAddress (ifIndex, 0); + oss << addr.GetAddress (); + } + } + if (!ipv4 && !ipv6) { - NS_LOG_WARN ("Node :" << nd->GetNode ()->GetId () << " Could not find index of NetDevice"); - return "0.0.0.0"; + NS_LOG_WARN ("Node:" << nd->GetNode ()->GetId () << " has neither aggregated ipv4 nor ipv6"); } - Ipv4InterfaceAddress addr = ipv4->GetAddress (ifIndex, 0); - std::ostringstream oss; - oss << addr.GetLocal (); return oss.str (); } @@ -1562,8 +1575,8 @@ (dev->GetInstanceTypeId ().GetName () == "ns3::LteEnbNetDevice")|| (dev->GetInstanceTypeId ().GetName () == "ns3::VirtualNetDevice")) { - WriteNonP2pLinkProperties (n->GetId (), GetIpv4Address (dev) + "~" + GetMacAddress (dev), dev->GetInstanceTypeId ().GetName ()); - AddToIpv4AddressNodeIdTable (GetIpv4Address (dev), n->GetId ()); + WriteNonP2pLinkProperties (n->GetId (), GetIpAddress (dev) + "~" + GetMacAddress (dev), dev->GetInstanceTypeId ().GetName ()); + AddToIpv4AddressNodeIdTable (GetIpAddress (dev), n->GetId ()); } continue; } @@ -1580,13 +1593,13 @@ if (n1Id < n2Id) { // ouptut the p2p link - NS_LOG_INFO ("Link:" << GetIpv4Address (dev) << ":" << GetMacAddress (dev) << "----" << GetIpv4Address (chDev) << ":" << GetMacAddress (chDev)); - AddToIpv4AddressNodeIdTable (GetIpv4Address (dev), n1Id); - AddToIpv4AddressNodeIdTable (GetIpv4Address (chDev), n2Id); + NS_LOG_INFO ("Link:" << GetIpAddress (dev) << ":" << GetMacAddress (dev) << "----" << GetIpAddress (chDev) << ":" << GetMacAddress (chDev)); + AddToIpv4AddressNodeIdTable (GetIpAddress (dev), n1Id); + AddToIpv4AddressNodeIdTable (GetIpAddress (chDev), n2Id); P2pLinkNodeIdPair p2pPair; p2pPair.fromNode = n1Id; p2pPair.toNode = n2Id; - LinkProperties lp = {GetIpv4Address (dev) + "~" + GetMacAddress (dev), GetIpv4Address (chDev) + "~" + GetMacAddress (chDev), ""}; + LinkProperties lp = {GetIpAddress (dev) + "~" + GetMacAddress (dev), GetIpAddress (chDev) + "~" + GetMacAddress (chDev), ""}; m_linkProperties[p2pPair] = lp; WriteXmlLink (n1Id, 0, n2Id); } @@ -1594,9 +1607,9 @@ } else { - NS_LOG_INFO ("Link:" << GetIpv4Address (dev) << " Channel Type:" << channelType << " Mac: " << GetMacAddress (dev)); - WriteNonP2pLinkProperties (n->GetId (), GetIpv4Address (dev) + "~" + GetMacAddress (dev), channelType); - AddToIpv4AddressNodeIdTable (GetIpv4Address (dev), n->GetId ()); + NS_LOG_INFO ("Link:" << GetIpAddress (dev) << " Channel Type:" << channelType << " Mac: " << GetMacAddress (dev)); + WriteNonP2pLinkProperties (n->GetId (), GetIpAddress (dev) + "~" + GetMacAddress (dev), channelType); + AddToIpv4AddressNodeIdTable (GetIpAddress (dev), n->GetId ()); } } } diff -r daa3bfadabef src/netanim/model/animation-interface.h --- a/src/netanim/model/animation-interface.h Mon Sep 28 20:23:11 2015 -0700 +++ b/src/netanim/model/animation-interface.h Thu Oct 08 17:27:35 2015 -0700 @@ -629,7 +629,7 @@ int WriteN (const char*, uint32_t, FILE * f); int WriteN (const std::string&, FILE * f); std::string GetMacAddress (Ptr <NetDevice> nd); - std::string GetIpv4Address (Ptr <NetDevice> nd); + std::string GetIpAddress (Ptr <NetDevice> nd); std::string GetNetAnimVersion (); void MobilityAutoCheck (); bool IsPacketPending (uint64_t animUid, ProtocolType protocolType); But I am holding off for now, as the long-term solution is to send an XML element for node properties and list the devices per node and iterate over all ip/ipv6 addresses including secondary and tertiary addresses. The result of this patch is this (in the xml file): <nonp2plinkproperties id="0" ipv4Address=" ~00:01" channelType="ns3::SingleModelSpectrumChannel" /> <nonp2plinkproperties id="0" ipv4Address=" fe80::ff:fe00:1~00:01" channelType="ns3::SingleModelSpectrumChannel" /> <nonp2plinkproperties id="1" ipv4Address=" ~00:02" channelType="ns3::SingleModelSpectrumChannel" /> <nonp2plinkproperties id="1" ipv4Address=" fe80::ff:fe00:2~00:02" channelType="ns3::SingleModelSpectrumChannel" /> Most probably it's due to the 6LoWPAN NetDevice, which is a fake netDevice by all means. Moreover, NetAnim will keep showing 0.0.0.0, as it doesn't really understand what's going on (stats is right, animation isn't). I guess the only "right" way to do it is to have an xml element for the node. If I can help, let me know. (In reply to Tommaso Pecorella from comment #2) > The result of this patch is this (in the xml file): > > <nonp2plinkproperties id="0" ipv4Address=" ~00:01" > channelType="ns3::SingleModelSpectrumChannel" /> > <nonp2plinkproperties id="0" ipv4Address=" fe80::ff:fe00:1~00:01" > channelType="ns3::SingleModelSpectrumChannel" /> > <nonp2plinkproperties id="1" ipv4Address=" ~00:02" > channelType="ns3::SingleModelSpectrumChannel" /> > <nonp2plinkproperties id="1" ipv4Address=" fe80::ff:fe00:2~00:02" > channelType="ns3::SingleModelSpectrumChannel" /> > > Most probably it's due to the 6LoWPAN NetDevice, which is a fake netDevice > by all means. > > Moreover, NetAnim will keep showing 0.0.0.0, as it doesn't really understand > what's going on (stats is right, animation isn't). > > I guess the only "right" way to do it is to have an xml element for the > node. If I can help, let me know. Sorry for the delay. Can you share the program which generates 0.0.0.0? (In reply to John Abraham from comment #3) > (In reply to Tommaso Pecorella from comment #2) > > The result of this patch is this (in the xml file): > > > > <nonp2plinkproperties id="0" ipv4Address=" ~00:01" > > channelType="ns3::SingleModelSpectrumChannel" /> > > <nonp2plinkproperties id="0" ipv4Address=" fe80::ff:fe00:1~00:01" > > channelType="ns3::SingleModelSpectrumChannel" /> > > <nonp2plinkproperties id="1" ipv4Address=" ~00:02" > > channelType="ns3::SingleModelSpectrumChannel" /> > > <nonp2plinkproperties id="1" ipv4Address=" fe80::ff:fe00:2~00:02" > > channelType="ns3::SingleModelSpectrumChannel" /> > > > > Most probably it's due to the 6LoWPAN NetDevice, which is a fake netDevice > > by all means. > > > > Moreover, NetAnim will keep showing 0.0.0.0, as it doesn't really understand > > what's going on (stats is right, animation isn't). > > > > I guess the only "right" way to do it is to have an xml element for the > > node. If I can help, let me know. > > > > Sorry for the delay. Can you share the program which generates 0.0.0.0? I just uses examples/ipv6/wsn-ping6.cc, with a the addition of the lines: AnimationInterface anim ("lr-wpan-animation.xml"); // Mandatory anim.EnablePacketMetadata (); // Optional *and* the patch proposed in bug #2190 (otherwise lr-wpan wouldn't generate the output). Created attachment 2163 [details] animation example Animation created by examples/ipv6/wsn-ping6.cc with bug #2190 patch (In reply to Tommaso Pecorella from comment #5) > Created attachment 2163 [details] > animation example > > Animation created by examples/ipv6/wsn-ping6.cc with bug #2190 patch I see it may appear that the co-ordinate "0.0, 0.0" may look like "0.0.0.0" due to the font selection. Created attachment 2744 [details]
changes suggested by John in the comment
I'm trying to introduce a new tag to convey this information. This is less hacky. <ipv6 n="1" > <address >fe80:0000:0000:0000:0200:00ff:fe00:0002</address> <address >fe80:0000:0000:0000:0200:00ff:fe00:0006</address> </ipv6> Will try to implement the parsing for this tag in the Animator Applied first set of patches http://code.nsnam.org/ns-3-dev/rev/dec5c9887ada Hi Tommaso, Do you have any example IPv6 program that I can use for testing the changes? (In reply to John Abraham from comment #10) > Hi Tommaso, > Do you have any example IPv6 program that I can use for testing the changes? Hi John, what about examples/routing/ripng-simple-network.cc as a starting point ? Cheers Tried, examples/routing/ripng-simple-network.cc with the latest netanim and ns-3-dev. Screenshots attached. Created attachment 2793 [details]
Ipv6 address displayed
Created attachment 2794 [details]
Multiple ipv6 addresses displayed under stats
Beautiful !!! I'd only filter the ::1 (Loopback) addresses, just to save space. Other than that, I'd say that we have IPv6 support in NetAnim :) Cheers, T. (In reply to John Abraham from comment #12) > Tried, examples/routing/ripng-simple-network.cc with the latest netanim and > ns-3-dev. > Screenshots attached. |