|
|
| 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" |
|
|
| 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 |
|
|
|
| 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 |
} |
|
|
| 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 |
} |
|
|
| 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); |
|
|
| 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) |
|
|
| 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 |
|
|
|
| 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 |