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

(-)a/src/lr-wpan/model/lr-wpan-phy.cc (-3 / +4 lines)
 Lines 546-551    Link Here 
546
          LrWpanLqiTag lqiTag;
546
          LrWpanLqiTag lqiTag;
547
          p->RemovePacketTag (lqiTag);
547
          p->RemovePacketTag (lqiTag);
548
548
549
          m_phyTxBeginTrace (p);
550
          m_currentTxPacket.first = p;
551
          m_currentTxPacket.second = false;
552
549
          Ptr<LrWpanSpectrumSignalParameters> txParams = Create<LrWpanSpectrumSignalParameters> ();
553
          Ptr<LrWpanSpectrumSignalParameters> txParams = Create<LrWpanSpectrumSignalParameters> ();
550
          txParams->duration = CalculateTxTime (p);
554
          txParams->duration = CalculateTxTime (p);
551
          txParams->txPhy = GetObject<SpectrumPhy> ();
555
          txParams->txPhy = GetObject<SpectrumPhy> ();
 Lines 557-565    Link Here 
557
          m_channel->StartTx (txParams);
561
          m_channel->StartTx (txParams);
558
          m_pdDataRequest = Simulator::Schedule (txParams->duration, &LrWpanPhy::EndTx, this);
562
          m_pdDataRequest = Simulator::Schedule (txParams->duration, &LrWpanPhy::EndTx, this);
559
          ChangeTrxState (IEEE_802_15_4_PHY_BUSY_TX);
563
          ChangeTrxState (IEEE_802_15_4_PHY_BUSY_TX);
560
          m_phyTxBeginTrace (p);
561
          m_currentTxPacket.first = p;
562
          m_currentTxPacket.second = false;
563
          return;
564
          return;
564
        }
565
        }
565
      else if ((m_trxState == IEEE_802_15_4_PHY_RX_ON)
566
      else if ((m_trxState == IEEE_802_15_4_PHY_RX_ON)
(-)a/src/netanim/model/animation-interface.cc (+132 lines)
 Lines 40-45    Link Here 
40
#include "ns3/simulator.h"
40
#include "ns3/simulator.h"
41
#include "ns3/wifi-mac-header.h"
41
#include "ns3/wifi-mac-header.h"
42
#include "ns3/wimax-mac-header.h"
42
#include "ns3/wimax-mac-header.h"
43
#include "ns3/lr-wpan-mac-header.h"
43
#include "ns3/wifi-net-device.h"
44
#include "ns3/wifi-net-device.h"
44
#include "ns3/wifi-mac.h"
45
#include "ns3/wifi-mac.h"
45
#include "ns3/constant-position-mobility-model.h"
46
#include "ns3/constant-position-mobility-model.h"
 Lines 50-55    Link Here 
50
#include "ns3/ipv4.h"
51
#include "ns3/ipv4.h"
51
#include "ns3/ipv4-routing-protocol.h"
52
#include "ns3/ipv4-routing-protocol.h"
52
#include "ns3/energy-source-container.h"
53
#include "ns3/energy-source-container.h"
54
#include "ns3/lr-wpan-net-device.h"
53
55
54
namespace ns3 {
56
namespace ns3 {
55
57
 Lines 449-454    Link Here 
449
      PurgePendingPackets (AnimationInterface::WIMAX);
451
      PurgePendingPackets (AnimationInterface::WIMAX);
450
      PurgePendingPackets (AnimationInterface::LTE);
452
      PurgePendingPackets (AnimationInterface::LTE);
451
      PurgePendingPackets (AnimationInterface::CSMA);
453
      PurgePendingPackets (AnimationInterface::CSMA);
454
      PurgePendingPackets (AnimationInterface::LRWPAN);
452
      Simulator::Schedule (m_mobilityPollInterval, &AnimationInterface::MobilityAutoCheck, this);
455
      Simulator::Schedule (m_mobilityPollInterval, &AnimationInterface::MobilityAutoCheck, this);
453
    }
456
    }
454
}
457
}
 Lines 606-611    Link Here 
606
    }
609
    }
607
  else
610
  else
608
    {
611
    {
612
      NS_ASSERT_MSG (0, "No AnimUid found");
609
      return 0;
613
      return 0;
610
    }
614
    }
611
}
615
}
 Lines 684-689    Link Here 
684
}
688
}
685
689
686
void
690
void
691
AnimationInterface::LrWpanMacTxTrace (std::string context, Ptr<const Packet> p)
692
{
693
  const Ptr <const Node> node = GetNodeFromContext (context);
694
  ++m_nodeLrWpanMacTx[node->GetId ()];
695
}
696
697
void
698
AnimationInterface::LrWpanMacTxDropTrace (std::string context, Ptr<const Packet> p)
699
{
700
  const Ptr <const Node> node = GetNodeFromContext (context);
701
  ++m_nodeLrWpanMacTxDrop[node->GetId ()];
702
}
703
704
void
705
AnimationInterface::LrWpanMacRxTrace (std::string context, Ptr<const Packet> p)
706
{
707
  const Ptr <const Node> node = GetNodeFromContext (context);
708
  ++m_nodeLrWpanMacRx[node->GetId ()];
709
}
710
711
void
712
AnimationInterface::LrWpanMacRxDropTrace (std::string context, Ptr<const Packet> p)
713
{
714
  const Ptr <const Node> node = GetNodeFromContext (context);
715
  ++m_nodeLrWpanMacRxDrop[node->GetId ()];
716
}
717
718
void
687
AnimationInterface::Ipv4TxTrace (std::string context, Ptr<const Packet> p, Ptr<Ipv4> ipv4, uint32_t interfaceIndex)
719
AnimationInterface::Ipv4TxTrace (std::string context, Ptr<const Packet> p, Ptr<Ipv4> ipv4, uint32_t interfaceIndex)
688
{
720
{
689
  const Ptr <const Node> node = GetNodeFromContext (context);
721
  const Ptr <const Node> node = GetNodeFromContext (context);
 Lines 869-874    Link Here 
869
}
901
}
870
902
871
void 
903
void 
904
AnimationInterface::LrWpanPhyTxBeginTrace (std::string context,
905
                                           Ptr<const Packet> p)
906
{
907
  if (!m_started || !IsInTimeWindow () || !m_trackPackets)
908
    return;
909
910
  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
911
  NS_ASSERT (ndev);
912
  Ptr<LrWpanNetDevice> netDevice = DynamicCast<LrWpanNetDevice> (ndev);
913
914
  Ptr <Node> n = ndev->GetNode ();
915
  NS_ASSERT (n);
916
917
  UpdatePosition (n);
918
919
  LrWpanMacHeader hdr;
920
  if (!p->PeekHeader (hdr))
921
  {
922
    NS_LOG_WARN ("LrWpanMacHeader not present");
923
    return;
924
  }
925
926
  std::ostringstream oss;
927
  if (hdr.GetSrcAddrMode () == 2)
928
    {
929
      Mac16Address nodeAddr = netDevice->GetMac ()->GetShortAddress ();
930
      oss << nodeAddr;
931
    }
932
  else if (hdr.GetSrcAddrMode () == 3)
933
    {
934
      Mac64Address nodeAddr = netDevice->GetMac ()->GetExtendedAddress ();
935
      oss << nodeAddr;
936
    }
937
  else
938
    {
939
      NS_LOG_WARN ("LrWpanMacHeader without source address");
940
      return;
941
    }
942
  m_macToNodeIdMap[oss.str ()] = n->GetId ();
943
  NS_LOG_INFO ("Added Mac" << oss.str () << " node:" <<m_macToNodeIdMap[oss.str ()]);
944
945
  ++gAnimUid;
946
  NS_LOG_INFO ("LrWpan TxBeginTrace for packet:" << gAnimUid);
947
  AddByteTag (gAnimUid, p);
948
949
  AnimPacketInfo pktInfo (ndev, Simulator::Now ());
950
  AddPendingPacket (AnimationInterface::LRWPAN, gAnimUid, pktInfo);
951
952
  OutputWirelessPacketTxInfo (p, m_pendingLrWpanPackets[gAnimUid], gAnimUid);
953
}
954
955
void
956
AnimationInterface::LrWpanPhyRxBeginTrace (std::string context,
957
                                           Ptr<const Packet> p)
958
{
959
  if (!m_started || !IsInTimeWindow () || !m_trackPackets)
960
    return;
961
  Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
962
  NS_ASSERT (ndev);
963
  Ptr <Node> n = ndev->GetNode ();
964
  NS_ASSERT (n);
965
966
  AnimByteTag tag;
967
  if (!p->FindFirstMatchingByteTag (tag))
968
    {
969
      return;
970
    }
971
972
  uint64_t animUid = GetAnimUidFromPacket (p);
973
  NS_LOG_INFO ("LrWpan RxBeginTrace for packet:" << animUid);
974
  if (!IsPacketPending (animUid, AnimationInterface::LRWPAN))
975
    {
976
      NS_LOG_WARN ("LrWpanPhyRxBeginTrace: unknown Uid - most probably it's an ACK.");
977
    }
978
979
  UpdatePosition (n);
980
  m_pendingLrWpanPackets[animUid].ProcessRxBegin (ndev, Simulator::Now ().GetSeconds ());
981
  OutputWirelessPacketRxInfo (p, m_pendingLrWpanPackets[animUid], animUid);
982
}
983
984
void
872
AnimationInterface::WimaxTxTrace (std::string context, Ptr<const Packet> p, const Mac48Address & m)
985
AnimationInterface::WimaxTxTrace (std::string context, Ptr<const Packet> p, const Mac48Address & m)
873
{
986
{
874
  if (!m_started || !IsInTimeWindow () || !m_trackPackets)
987
  if (!m_started || !IsInTimeWindow () || !m_trackPackets)
 Lines 1218-1223    Link Here 
1218
          pendingPackets = &m_pendingLtePackets;
1331
          pendingPackets = &m_pendingLtePackets;
1219
          break;
1332
          break;
1220
        }
1333
        }
1334
      case AnimationInterface::LRWPAN:
1335
        {
1336
          pendingPackets = &m_pendingLrWpanPackets;
1337
          break;
1338
        }
1221
    }
1339
    }
1222
  return pendingPackets;
1340
  return pendingPackets;
1223
1341
 Lines 1474-1479    Link Here 
1474
                   MakeCallback (&AnimationInterface::WifiPhyTxDropTrace, this));
1592
                   MakeCallback (&AnimationInterface::WifiPhyTxDropTrace, this));
1475
  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop",
1593
  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop",
1476
                   MakeCallback (&AnimationInterface::WifiPhyRxDropTrace, this));
1594
                   MakeCallback (&AnimationInterface::WifiPhyRxDropTrace, this));
1595
1596
  // LrWpan
1597
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Phy/PhyTxBegin",
1598
                   MakeCallback (&AnimationInterface::LrWpanPhyTxBeginTrace, this));
1599
  Config::Connect ("NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Phy/PhyRxBegin",
1600
                   MakeCallback (&AnimationInterface::LrWpanPhyRxBeginTrace, this));
1601
  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacTx",
1602
                   MakeCallback (&AnimationInterface::LrWpanMacTxTrace, this));
1603
  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacTxDrop",
1604
                   MakeCallback (&AnimationInterface::LrWpanMacTxDropTrace, this));
1605
  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacRx",
1606
                   MakeCallback (&AnimationInterface::LrWpanMacRxTrace, this));
1607
  Config::Connect ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacRxDrop",
1608
                   MakeCallback (&AnimationInterface::LrWpanMacRxDropTrace, this));
1477
}
1609
}
1478
1610
1479
Vector 
1611
Vector 
(-)a/src/netanim/model/animation-interface.h (-3 / +21 lines)
 Lines 495-501    Link Here 
495
      LTE,
495
      LTE,
496
      WIFI,
496
      WIFI,
497
      WIMAX,
497
      WIMAX,
498
      CSMA
498
      CSMA,
499
      LRWPAN
499
    } ProtocolType;
500
    } ProtocolType;
500
501
501
  typedef struct
502
  typedef struct
 Lines 588-593    Link Here 
588
  AnimUidPacketInfoMap m_pendingLtePackets;
589
  AnimUidPacketInfoMap m_pendingLtePackets;
589
  AnimUidPacketInfoMap m_pendingCsmaPackets;
590
  AnimUidPacketInfoMap m_pendingCsmaPackets;
590
  AnimUidPacketInfoMap m_pendingUanPackets;
591
  AnimUidPacketInfoMap m_pendingUanPackets;
592
  AnimUidPacketInfoMap m_pendingLrWpanPackets;
591
  std::map <uint32_t, Vector> m_nodeLocation;
593
  std::map <uint32_t, Vector> m_nodeLocation;
592
  std::map <std::string, uint32_t> m_macToNodeIdMap;
594
  std::map <std::string, uint32_t> m_macToNodeIdMap;
593
  std::map <std::string, uint32_t> m_ipv4ToNodeIdMap;
595
  std::map <std::string, uint32_t> m_ipv4ToNodeIdMap;
 Lines 614-619    Link Here 
614
  NodeCounterMap64 m_nodeWifiMacRxDrop;
616
  NodeCounterMap64 m_nodeWifiMacRxDrop;
615
  NodeCounterMap64 m_nodeWifiPhyTxDrop;
617
  NodeCounterMap64 m_nodeWifiPhyTxDrop;
616
  NodeCounterMap64 m_nodeWifiPhyRxDrop;
618
  NodeCounterMap64 m_nodeWifiPhyRxDrop;
619
  NodeCounterMap64 m_nodeLrWpanMacTx;
620
  NodeCounterMap64 m_nodeLrWpanMacTxDrop;
621
  NodeCounterMap64 m_nodeLrWpanMacRx;
622
  NodeCounterMap64 m_nodeLrWpanMacRxDrop;
617
623
618
  const std::vector<std::string> GetElementsFromContext (const std::string& context) const;
624
  const std::vector<std::string> GetElementsFromContext (const std::string& context) const;
619
  Ptr <Node> GetNodeFromContext (const std::string& context) const;
625
  Ptr <Node> GetNodeFromContext (const std::string& context) const;
 Lines 681-689    Link Here 
681
  void WifiMacRxDropTrace (std::string context,
687
  void WifiMacRxDropTrace (std::string context,
682
                           Ptr<const Packet>);
688
                           Ptr<const Packet>);
683
  void WifiPhyTxDropTrace (std::string context,
689
  void WifiPhyTxDropTrace (std::string context,
684
                       Ptr<const Packet>);
690
                           Ptr<const Packet>);
685
  void WifiPhyRxDropTrace (std::string context,
691
  void WifiPhyRxDropTrace (std::string context,
686
                       Ptr<const Packet>);
692
                           Ptr<const Packet>);
693
  void LrWpanMacTxTrace (std::string context,
694
                         Ptr<const Packet>);
695
  void LrWpanMacTxDropTrace (std::string context,
696
                             Ptr<const Packet>);
697
  void LrWpanMacRxTrace (std::string context,
698
                         Ptr<const Packet>);
699
  void LrWpanMacRxDropTrace (std::string context,
700
                             Ptr<const Packet>);
687
  void DevTxTrace (std::string context,
701
  void DevTxTrace (std::string context,
688
                   Ptr<const Packet> p,
702
                   Ptr<const Packet> p,
689
                   Ptr<NetDevice> tx,
703
                   Ptr<NetDevice> tx,
 Lines 694-699    Link Here 
694
                            Ptr<const Packet> p);
708
                            Ptr<const Packet> p);
695
  void WifiPhyRxBeginTrace (std::string context,
709
  void WifiPhyRxBeginTrace (std::string context,
696
                            Ptr<const Packet> p);
710
                            Ptr<const Packet> p);
711
  void LrWpanPhyTxBeginTrace (std::string context,
712
                              Ptr<const Packet> p);
713
  void LrWpanPhyRxBeginTrace (std::string context,
714
                              Ptr<const Packet> p);
697
  void WimaxTxTrace (std::string context,
715
  void WimaxTxTrace (std::string context,
698
                     Ptr<const Packet> p,
716
                     Ptr<const Packet> p,
699
		     const Mac48Address &);
717
		     const Mac48Address &);
(-)a/src/netanim/wscript (-1 / +1 lines)
 Lines 6-12    Link Here 
6
NETANIM_RELEASE_NAME = "netanim-3.106"
6
NETANIM_RELEASE_NAME = "netanim-3.106"
7
7
8
def build (bld) :
8
def build (bld) :
9
    module = bld.create_ns3_module ('netanim', ['internet', 'mobility', 'wimax', 'wifi', 'csma', 'lte', 'uan', 'energy'])
9
    module = bld.create_ns3_module ('netanim', ['internet', 'mobility', 'wimax', 'wifi', 'csma', 'lte', 'uan', 'energy', 'lr-wpan'])
10
    module.includes = '.'
10
    module.includes = '.'
11
    module.source = [ 'model/animation-interface.cc', ]
11
    module.source = [ 'model/animation-interface.cc', ]
12
    netanim_test = bld.create_ns3_module_test_library('netanim')
12
    netanim_test = bld.create_ns3_module_test_library('netanim')

Return to bug 2190