View | Details | Raw Unified | Return to bug 2191
Collapse All | Expand All

(-)a/src/netanim/model/animation-interface.cc (-20 / +33 lines)
 Lines 49-54    Link Here 
49
#include "ns3/uan-net-device.h"
49
#include "ns3/uan-net-device.h"
50
#include "ns3/uan-mac.h"
50
#include "ns3/uan-mac.h"
51
#include "ns3/ipv4.h"
51
#include "ns3/ipv4.h"
52
#include "ns3/ipv6.h"
52
#include "ns3/ipv4-routing-protocol.h"
53
#include "ns3/ipv4-routing-protocol.h"
53
#include "ns3/energy-source-container.h"
54
#include "ns3/energy-source-container.h"
54
#include "ns3/lr-wpan-net-device.h"
55
#include "ns3/lr-wpan-net-device.h"
 Lines 1652-1674    Link Here 
1652
}
1653
}
1653
1654
1654
std::string 
1655
std::string 
1655
AnimationInterface::GetIpv4Address (Ptr <NetDevice> nd)
1656
AnimationInterface::GetIpAddress (Ptr <NetDevice> nd)
1656
{
1657
{
1658
  std::ostringstream oss;
1659
  oss << "";
1657
  Ptr<Ipv4> ipv4 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv4> ();
1660
  Ptr<Ipv4> ipv4 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv4> ();
1658
  if (!ipv4)
1661
  if (ipv4)
1659
    {
1662
    {
1660
      NS_LOG_WARN ("Node: " << nd->GetNode ()->GetId () << " No ipv4 object found");
1663
      int32_t ifIndex = ipv4->GetInterfaceForDevice (nd);
1661
      return "0.0.0.0";
1664
      if (ifIndex != -1)
1665
        {
1666
          Ipv4InterfaceAddress addr = ipv4->GetAddress (ifIndex, 0);
1667
          oss << addr.GetLocal ();
1668
        }
1662
    }
1669
    }
1663
  int32_t ifIndex = ipv4->GetInterfaceForDevice (nd);
1670
  oss << " ";
1664
  if (ifIndex == -1)
1671
  Ptr<Ipv6> ipv6 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv6> ();
1672
  if (ipv6)
1665
    {
1673
    {
1666
      NS_LOG_WARN ("Node :" << nd->GetNode ()->GetId () << " Could not find index of NetDevice");
1674
      int32_t ifIndex = ipv6->GetInterfaceForDevice (nd);
1667
      return "0.0.0.0";
1675
      if (ifIndex != -1)
1676
        {
1677
          Ipv6InterfaceAddress addr = ipv6->GetAddress (ifIndex, 0);
1678
          oss << addr.GetAddress ();
1679
        }
1668
    }
1680
    }
1669
  Ipv4InterfaceAddress addr = ipv4->GetAddress (ifIndex, 0);
1681
  if (!ipv4 && !ipv6)
1670
  std::ostringstream oss;
1682
    {
1671
  oss << addr.GetLocal ();
1683
      NS_LOG_WARN ("Node:" << nd->GetNode ()->GetId () << " has neither aggregated ipv4 nor ipv6");
1684
    }
1672
  return oss.str ();
1685
  return oss.str ();
1673
}
1686
}
1674
1687
 Lines 1694-1701    Link Here 
1694
                  (dev->GetInstanceTypeId ().GetName () == "ns3::LteEnbNetDevice")||
1707
                  (dev->GetInstanceTypeId ().GetName () == "ns3::LteEnbNetDevice")||
1695
                  (dev->GetInstanceTypeId ().GetName () == "ns3::VirtualNetDevice"))
1708
                  (dev->GetInstanceTypeId ().GetName () == "ns3::VirtualNetDevice"))
1696
                {
1709
                {
1697
                  WriteNonP2pLinkProperties (n->GetId (), GetIpv4Address (dev) + "~" + GetMacAddress (dev), dev->GetInstanceTypeId ().GetName ());
1710
                  WriteNonP2pLinkProperties (n->GetId (), GetIpAddress (dev) + "~" + GetMacAddress (dev), dev->GetInstanceTypeId ().GetName ());
1698
                  AddToIpv4AddressNodeIdTable (GetIpv4Address (dev), n->GetId ());
1711
                  AddToIpv4AddressNodeIdTable (GetIpAddress (dev), n->GetId ());
1699
                }
1712
                }
1700
              continue;
1713
              continue;
1701
            }
1714
            }
 Lines 1712-1724    Link Here 
1712
                  if (n1Id < n2Id)
1725
                  if (n1Id < n2Id)
1713
                    { 
1726
                    { 
1714
                      // ouptut the p2p link
1727
                      // ouptut the p2p link
1715
                      NS_LOG_INFO ("Link:" << GetIpv4Address (dev) << ":" << GetMacAddress (dev) << "----" << GetIpv4Address (chDev) << ":" << GetMacAddress (chDev));
1728
                      NS_LOG_INFO ("Link:" << GetIpAddress (dev) << ":" << GetMacAddress (dev) << "----" << GetIpAddress (chDev) << ":" << GetMacAddress (chDev));
1716
                      AddToIpv4AddressNodeIdTable (GetIpv4Address (dev), n1Id);
1729
                      AddToIpv4AddressNodeIdTable (GetIpAddress (dev), n1Id);
1717
                      AddToIpv4AddressNodeIdTable (GetIpv4Address (chDev), n2Id);
1730
                      AddToIpv4AddressNodeIdTable (GetIpAddress (chDev), n2Id);
1718
                      P2pLinkNodeIdPair p2pPair;
1731
                      P2pLinkNodeIdPair p2pPair;
1719
                      p2pPair.fromNode = n1Id;
1732
                      p2pPair.fromNode = n1Id;
1720
                      p2pPair.toNode = n2Id;
1733
                      p2pPair.toNode = n2Id;
1721
                      LinkProperties lp = {GetIpv4Address (dev) + "~" + GetMacAddress (dev), GetIpv4Address (chDev) + "~" + GetMacAddress (chDev), ""};
1734
                      LinkProperties lp = {GetIpAddress (dev) + "~" + GetMacAddress (dev), GetIpAddress (chDev) + "~" + GetMacAddress (chDev), ""};
1722
                      m_linkProperties[p2pPair] = lp;
1735
                      m_linkProperties[p2pPair] = lp;
1723
                      WriteXmlLink (n1Id, 0, n2Id);
1736
                      WriteXmlLink (n1Id, 0, n2Id);
1724
                    }
1737
                    }
 Lines 1726-1734    Link Here 
1726
            }
1739
            }
1727
          else
1740
          else
1728
            {
1741
            {
1729
              NS_LOG_INFO ("Link:" << GetIpv4Address (dev) << " Channel Type:" << channelType << " Mac: " << GetMacAddress (dev));
1742
              NS_LOG_INFO ("Link:" << GetIpAddress (dev) << " Channel Type:" << channelType << " Mac: " << GetMacAddress (dev));
1730
              WriteNonP2pLinkProperties (n->GetId (), GetIpv4Address (dev) + "~" + GetMacAddress (dev), channelType); 
1743
              WriteNonP2pLinkProperties (n->GetId (), GetIpAddress (dev) + "~" + GetMacAddress (dev), channelType);
1731
              AddToIpv4AddressNodeIdTable (GetIpv4Address (dev), n->GetId ());
1744
              AddToIpv4AddressNodeIdTable (GetIpAddress (dev), n->GetId ());
1732
            }
1745
            }
1733
        }
1746
        }
1734
    }
1747
    }
(-)a/src/netanim/model/animation-interface.h (-1 / +1 lines)
 Lines 635-641    Link Here 
635
  int WriteN (const char*, uint32_t, FILE * f);
635
  int WriteN (const char*, uint32_t, FILE * f);
636
  int WriteN (const std::string&, FILE * f);
636
  int WriteN (const std::string&, FILE * f);
637
  std::string GetMacAddress (Ptr <NetDevice> nd);
637
  std::string GetMacAddress (Ptr <NetDevice> nd);
638
  std::string GetIpv4Address (Ptr <NetDevice> nd);
638
  std::string GetIpAddress (Ptr <NetDevice> nd);
639
  std::string GetNetAnimVersion ();
639
  std::string GetNetAnimVersion ();
640
  void MobilityAutoCheck ();
640
  void MobilityAutoCheck ();
641
  bool IsPacketPending (uint64_t animUid, ProtocolType protocolType);
641
  bool IsPacketPending (uint64_t animUid, ProtocolType protocolType);

Return to bug 2191