|
|
| 44 |
#include "ns3/wimax-mac-header.h" |
44 |
#include "ns3/wimax-mac-header.h" |
| 45 |
#include "ns3/wifi-net-device.h" |
45 |
#include "ns3/wifi-net-device.h" |
| 46 |
#include "ns3/wifi-mac.h" |
46 |
#include "ns3/wifi-mac.h" |
|
|
47 |
#include "ns3/lr-wpan-mac-header.h" |
| 48 |
#include "ns3/lr-wpan-net-device.h" |
| 47 |
#include "ns3/constant-position-mobility-model.h" |
49 |
#include "ns3/constant-position-mobility-model.h" |
| 48 |
#include "ns3/lte-ue-phy.h" |
50 |
#include "ns3/lte-ue-phy.h" |
| 49 |
#include "ns3/lte-enb-phy.h" |
51 |
#include "ns3/lte-enb-phy.h" |
|
|
| 454 |
PurgePendingPackets (AnimationInterface::WIMAX); |
456 |
PurgePendingPackets (AnimationInterface::WIMAX); |
| 455 |
PurgePendingPackets (AnimationInterface::LTE); |
457 |
PurgePendingPackets (AnimationInterface::LTE); |
| 456 |
PurgePendingPackets (AnimationInterface::CSMA); |
458 |
PurgePendingPackets (AnimationInterface::CSMA); |
|
|
459 |
PurgePendingPackets (AnimationInterface::LRWPAN); |
| 457 |
Simulator::Schedule (m_mobilityPollInterval, &AnimationInterface::MobilityAutoCheck, this); |
460 |
Simulator::Schedule (m_mobilityPollInterval, &AnimationInterface::MobilityAutoCheck, this); |
| 458 |
} |
461 |
} |
| 459 |
} |
462 |
} |
|
|
| 691 |
} |
694 |
} |
| 692 |
|
695 |
|
| 693 |
void |
696 |
void |
|
|
697 |
AnimationInterface::LrWpanMacTxTrace (std::string context, Ptr<const Packet> p) |
| 698 |
{ |
| 699 |
const Ptr <const Node> node = GetNodeFromContext (context); |
| 700 |
++m_nodeLrWpanMacTx[node->GetId ()]; |
| 701 |
} |
| 702 |
|
| 703 |
void |
| 704 |
AnimationInterface::LrWpanMacTxDropTrace (std::string context, Ptr<const Packet> p) |
| 705 |
{ |
| 706 |
const Ptr <const Node> node = GetNodeFromContext (context); |
| 707 |
++m_nodeLrWpanMacTxDrop[node->GetId ()]; |
| 708 |
} |
| 709 |
|
| 710 |
void |
| 711 |
AnimationInterface::LrWpanMacRxTrace (std::string context, Ptr<const Packet> p) |
| 712 |
{ |
| 713 |
const Ptr <const Node> node = GetNodeFromContext (context); |
| 714 |
++m_nodeLrWpanMacRx[node->GetId ()]; |
| 715 |
} |
| 716 |
|
| 717 |
void |
| 718 |
AnimationInterface::LrWpanMacRxDropTrace (std::string context, Ptr<const Packet> p) |
| 719 |
{ |
| 720 |
const Ptr <const Node> node = GetNodeFromContext (context); |
| 721 |
++m_nodeLrWpanMacRxDrop[node->GetId ()]; |
| 722 |
} |
| 723 |
|
| 724 |
void |
| 694 |
AnimationInterface::Ipv4TxTrace (std::string context, Ptr<const Packet> p, Ptr<Ipv4> ipv4, uint32_t interfaceIndex) |
725 |
AnimationInterface::Ipv4TxTrace (std::string context, Ptr<const Packet> p, Ptr<Ipv4> ipv4, uint32_t interfaceIndex) |
| 695 |
{ |
726 |
{ |
| 696 |
const Ptr <const Node> node = GetNodeFromContext (context); |
727 |
const Ptr <const Node> node = GetNodeFromContext (context); |
|
|
| 878 |
} |
909 |
} |
| 879 |
|
910 |
|
| 880 |
void |
911 |
void |
|
|
912 |
AnimationInterface::LrWpanPhyTxBeginTrace (std::string context, |
| 913 |
Ptr<const Packet> p) |
| 914 |
{ |
| 915 |
if (!m_started || !IsInTimeWindow () || !m_trackPackets) |
| 916 |
return; |
| 917 |
|
| 918 |
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context); |
| 919 |
NS_ASSERT (ndev); |
| 920 |
Ptr<LrWpanNetDevice> netDevice = DynamicCast<LrWpanNetDevice> (ndev); |
| 921 |
|
| 922 |
Ptr <Node> n = ndev->GetNode (); |
| 923 |
NS_ASSERT (n); |
| 924 |
|
| 925 |
UpdatePosition (n); |
| 926 |
|
| 927 |
LrWpanMacHeader hdr; |
| 928 |
if (!p->PeekHeader (hdr)) |
| 929 |
{ |
| 930 |
NS_LOG_WARN ("LrWpanMacHeader not present"); |
| 931 |
return; |
| 932 |
} |
| 933 |
|
| 934 |
std::ostringstream oss; |
| 935 |
if (hdr.GetSrcAddrMode () == 2) |
| 936 |
{ |
| 937 |
Mac16Address nodeAddr = netDevice->GetMac ()->GetShortAddress (); |
| 938 |
oss << nodeAddr; |
| 939 |
} |
| 940 |
else if (hdr.GetSrcAddrMode () == 3) |
| 941 |
{ |
| 942 |
Mac64Address nodeAddr = netDevice->GetMac ()->GetExtendedAddress (); |
| 943 |
oss << nodeAddr; |
| 944 |
} |
| 945 |
else |
| 946 |
{ |
| 947 |
NS_LOG_WARN ("LrWpanMacHeader without source address"); |
| 948 |
return; |
| 949 |
} |
| 950 |
m_macToNodeIdMap[oss.str ()] = n->GetId (); |
| 951 |
NS_LOG_INFO ("Added Mac" << oss.str () << " node:" <<m_macToNodeIdMap[oss.str ()]); |
| 952 |
|
| 953 |
++gAnimUid; |
| 954 |
NS_LOG_INFO ("LrWpan TxBeginTrace for packet:" << gAnimUid); |
| 955 |
AddByteTag (gAnimUid, p); |
| 956 |
|
| 957 |
AnimPacketInfo pktInfo (ndev, Simulator::Now ()); |
| 958 |
AddPendingPacket (AnimationInterface::LRWPAN, gAnimUid, pktInfo); |
| 959 |
|
| 960 |
OutputWirelessPacketTxInfo (p, m_pendingLrWpanPackets[gAnimUid], gAnimUid); |
| 961 |
} |
| 962 |
|
| 963 |
void |
| 964 |
AnimationInterface::LrWpanPhyRxBeginTrace (std::string context, |
| 965 |
Ptr<const Packet> p) |
| 966 |
{ |
| 967 |
if (!m_started || !IsInTimeWindow () || !m_trackPackets) |
| 968 |
return; |
| 969 |
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context); |
| 970 |
NS_ASSERT (ndev); |
| 971 |
Ptr <Node> n = ndev->GetNode (); |
| 972 |
NS_ASSERT (n); |
| 973 |
|
| 974 |
AnimByteTag tag; |
| 975 |
if (!p->FindFirstMatchingByteTag (tag)) |
| 976 |
{ |
| 977 |
return; |
| 978 |
} |
| 979 |
|
| 980 |
uint64_t animUid = GetAnimUidFromPacket (p); |
| 981 |
NS_LOG_INFO ("LrWpan RxBeginTrace for packet:" << animUid); |
| 982 |
if (!IsPacketPending (animUid, AnimationInterface::LRWPAN)) |
| 983 |
{ |
| 984 |
NS_LOG_WARN ("LrWpanPhyRxBeginTrace: unknown Uid - most probably it's an ACK."); |
| 985 |
} |
| 986 |
|
| 987 |
UpdatePosition (n); |
| 988 |
m_pendingLrWpanPackets[animUid].ProcessRxBegin (ndev, Simulator::Now ().GetSeconds ()); |
| 989 |
OutputWirelessPacketRxInfo (p, m_pendingLrWpanPackets[animUid], animUid); |
| 990 |
} |
| 991 |
|
| 992 |
void |
| 881 |
AnimationInterface::WimaxTxTrace (std::string context, Ptr<const Packet> p, const Mac48Address & m) |
993 |
AnimationInterface::WimaxTxTrace (std::string context, Ptr<const Packet> p, const Mac48Address & m) |
| 882 |
{ |
994 |
{ |
| 883 |
NS_LOG_FUNCTION (this); |
995 |
NS_LOG_FUNCTION (this); |
|
|
| 1172 |
pendingPackets = &m_pendingLtePackets; |
1284 |
pendingPackets = &m_pendingLtePackets; |
| 1173 |
break; |
1285 |
break; |
| 1174 |
} |
1286 |
} |
|
|
1287 |
case AnimationInterface::LRWPAN: |
| 1288 |
{ |
| 1289 |
pendingPackets = &m_pendingLrWpanPackets; |
| 1290 |
break; |
| 1291 |
} |
| 1175 |
} |
1292 |
} |
| 1176 |
return pendingPackets; |
1293 |
return pendingPackets; |
| 1177 |
|
1294 |
|
|
|
| 1208 |
result = "LTE"; |
1325 |
result = "LTE"; |
| 1209 |
break; |
1326 |
break; |
| 1210 |
} |
1327 |
} |
|
|
1328 |
case AnimationInterface::LRWPAN: |
| 1329 |
{ |
| 1330 |
result = "LRWPAN"; |
| 1331 |
break; |
| 1332 |
} |
| 1211 |
} |
1333 |
} |
| 1212 |
return result; |
1334 |
return result; |
| 1213 |
} |
1335 |
} |
|
|
| 1494 |
MakeCallback (&AnimationInterface::WifiPhyTxDropTrace, this)); |
1616 |
MakeCallback (&AnimationInterface::WifiPhyTxDropTrace, this)); |
| 1495 |
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop", |
1617 |
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop", |
| 1496 |
MakeCallback (&AnimationInterface::WifiPhyRxDropTrace, this)); |
1618 |
MakeCallback (&AnimationInterface::WifiPhyRxDropTrace, this)); |
|
|
1619 |
|
| 1620 |
// LrWpan |
| 1621 |
Config::Connect ("NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Phy/PhyTxBegin", |
| 1622 |
MakeCallback (&AnimationInterface::LrWpanPhyTxBeginTrace, this)); |
| 1623 |
Config::Connect ("NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Phy/PhyRxBegin", |
| 1624 |
MakeCallback (&AnimationInterface::LrWpanPhyRxBeginTrace, this)); |
| 1625 |
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacTx", |
| 1626 |
MakeCallback (&AnimationInterface::LrWpanMacTxTrace, this)); |
| 1627 |
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacTxDrop", |
| 1628 |
MakeCallback (&AnimationInterface::LrWpanMacTxDropTrace, this)); |
| 1629 |
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacRx", |
| 1630 |
MakeCallback (&AnimationInterface::LrWpanMacRxTrace, this)); |
| 1631 |
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacRxDrop", |
| 1632 |
MakeCallback (&AnimationInterface::LrWpanMacRxDropTrace, this)); |
| 1497 |
} |
1633 |
} |
| 1498 |
|
1634 |
|
| 1499 |
Vector |
1635 |
Vector |