NetAnim: Wave support

This commit is contained in:
John Abraham
2017-03-12 15:26:01 -07:00
parent 2913210dd8
commit c4c4537faa
3 changed files with 76 additions and 6 deletions

View File

@@ -458,6 +458,7 @@ AnimationInterface::MobilityAutoCheck ()
PurgePendingPackets (AnimationInterface::LTE);
PurgePendingPackets (AnimationInterface::CSMA);
PurgePendingPackets (AnimationInterface::LRWPAN);
PurgePendingPackets (AnimationInterface::WAVE);
Simulator::Schedule (m_mobilityPollInterval, &AnimationInterface::MobilityAutoCheck, this);
}
}
@@ -990,6 +991,52 @@ AnimationInterface::LrWpanPhyRxBeginTrace (std::string context,
OutputWirelessPacketRxInfo (p, m_pendingLrWpanPackets[animUid], animUid);
}
void
AnimationInterface::WavePhyTxBeginTrace (std::string context, Ptr<const Packet> p)
{
NS_LOG_FUNCTION (this);
return GenericWirelessTxTrace (context, p, AnimationInterface::WAVE);
}
void
AnimationInterface::WavePhyRxBeginTrace (std::string context, Ptr<const Packet> p)
{
NS_LOG_FUNCTION (this);
CHECK_STARTED_INTIMEWINDOW_TRACKPACKETS;
Ptr <NetDevice> ndev = GetNetDeviceFromContext (context);
NS_ASSERT (ndev);
UpdatePosition (ndev);
uint64_t animUid = GetAnimUidFromPacket (p);
NS_LOG_INFO ("Wave RxBeginTrace for packet:" << animUid);
if (!IsPacketPending (animUid, AnimationInterface::WAVE))
{
NS_ASSERT (0);
NS_LOG_WARN ("WavePhyRxBeginTrace: unknown Uid");
std::ostringstream oss;
WifiMacHeader hdr;
if (!p->PeekHeader (hdr))
{
NS_LOG_WARN ("WaveMacHeader not present");
return;
}
oss << hdr.GetAddr2 ();
if (m_macToNodeIdMap.find (oss.str ()) == m_macToNodeIdMap.end ())
{
NS_LOG_WARN ("Transmitter Mac address " << oss.str () << " never seen before. Skipping");
return;
}
Ptr <Node> txNode = NodeList::GetNode (m_macToNodeIdMap[oss.str ()]);
UpdatePosition (txNode);
AnimPacketInfo pktInfo (0, Simulator::Now (), m_macToNodeIdMap[oss.str ()]);
AddPendingPacket (AnimationInterface::WAVE, animUid, pktInfo);
NS_LOG_WARN ("WavePhyRxBegin: unknown Uid, but we are adding a wave packet");
}
/// \todo NS_ASSERT (WavePacketIsPending (animUid) == true);
m_pendingWavePackets[animUid].ProcessRxBegin (ndev, Simulator::Now ().GetSeconds ());
OutputWirelessPacketRxInfo (p, m_pendingWavePackets[animUid], animUid);
}
void
AnimationInterface::WimaxTxTrace (std::string context, Ptr<const Packet> p, const Mac48Address & m)
{
@@ -1290,6 +1337,11 @@ AnimationInterface::ProtocolTypeToPendingPackets (AnimationInterface::ProtocolTy
pendingPackets = &m_pendingLrWpanPackets;
break;
}
case AnimationInterface::WAVE:
{
pendingPackets = &m_pendingWavePackets;
break;
}
}
return pendingPackets;
@@ -1331,6 +1383,11 @@ AnimationInterface::ProtocolTypeToString (AnimationInterface::ProtocolType proto
result = "LRWPAN";
break;
}
case AnimationInterface::WAVE:
{
result = "WAVE";
break;
}
}
return result;
}
@@ -1631,6 +1688,12 @@ AnimationInterface::ConnectCallbacks ()
MakeCallback (&AnimationInterface::LrWpanMacRxTrace, this));
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacRxDrop",
MakeCallback (&AnimationInterface::LrWpanMacRxDropTrace, this));
// Wave
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/PhyTxBegin",
MakeCallback (&AnimationInterface::WavePhyTxBeginTrace, this));
Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WaveNetDevice/PhyEntities/*/$ns3::WifiPhy/PhyRxBegin",
MakeCallback (&AnimationInterface::WavePhyRxBeginTrace, this));
}
Vector
@@ -1878,13 +1941,13 @@ AnimationInterface::WriteLinkProperties ()
AddToIpv6AddressNodeIdTable(ipv6Addresses, n->GetId ());
if (!ipv4Addresses.empty ())
{
if (ipv4Addresses.size () > 1)
WriteNonP2pLinkProperties(n->GetId (), GetIpv4Address (dev) + "~" + GetMacAddress (dev), channelType);
NS_LOG_INFO ("Writing Ipv4 link");
WriteNonP2pLinkProperties(n->GetId (), GetIpv4Address (dev) + "~" + GetMacAddress (dev), channelType);
}
else if (!ipv6Addresses.empty ())
{
if (ipv6Addresses.size () > 1)
WriteNonP2pLinkProperties(n->GetId (), GetIpv6Address (dev) + "~" + GetMacAddress (dev), channelType);
NS_LOG_INFO ("Writing Ipv6 link");
WriteNonP2pLinkProperties(n->GetId (), GetIpv6Address (dev) + "~" + GetMacAddress (dev), channelType);
}
continue;
}

View File

@@ -498,7 +498,8 @@ private:
WIFI,
WIMAX,
CSMA,
LRWPAN
LRWPAN,
WAVE
} ProtocolType;
typedef struct
@@ -595,6 +596,8 @@ private:
AnimUidPacketInfoMap m_pendingLtePackets;
AnimUidPacketInfoMap m_pendingCsmaPackets;
AnimUidPacketInfoMap m_pendingUanPackets;
AnimUidPacketInfoMap m_pendingWavePackets;
std::map <uint32_t, Vector> m_nodeLocation;
std::map <std::string, uint32_t> m_macToNodeIdMap;
std::map <std::string, uint32_t> m_ipv4ToNodeIdMap;
@@ -725,6 +728,10 @@ private:
Ptr<const Packet> p);
void WifiPhyRxBeginTrace (std::string context,
Ptr<const Packet> p);
void WavePhyTxBeginTrace (std::string context,
Ptr<const Packet> p);
void WavePhyRxBeginTrace (std::string context,
Ptr<const Packet> p);
void LrWpanPhyTxBeginTrace (std::string context,
Ptr<const Packet> p);
void LrWpanPhyRxBeginTrace (std::string context,

View File

@@ -6,7 +6,7 @@ import wutils
NETANIM_RELEASE_NAME = "netanim-3.108"
def build (bld) :
module = bld.create_ns3_module ('netanim', ['internet', 'mobility', 'wimax', 'wifi', 'csma', 'lte', 'uan', 'lr-wpan', 'energy'])
module = bld.create_ns3_module ('netanim', ['internet', 'mobility', 'wimax', 'wifi', 'csma', 'lte', 'uan', 'lr-wpan', 'energy', 'wave'])
module.includes = '.'
module.source = [ 'model/animation-interface.cc', ]
netanim_test = bld.create_ns3_module_test_library('netanim')