LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * This program is free software; you can redistribute it and/or modify | 3 * This program is free software; you can redistribute it and/or modify |
4 * it under the terms of the GNU General Public License version 2 as | 4 * it under the terms of the GNU General Public License version 2 as |
5 * published by the Free Software Foundation; | 5 * published by the Free Software Foundation; |
6 * | 6 * |
7 * This program is distributed in the hope that it will be useful, | 7 * This program is distributed in the hope that it will be useful, |
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 * GNU General Public License for more details. | 10 * GNU General Public License for more details. |
11 * | 11 * |
12 * You should have received a copy of the GNU General Public License | 12 * You should have received a copy of the GNU General Public License |
13 * along with this program; if not, write to the Free Software | 13 * along with this program; if not, write to the Free Software |
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
15 * | 15 * |
16 * Author: George F. Riley<riley@ece.gatech.edu> | 16 * Author: George F. Riley<riley@ece.gatech.edu> |
17 * Modified by: John Abraham <john.abraham@gatech.edu> | 17 * Modified by: John Abraham <john.abraham@gatech.edu> |
18 * Contributions: Eugene Kalishenko <ydginster@gmail.com> (Open Source and Linux
Laboratory http://dev.osll.ru/) | 18 * Contributions: Eugene Kalishenko <ydginster@gmail.com> (Open Source and Linux
Laboratory http://dev.osll.ru/) |
| 19 * Tommaso Pecorella <tommaso.pecorella@unifi.it> |
| 20 * Pavel Vasilyev <pavel.vasilyev@sredasolutions.com> |
19 */ | 21 */ |
20 | 22 |
21 // Interface between ns-3 and the network animator | 23 // Interface between ns-3 and the network animator |
22 | 24 |
23 | 25 |
24 | 26 |
25 #include <cstdio> | 27 #include <cstdio> |
| 28 #ifndef WIN32 |
26 #include <unistd.h> | 29 #include <unistd.h> |
| 30 #endif |
27 #include <sstream> | 31 #include <sstream> |
28 #include <fstream> | 32 #include <fstream> |
29 #include <string> | 33 #include <string> |
30 #include <iomanip> | 34 #include <iomanip> |
31 #include <map> | 35 #include <map> |
32 | 36 |
33 // ns3 includes | 37 // ns3 includes |
34 #include "ns3/animation-interface.h" | 38 #include "ns3/animation-interface.h" |
35 #include "ns3/channel.h" | 39 #include "ns3/channel.h" |
36 #include "ns3/config.h" | 40 #include "ns3/config.h" |
37 #include "ns3/node.h" | 41 #include "ns3/node.h" |
38 #include "ns3/mobility-model.h" | 42 #include "ns3/mobility-model.h" |
39 #include "ns3/packet.h" | 43 #include "ns3/packet.h" |
40 #include "ns3/simulator.h" | 44 #include "ns3/simulator.h" |
41 #include "ns3/wifi-mac-header.h" | 45 #include "ns3/wifi-mac-header.h" |
42 #include "ns3/wimax-mac-header.h" | 46 #include "ns3/wimax-mac-header.h" |
43 #include "ns3/wifi-net-device.h" | 47 #include "ns3/wifi-net-device.h" |
44 #include "ns3/wifi-mac.h" | 48 #include "ns3/wifi-mac.h" |
| 49 #include "ns3/lr-wpan-mac-header.h" |
| 50 #include "ns3/lr-wpan-net-device.h" |
45 #include "ns3/constant-position-mobility-model.h" | 51 #include "ns3/constant-position-mobility-model.h" |
46 #include "ns3/lte-ue-phy.h" | 52 #include "ns3/lte-ue-phy.h" |
47 #include "ns3/lte-enb-phy.h" | 53 #include "ns3/lte-enb-phy.h" |
48 #include "ns3/uan-net-device.h" | 54 #include "ns3/uan-net-device.h" |
49 #include "ns3/uan-mac.h" | 55 #include "ns3/uan-mac.h" |
| 56 #include "ns3/double.h" |
50 #include "ns3/ipv4.h" | 57 #include "ns3/ipv4.h" |
| 58 #include "ns3/ipv6.h" |
51 #include "ns3/ipv4-routing-protocol.h" | 59 #include "ns3/ipv4-routing-protocol.h" |
52 #include "ns3/energy-source-container.h" | 60 #include "ns3/energy-source-container.h" |
| 61 #include "animation-interface.h" |
53 | 62 |
54 namespace ns3 { | 63 namespace ns3 { |
55 | 64 |
56 NS_LOG_COMPONENT_DEFINE ("AnimationInterface"); | 65 NS_LOG_COMPONENT_DEFINE ("AnimationInterface"); |
57 | 66 |
58 // Globals | 67 // Globals |
59 | 68 |
60 static bool initialized = false; ///< initialized indicator | 69 static bool initialized = false; ///< initialized indicator |
61 | 70 |
62 | 71 |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 NS_ASSERT (n); | 451 NS_ASSERT (n); |
443 Vector v = GetPosition (n); | 452 Vector v = GetPosition (n); |
444 WriteXmlUpdateNodePosition (n->GetId () , v.x, v.y); | 453 WriteXmlUpdateNodePosition (n->GetId () , v.x, v.y); |
445 } | 454 } |
446 if (!Simulator::IsFinished ()) | 455 if (!Simulator::IsFinished ()) |
447 { | 456 { |
448 PurgePendingPackets (AnimationInterface::WIFI); | 457 PurgePendingPackets (AnimationInterface::WIFI); |
449 PurgePendingPackets (AnimationInterface::WIMAX); | 458 PurgePendingPackets (AnimationInterface::WIMAX); |
450 PurgePendingPackets (AnimationInterface::LTE); | 459 PurgePendingPackets (AnimationInterface::LTE); |
451 PurgePendingPackets (AnimationInterface::CSMA); | 460 PurgePendingPackets (AnimationInterface::CSMA); |
| 461 PurgePendingPackets (AnimationInterface::LRWPAN); |
| 462 PurgePendingPackets (AnimationInterface::WAVE); |
452 Simulator::Schedule (m_mobilityPollInterval, &AnimationInterface::Mobility
AutoCheck, this); | 463 Simulator::Schedule (m_mobilityPollInterval, &AnimationInterface::Mobility
AutoCheck, this); |
453 } | 464 } |
454 } | 465 } |
455 | 466 |
456 std::vector <Ptr <Node> >·· | 467 std::vector <Ptr <Node> >·· |
457 AnimationInterface::GetMovedNodes () | 468 AnimationInterface::GetMovedNodes () |
458 { | 469 { |
459 std::vector < Ptr <Node> > movedNodes; | 470 std::vector < Ptr <Node> > movedNodes; |
460 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i) | 471 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i) |
461 { | 472 { |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 { | 687 { |
677 const Ptr <const Node> node = GetNodeFromContext (context); | 688 const Ptr <const Node> node = GetNodeFromContext (context); |
678 ++m_nodeWifiMacRx[node->GetId ()]; | 689 ++m_nodeWifiMacRx[node->GetId ()]; |
679 } | 690 } |
680 | 691 |
681 void | 692 void |
682 AnimationInterface::WifiMacRxDropTrace (std::string context, Ptr<const Packet> p
) | 693 AnimationInterface::WifiMacRxDropTrace (std::string context, Ptr<const Packet> p
) |
683 { | 694 { |
684 const Ptr <const Node> node = GetNodeFromContext (context); | 695 const Ptr <const Node> node = GetNodeFromContext (context); |
685 ++m_nodeWifiMacRxDrop[node->GetId ()]; | 696 ++m_nodeWifiMacRxDrop[node->GetId ()]; |
| 697 } |
| 698 |
| 699 void |
| 700 AnimationInterface::LrWpanMacTxTrace (std::string context, Ptr<const Packet> p) |
| 701 { |
| 702 const Ptr <const Node> node = GetNodeFromContext (context); |
| 703 ++m_nodeLrWpanMacTx[node->GetId ()]; |
| 704 } |
| 705 |
| 706 void |
| 707 AnimationInterface::LrWpanMacTxDropTrace (std::string context, Ptr<const Packet>
p) |
| 708 { |
| 709 const Ptr <const Node> node = GetNodeFromContext (context); |
| 710 ++m_nodeLrWpanMacTxDrop[node->GetId ()]; |
| 711 } |
| 712 |
| 713 void |
| 714 AnimationInterface::LrWpanMacRxTrace (std::string context, Ptr<const Packet> p) |
| 715 { |
| 716 const Ptr <const Node> node = GetNodeFromContext (context); |
| 717 ++m_nodeLrWpanMacRx[node->GetId ()]; |
| 718 } |
| 719 |
| 720 void |
| 721 AnimationInterface::LrWpanMacRxDropTrace (std::string context, Ptr<const Packet>
p) |
| 722 { |
| 723 const Ptr <const Node> node = GetNodeFromContext (context); |
| 724 ++m_nodeLrWpanMacRxDrop[node->GetId ()]; |
686 } | 725 } |
687 | 726 |
688 void | 727 void |
689 AnimationInterface::Ipv4TxTrace (std::string context, Ptr<const Packet> p, Ptr<I
pv4> ipv4, uint32_t interfaceIndex) | 728 AnimationInterface::Ipv4TxTrace (std::string context, Ptr<const Packet> p, Ptr<I
pv4> ipv4, uint32_t interfaceIndex) |
690 { | 729 { |
691 const Ptr <const Node> node = GetNodeFromContext (context); | 730 const Ptr <const Node> node = GetNodeFromContext (context); |
692 ++m_nodeIpv4Tx[node->GetId ()]; | 731 ++m_nodeIpv4Tx[node->GetId ()]; |
693 } | 732 } |
694 · | 733 · |
695 void | 734 void |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 AnimPacketInfo pktInfo (0, Simulator::Now (), m_macToNodeIdMap[oss.str ()]
); | 905 AnimPacketInfo pktInfo (0, Simulator::Now (), m_macToNodeIdMap[oss.str ()]
); |
867 AddPendingPacket (AnimationInterface::WIFI, animUid, pktInfo); | 906 AddPendingPacket (AnimationInterface::WIFI, animUid, pktInfo); |
868 NS_LOG_WARN ("WifiPhyRxBegin: unknown Uid, but we are adding a wifi packet
"); | 907 NS_LOG_WARN ("WifiPhyRxBegin: unknown Uid, but we are adding a wifi packet
"); |
869 } | 908 } |
870 /// \todo NS_ASSERT (WifiPacketIsPending (animUid) == true); | 909 /// \todo NS_ASSERT (WifiPacketIsPending (animUid) == true); |
871 m_pendingWifiPackets[animUid].ProcessRxBegin (ndev, Simulator::Now ().GetSecon
ds ()); | 910 m_pendingWifiPackets[animUid].ProcessRxBegin (ndev, Simulator::Now ().GetSecon
ds ()); |
872 OutputWirelessPacketRxInfo (p, m_pendingWifiPackets[animUid], animUid); | 911 OutputWirelessPacketRxInfo (p, m_pendingWifiPackets[animUid], animUid); |
873 } | 912 } |
874 | 913 |
875 void· | 914 void· |
| 915 AnimationInterface::LrWpanPhyTxBeginTrace (std::string context, |
| 916 Ptr<const Packet> p) |
| 917 { |
| 918 NS_LOG_FUNCTION (this); |
| 919 CHECK_STARTED_INTIMEWINDOW_TRACKPACKETS; |
| 920 |
| 921 Ptr <NetDevice> ndev = GetNetDeviceFromContext (context); |
| 922 NS_ASSERT (ndev); |
| 923 Ptr<LrWpanNetDevice> netDevice = DynamicCast<LrWpanNetDevice> (ndev); |
| 924 |
| 925 Ptr <Node> n = ndev->GetNode (); |
| 926 NS_ASSERT (n); |
| 927 |
| 928 UpdatePosition (n); |
| 929 |
| 930 LrWpanMacHeader hdr; |
| 931 if (!p->PeekHeader (hdr)) |
| 932 { |
| 933 NS_LOG_WARN ("LrWpanMacHeader not present"); |
| 934 return; |
| 935 } |
| 936 |
| 937 std::ostringstream oss; |
| 938 if (hdr.GetSrcAddrMode () == 2) |
| 939 { |
| 940 Mac16Address nodeAddr = netDevice->GetMac ()->GetShortAddress (); |
| 941 oss << nodeAddr; |
| 942 } |
| 943 else if (hdr.GetSrcAddrMode () == 3) |
| 944 { |
| 945 Mac64Address nodeAddr = netDevice->GetMac ()->GetExtendedAddress (); |
| 946 oss << nodeAddr; |
| 947 } |
| 948 else |
| 949 { |
| 950 NS_LOG_WARN ("LrWpanMacHeader without source address"); |
| 951 return; |
| 952 } |
| 953 m_macToNodeIdMap[oss.str ()] = n->GetId (); |
| 954 NS_LOG_INFO ("Added Mac" << oss.str () << " node:" <<m_macToNodeIdMap[oss.str
()]); |
| 955 |
| 956 ++gAnimUid; |
| 957 NS_LOG_INFO ("LrWpan TxBeginTrace for packet:" << gAnimUid); |
| 958 AddByteTag (gAnimUid, p); |
| 959 |
| 960 AnimPacketInfo pktInfo (ndev, Simulator::Now ()); |
| 961 AddPendingPacket (AnimationInterface::LRWPAN, gAnimUid, pktInfo); |
| 962 |
| 963 OutputWirelessPacketTxInfo (p, m_pendingLrWpanPackets[gAnimUid], gAnimUid); |
| 964 } |
| 965 |
| 966 void |
| 967 AnimationInterface::LrWpanPhyRxBeginTrace (std::string context, |
| 968 Ptr<const Packet> p) |
| 969 { |
| 970 NS_LOG_FUNCTION (this); |
| 971 CHECK_STARTED_INTIMEWINDOW_TRACKPACKETS; |
| 972 Ptr <NetDevice> ndev = GetNetDeviceFromContext (context); |
| 973 NS_ASSERT (ndev); |
| 974 Ptr <Node> n = ndev->GetNode (); |
| 975 NS_ASSERT (n); |
| 976 |
| 977 AnimByteTag tag; |
| 978 if (!p->FindFirstMatchingByteTag (tag)) |
| 979 { |
| 980 return; |
| 981 } |
| 982 |
| 983 uint64_t animUid = GetAnimUidFromPacket (p); |
| 984 NS_LOG_INFO ("LrWpan RxBeginTrace for packet:" << animUid); |
| 985 if (!IsPacketPending (animUid, AnimationInterface::LRWPAN)) |
| 986 { |
| 987 NS_LOG_WARN ("LrWpanPhyRxBeginTrace: unknown Uid - most probably it's an A
CK."); |
| 988 } |
| 989 |
| 990 UpdatePosition (n); |
| 991 m_pendingLrWpanPackets[animUid].ProcessRxBegin (ndev, Simulator::Now ().GetSec
onds ()); |
| 992 OutputWirelessPacketRxInfo (p, m_pendingLrWpanPackets[animUid], animUid); |
| 993 } |
| 994 |
| 995 void |
| 996 AnimationInterface::WavePhyTxBeginTrace (std::string context, Ptr<const Packet>
p) |
| 997 { |
| 998 NS_LOG_FUNCTION (this); |
| 999 return GenericWirelessTxTrace (context, p, AnimationInterface::WAVE); |
| 1000 } |
| 1001 |
| 1002 void |
| 1003 AnimationInterface::WavePhyRxBeginTrace (std::string context, Ptr<const Packet>
p) |
| 1004 { |
| 1005 NS_LOG_FUNCTION (this); |
| 1006 CHECK_STARTED_INTIMEWINDOW_TRACKPACKETS; |
| 1007 Ptr <NetDevice> ndev = GetNetDeviceFromContext (context); |
| 1008 NS_ASSERT (ndev); |
| 1009 UpdatePosition (ndev); |
| 1010 uint64_t animUid = GetAnimUidFromPacket (p); |
| 1011 NS_LOG_INFO ("Wave RxBeginTrace for packet:" << animUid); |
| 1012 if (!IsPacketPending (animUid, AnimationInterface::WAVE)) |
| 1013 { |
| 1014 NS_ASSERT (0); |
| 1015 NS_LOG_WARN ("WavePhyRxBeginTrace: unknown Uid"); |
| 1016 std::ostringstream oss; |
| 1017 WifiMacHeader hdr; |
| 1018 if (!p->PeekHeader (hdr)) |
| 1019 { |
| 1020 NS_LOG_WARN ("WaveMacHeader not present"); |
| 1021 return; |
| 1022 } |
| 1023 oss << hdr.GetAddr2 (); |
| 1024 if (m_macToNodeIdMap.find (oss.str ()) == m_macToNodeIdMap.end ()) |
| 1025 { |
| 1026 NS_LOG_WARN ("Transmitter Mac address " << oss.str () << " never seen be
fore. Skipping"); |
| 1027 return; |
| 1028 } |
| 1029 Ptr <Node> txNode = NodeList::GetNode (m_macToNodeIdMap[oss.str ()]); |
| 1030 UpdatePosition (txNode); |
| 1031 AnimPacketInfo pktInfo (0, Simulator::Now (), m_macToNodeIdMap[oss.str ()]
); |
| 1032 AddPendingPacket (AnimationInterface::WAVE, animUid, pktInfo); |
| 1033 NS_LOG_WARN ("WavePhyRxBegin: unknown Uid, but we are adding a wave packet
"); |
| 1034 } |
| 1035 /// \todo NS_ASSERT (WavePacketIsPending (animUid) == true); |
| 1036 m_pendingWavePackets[animUid].ProcessRxBegin (ndev, Simulator::Now ().GetSecon
ds ()); |
| 1037 OutputWirelessPacketRxInfo (p, m_pendingWavePackets[animUid], animUid); |
| 1038 } |
| 1039 |
| 1040 |
| 1041 void |
876 AnimationInterface::WimaxTxTrace (std::string context, Ptr<const Packet> p, cons
t Mac48Address & m) | 1042 AnimationInterface::WimaxTxTrace (std::string context, Ptr<const Packet> p, cons
t Mac48Address & m) |
877 { | 1043 { |
878 NS_LOG_FUNCTION (this); | 1044 NS_LOG_FUNCTION (this); |
879 return GenericWirelessTxTrace (context, p, AnimationInterface::WIMAX); | 1045 return GenericWirelessTxTrace (context, p, AnimationInterface::WIMAX); |
880 } | 1046 } |
881 | 1047 |
882 | 1048 |
883 void· | 1049 void· |
884 AnimationInterface::WimaxRxTrace (std::string context, Ptr<const Packet> p, cons
t Mac48Address & m) | 1050 AnimationInterface::WimaxRxTrace (std::string context, Ptr<const Packet> p, cons
t Mac48Address & m) |
885 { | 1051 { |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 case AnimationInterface::WIMAX: | 1326 case AnimationInterface::WIMAX: |
1161 { | 1327 { |
1162 pendingPackets = &m_pendingWimaxPackets; | 1328 pendingPackets = &m_pendingWimaxPackets; |
1163 break; | 1329 break; |
1164 } | 1330 } |
1165 case AnimationInterface::LTE: | 1331 case AnimationInterface::LTE: |
1166 { | 1332 { |
1167 pendingPackets = &m_pendingLtePackets; | 1333 pendingPackets = &m_pendingLtePackets; |
1168 break; | 1334 break; |
1169 } | 1335 } |
| 1336 case AnimationInterface::LRWPAN: |
| 1337 { |
| 1338 pendingPackets = &m_pendingLrWpanPackets; |
| 1339 break; |
| 1340 } |
| 1341 case AnimationInterface::WAVE: |
| 1342 { |
| 1343 pendingPackets = &m_pendingWavePackets; |
| 1344 break; |
| 1345 } |
1170 } | 1346 } |
1171 return pendingPackets; | 1347 return pendingPackets; |
1172 | 1348 |
1173 } | 1349 } |
1174 | 1350 |
1175 std::string | 1351 std::string |
1176 AnimationInterface::ProtocolTypeToString (AnimationInterface::ProtocolType proto
colType) | 1352 AnimationInterface::ProtocolTypeToString (AnimationInterface::ProtocolType proto
colType) |
1177 { | 1353 { |
1178 std::string result = "Unknown"; | 1354 std::string result = "Unknown"; |
1179 switch (protocolType) | 1355 switch (protocolType) |
(...skipping 14 matching lines...) Expand all Loading... |
1194 break; | 1370 break; |
1195 } | 1371 } |
1196 case AnimationInterface::WIMAX: | 1372 case AnimationInterface::WIMAX: |
1197 { | 1373 { |
1198 result = "WIMAX"; | 1374 result = "WIMAX"; |
1199 break; | 1375 break; |
1200 } | 1376 } |
1201 case AnimationInterface::LTE: | 1377 case AnimationInterface::LTE: |
1202 { | 1378 { |
1203 result = "LTE"; | 1379 result = "LTE"; |
| 1380 break; |
| 1381 } |
| 1382 case AnimationInterface::LRWPAN: |
| 1383 { |
| 1384 result = "LRWPAN"; |
| 1385 break; |
| 1386 } |
| 1387 case AnimationInterface::WAVE: |
| 1388 { |
| 1389 result = "WAVE"; |
1204 break; | 1390 break; |
1205 } | 1391 } |
1206 } | 1392 } |
1207 return result; | 1393 return result; |
1208 } | 1394 } |
1209 | 1395 |
1210 // Counters | 1396 // Counters |
1211 | 1397 |
1212 std::string· | 1398 std::string· |
1213 AnimationInterface::CounterTypeToString (CounterType counterType) | 1399 AnimationInterface::CounterTypeToString (CounterType counterType) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 void· | 1459 void· |
1274 AnimationInterface::StartAnimation (bool restart) | 1460 AnimationInterface::StartAnimation (bool restart) |
1275 { | 1461 { |
1276 m_currentPktCount = 0; | 1462 m_currentPktCount = 0; |
1277 m_started = true; | 1463 m_started = true; |
1278 SetOutputFile (m_outputFileName); | 1464 SetOutputFile (m_outputFileName); |
1279 WriteXmlAnim (); | 1465 WriteXmlAnim (); |
1280 WriteNodes (); | 1466 WriteNodes (); |
1281 WriteNodeColors (); | 1467 WriteNodeColors (); |
1282 WriteLinkProperties (); | 1468 WriteLinkProperties (); |
| 1469 WriteIpv4Addresses (); |
| 1470 WriteIpv6Addresses (); |
1283 WriteNodeSizes (); | 1471 WriteNodeSizes (); |
1284 WriteNodeEnergies (); | 1472 WriteNodeEnergies (); |
1285 if (!restart) | 1473 if (!restart) |
1286 { | 1474 { |
1287 Simulator::Schedule (m_mobilityPollInterval, &AnimationInterface::Mobility
AutoCheck, this); | 1475 Simulator::Schedule (m_mobilityPollInterval, &AnimationInterface::Mobility
AutoCheck, this); |
1288 ConnectCallbacks (); | 1476 ConnectCallbacks (); |
1289 } | 1477 } |
1290 } | 1478 } |
1291 | 1479 |
1292 void· | 1480 void· |
1293 AnimationInterface::AddToIpv4AddressNodeIdTable (std::string ipv4Address, uint32
_t nodeId) | 1481 AnimationInterface::AddToIpv4AddressNodeIdTable (std::string ipv4Address, uint32
_t nodeId) |
1294 { | 1482 { |
1295 m_ipv4ToNodeIdMap[ipv4Address] = nodeId; | 1483 m_ipv4ToNodeIdMap[ipv4Address] = nodeId; |
1296 } | 1484 m_nodeIdIpv4Map.insert(NodeIdIpv4Pair(nodeId, ipv4Address)); |
1297 | 1485 } |
| 1486 |
| 1487 void· |
| 1488 AnimationInterface::AddToIpv4AddressNodeIdTable (std::vector<std::string> ipv4Ad
dresses, uint32_t nodeId) |
| 1489 { |
| 1490 for (std::vector<std::string>::const_iterator i = ipv4Addresses.begin (); |
| 1491 » i != ipv4Addresses.end (); |
| 1492 » ++i) |
| 1493 { |
| 1494 » AddToIpv4AddressNodeIdTable (*i, nodeId); |
| 1495 } |
| 1496 } |
| 1497 |
| 1498 void |
| 1499 AnimationInterface::AddToIpv6AddressNodeIdTable(std::string ipv6Address, uint32_
t nodeId) |
| 1500 { |
| 1501 » m_ipv6ToNodeIdMap[ipv6Address] = nodeId; |
| 1502 » m_nodeIdIpv6Map.insert(NodeIdIpv6Pair(nodeId, ipv6Address)); |
| 1503 } |
| 1504 |
| 1505 void |
| 1506 AnimationInterface::AddToIpv6AddressNodeIdTable(std::vector<std::string> ipv6Add
resses, uint32_t nodeId) |
| 1507 { |
| 1508 » for (std::vector<std::string>::const_iterator i = ipv6Addresses.begin(); |
| 1509 » » i != ipv6Addresses.end(); |
| 1510 » » ++i) |
| 1511 » { |
| 1512 » » AddToIpv6AddressNodeIdTable(*i, nodeId); |
| 1513 » } |
| 1514 } |
1298 | 1515 |
1299 // Callbacks | 1516 // Callbacks |
1300 void· | 1517 void· |
1301 AnimationInterface::ConnectLteEnb (Ptr <Node> n, Ptr <LteEnbNetDevice> nd, uint3
2_t devIndex) | 1518 AnimationInterface::ConnectLteEnb (Ptr <Node> n, Ptr <LteEnbNetDevice> nd, uint3
2_t devIndex) |
1302 { | 1519 { |
1303 | 1520 |
1304 Ptr<LteEnbPhy> lteEnbPhy = nd->GetPhy (); | 1521 Ptr<LteEnbPhy> lteEnbPhy = nd->GetPhy (); |
1305 Ptr<LteSpectrumPhy> dlPhy = lteEnbPhy->GetDownlinkSpectrumPhy (); | 1522 Ptr<LteSpectrumPhy> dlPhy = lteEnbPhy->GetDownlinkSpectrumPhy (); |
1306 Ptr<LteSpectrumPhy> ulPhy = lteEnbPhy->GetUplinkSpectrumPhy (); | 1523 Ptr<LteSpectrumPhy> ulPhy = lteEnbPhy->GetUplinkSpectrumPhy (); |
1307 std::ostringstream oss; | 1524 std::ostringstream oss; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1451 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx", | 1668 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRx", |
1452 MakeCallback (&AnimationInterface::WifiMacRxTrace, this)); | 1669 MakeCallback (&AnimationInterface::WifiMacRxTrace, this)); |
1453 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRxDrop", | 1670 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacRxDrop", |
1454 MakeCallback (&AnimationInterface::WifiMacRxDropTrace, this))
; | 1671 MakeCallback (&AnimationInterface::WifiMacRxDropTrace, this))
; |
1455 | 1672 |
1456 // Wifi Phy | 1673 // Wifi Phy |
1457 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxDrop", | 1674 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxDrop", |
1458 MakeCallback (&AnimationInterface::WifiPhyTxDropTrace, this))
; | 1675 MakeCallback (&AnimationInterface::WifiPhyTxDropTrace, this))
; |
1459 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop", | 1676 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop", |
1460 MakeCallback (&AnimationInterface::WifiPhyRxDropTrace, this))
; | 1677 MakeCallback (&AnimationInterface::WifiPhyRxDropTrace, this))
; |
| 1678 |
| 1679 // LrWpan |
| 1680 Config::Connect ("NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Phy/PhyTxBegin
", |
| 1681 MakeCallback (&AnimationInterface::LrWpanPhyTxBeginTrace, thi
s)); |
| 1682 Config::Connect ("NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Phy/PhyRxBegin
", |
| 1683 MakeCallback (&AnimationInterface::LrWpanPhyRxBeginTrace, thi
s)); |
| 1684 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacTx", |
| 1685 MakeCallback (&AnimationInterface::LrWpanMacTxTrace, this)); |
| 1686 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacTxDrop
", |
| 1687 MakeCallback (&AnimationInterface::LrWpanMacTxDropTrace, this
)); |
| 1688 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacRx", |
| 1689 MakeCallback (&AnimationInterface::LrWpanMacRxTrace, this)); |
| 1690 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::LrWpanNetDevice/Mac/MacRxDrop
", |
| 1691 MakeCallback (&AnimationInterface::LrWpanMacRxDropTrace, this
)); |
| 1692 |
| 1693 // Wave |
| 1694 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WaveNetDevice/PhyEntities/*/$
ns3::WifiPhy/PhyTxBegin", |
| 1695 MakeCallback (&AnimationInterface::WavePhyTxBeginTrace, this)
); |
| 1696 Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WaveNetDevice/PhyEntities/*/$
ns3::WifiPhy/PhyRxBegin", |
| 1697 MakeCallback (&AnimationInterface::WavePhyRxBeginTrace, this)
); |
1461 } | 1698 } |
1462 | 1699 |
1463 Vector· | 1700 Vector· |
1464 AnimationInterface::UpdatePosition (Ptr <Node> n) | 1701 AnimationInterface::UpdatePosition (Ptr <Node> n) |
1465 { | 1702 { |
1466 Ptr<MobilityModel> loc = n->GetObject<MobilityModel> (); | 1703 Ptr<MobilityModel> loc = n->GetObject<MobilityModel> (); |
1467 if (loc) | 1704 if (loc) |
1468 { | 1705 { |
1469 m_nodeLocation[n->GetId ()] = loc->GetPosition (); | 1706 m_nodeLocation[n->GetId ()] = loc->GetPosition (); |
1470 } | 1707 } |
1471 else | 1708 else |
1472 { | 1709 { |
1473 NS_LOG_UNCOND ( "AnimationInterface WARNING:Node:" << n->GetId () << " Does
not have a mobility model. Use SetConstantPosition if it is stationary"); | 1710 NS_LOG_UNCOND ( "AnimationInterface WARNING:Node:" << n->GetId () << " Does
not have a mobility model. Use SetConstantPosition if it is stationary"); |
1474 m_nodeLocation[n->GetId ()] = Vector (0, 0, 0); | 1711 Ptr<UniformRandomVariable> x = CreateObject<UniformRandomVariable> (); |
| 1712 x->SetAttribute ("Min", DoubleValue (0)); |
| 1713 x->SetAttribute ("Max", DoubleValue (100)); |
| 1714 Ptr<UniformRandomVariable> y = CreateObject<UniformRandomVariable> (); |
| 1715 y->SetAttribute ("Min", DoubleValue (0)); |
| 1716 y->SetAttribute ("Max", DoubleValue (100)); |
| 1717 m_nodeLocation[n->GetId ()] = Vector (int (x->GetValue ()), int (y->GetValu
e ()), 0); |
1475 } | 1718 } |
1476 return m_nodeLocation[n->GetId ()]; | 1719 return m_nodeLocation[n->GetId ()]; |
1477 } | 1720 } |
1478 | 1721 |
1479 Vector· | 1722 Vector· |
1480 AnimationInterface::UpdatePosition (Ptr <Node> n, Vector v) | 1723 AnimationInterface::UpdatePosition (Ptr <Node> n, Vector v) |
1481 { | 1724 { |
1482 m_nodeLocation[n->GetId ()] = v; | 1725 m_nodeLocation[n->GetId ()] = v; |
1483 return v; | 1726 return v; |
1484 } | 1727 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 int32_t ifIndex = ipv4->GetInterfaceForDevice (nd); | 1766 int32_t ifIndex = ipv4->GetInterfaceForDevice (nd); |
1524 if (ifIndex == -1) | 1767 if (ifIndex == -1) |
1525 { | 1768 { |
1526 NS_LOG_WARN ("Node :" << nd->GetNode ()->GetId () << " Could not find inde
x of NetDevice"); | 1769 NS_LOG_WARN ("Node :" << nd->GetNode ()->GetId () << " Could not find inde
x of NetDevice"); |
1527 return "0.0.0.0"; | 1770 return "0.0.0.0"; |
1528 } | 1771 } |
1529 Ipv4InterfaceAddress addr = ipv4->GetAddress (ifIndex, 0); | 1772 Ipv4InterfaceAddress addr = ipv4->GetAddress (ifIndex, 0); |
1530 std::ostringstream oss; | 1773 std::ostringstream oss; |
1531 oss << addr.GetLocal (); | 1774 oss << addr.GetLocal (); |
1532 return oss.str (); | 1775 return oss.str (); |
| 1776 } |
| 1777 |
| 1778 std::string |
| 1779 AnimationInterface::GetIpv6Address(Ptr <NetDevice> nd) |
| 1780 { |
| 1781 Ptr<Ipv6> ipv6 = NodeList::GetNode(nd->GetNode()->GetId())->GetObject <Ipv6>()
; |
| 1782 if (!ipv6) |
| 1783 { |
| 1784 NS_LOG_WARN("Node: " << nd->GetNode()->GetId() << " No ipv4 object found")
; |
| 1785 return "::"; |
| 1786 } |
| 1787 int32_t ifIndex = ipv6->GetInterfaceForDevice(nd); |
| 1788 if (ifIndex == -1) |
| 1789 { |
| 1790 NS_LOG_WARN("Node :" << nd->GetNode()->GetId() << " Could not find index o
f NetDevice"); |
| 1791 return "::"; |
| 1792 } |
| 1793 bool nonLinkLocalFound = false; |
| 1794 uint32_t nAddresses = ipv6->GetNAddresses(ifIndex); |
| 1795 Ipv6InterfaceAddress addr; |
| 1796 for (uint32_t addressIndex = 0; addressIndex < nAddresses; ++addressIndex) |
| 1797 { |
| 1798 addr = ipv6->GetAddress(ifIndex, addressIndex); |
| 1799 if (!addr.GetAddress().IsLinkLocal()) |
| 1800 { |
| 1801 nonLinkLocalFound = true; |
| 1802 break; |
| 1803 } |
| 1804 } |
| 1805 if (!nonLinkLocalFound) |
| 1806 addr = ipv6->GetAddress(ifIndex, 0); |
| 1807 std::ostringstream oss; |
| 1808 oss << addr.GetAddress(); |
| 1809 return oss.str(); |
| 1810 } |
| 1811 |
| 1812 |
| 1813 |
| 1814 std::vector<std::string> |
| 1815 AnimationInterface::GetIpv4Addresses (Ptr <NetDevice> nd) |
| 1816 { |
| 1817 std::vector<std::string> ipv4Addresses; |
| 1818 Ptr<Ipv4> ipv4 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv4
> (); |
| 1819 if (!ipv4) |
| 1820 { |
| 1821 NS_LOG_WARN ("Node: " << nd->GetNode ()->GetId () << " No ipv4 object foun
d"); |
| 1822 return ipv4Addresses; |
| 1823 } |
| 1824 int32_t ifIndex = ipv4->GetInterfaceForDevice (nd); |
| 1825 if (ifIndex == -1) |
| 1826 { |
| 1827 NS_LOG_WARN ("Node :" << nd->GetNode ()->GetId () << " Could not find inde
x of NetDevice"); |
| 1828 return ipv4Addresses; |
| 1829 } |
| 1830 for (uint32_t index = 0; index < ipv4->GetNAddresses (ifIndex); ++index) |
| 1831 { |
| 1832 Ipv4InterfaceAddress addr = ipv4->GetAddress (ifIndex, index); |
| 1833 std::ostringstream oss; |
| 1834 oss << addr.GetLocal (); |
| 1835 ipv4Addresses.push_back(oss.str ()); |
| 1836 } |
| 1837 return ipv4Addresses; |
| 1838 } |
| 1839 |
| 1840 std::vector<std::string> |
| 1841 AnimationInterface::GetIpv6Addresses(Ptr <NetDevice> nd) |
| 1842 { |
| 1843 std::vector<std::string> ipv6Addresses; |
| 1844 Ptr<Ipv6> ipv6 = NodeList::GetNode (nd->GetNode ()->GetId ())->GetObject <Ipv6
> (); |
| 1845 if (!ipv6) |
| 1846 { |
| 1847 NS_LOG_WARN("Node: " << nd->GetNode ()->GetId () << " No ipv6 object found
"); |
| 1848 return ipv6Addresses; |
| 1849 } |
| 1850 int32_t ifIndex = ipv6->GetInterfaceForDevice (nd); |
| 1851 if (ifIndex == -1) |
| 1852 { |
| 1853 NS_LOG_WARN("Node :" << nd->GetNode ()->GetId () << " Could not find index
of NetDevice"); |
| 1854 return ipv6Addresses; |
| 1855 } |
| 1856 for (uint32_t index = 0; index < ipv6->GetNAddresses (ifIndex); ++index) |
| 1857 { |
| 1858 Ipv6InterfaceAddress addr = ipv6->GetAddress (ifIndex, index); |
| 1859 std::ostringstream oss; |
| 1860 oss << addr.GetAddress (); |
| 1861 ipv6Addresses.push_back (oss.str ()); |
| 1862 } |
| 1863 return ipv6Addresses; |
| 1864 } |
| 1865 |
| 1866 |
| 1867 void |
| 1868 AnimationInterface::WriteIpv4Addresses () |
| 1869 { |
| 1870 for (NodeIdIpv4Map::const_iterator i = m_nodeIdIpv4Map.begin (); |
| 1871 i != m_nodeIdIpv4Map.end(); |
| 1872 ++i) |
| 1873 { |
| 1874 std::vector <std::string> ipv4Addresses; |
| 1875 std::pair<NodeIdIpv4Map::const_iterator, NodeIdIpv4Map::const_iterator> it
erPair = m_nodeIdIpv4Map.equal_range (i->first); |
| 1876 for (NodeIdIpv4Map::const_iterator it = iterPair.first; |
| 1877 it != iterPair.second;· |
| 1878 ++it) |
| 1879 { |
| 1880 ipv4Addresses.push_back (it->second); |
| 1881 } |
| 1882 WriteXmlIpv4Addresses (i->first, ipv4Addresses); |
| 1883 } |
| 1884 } |
| 1885 |
| 1886 void |
| 1887 AnimationInterface::WriteIpv6Addresses() |
| 1888 { |
| 1889 for (NodeIdIpv6Map::const_iterator i = m_nodeIdIpv6Map.begin (); |
| 1890 i != m_nodeIdIpv6Map.end (); |
| 1891 i = m_nodeIdIpv6Map.upper_bound (i->first)) |
| 1892 { |
| 1893 std::vector <std::string> ipv6Addresses; |
| 1894 std::pair<NodeIdIpv6Map::const_iterator, NodeIdIpv6Map::const_iterator> it
erPair = m_nodeIdIpv6Map.equal_range (i->first); |
| 1895 for (NodeIdIpv6Map::const_iterator it = iterPair.first; |
| 1896 it != iterPair.second;· |
| 1897 ++it) |
| 1898 { |
| 1899 ipv6Addresses.push_back (it->second); |
| 1900 } |
| 1901 WriteXmlIpv6Addresses (i->first, ipv6Addresses); |
| 1902 } |
1533 } | 1903 } |
1534 | 1904 |
1535 void· | 1905 void· |
1536 AnimationInterface::WriteLinkProperties () | 1906 AnimationInterface::WriteLinkProperties () |
1537 { | 1907 { |
1538 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i) | 1908 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i) |
1539 { | 1909 { |
1540 Ptr<Node> n = *i; | 1910 Ptr<Node> n = *i; |
1541 UpdatePosition (n); | 1911 UpdatePosition (n); |
1542 uint32_t n1Id = n->GetId (); | 1912 uint32_t n1Id = n->GetId (); |
1543 uint32_t nDev = n->GetNDevices (); // Number of devices | 1913 uint32_t nDev = n->GetNDevices (); // Number of devices |
1544 for (uint32_t i = 0; i < nDev; ++i) | 1914 for (uint32_t i = 0; i < nDev; ++i) |
1545 { | 1915 { |
1546 Ptr<NetDevice> dev = n->GetDevice (i); | 1916 Ptr<NetDevice> dev = n->GetDevice (i); |
1547 NS_ASSERT (dev); | 1917 NS_ASSERT (dev); |
1548 Ptr<Channel> ch = dev->GetChannel (); | 1918 » Ptr<Channel> ch = dev->GetChannel (); |
1549 if (!ch)· | 1919 std::string channelType = "Unknown channel"; |
| 1920 » if (ch) |
| 1921 { |
| 1922 » channelType = ch->GetInstanceTypeId ().GetName (); |
| 1923 » } |
| 1924 » NS_LOG_DEBUG("Got ChannelType" << channelType); |
| 1925 |
| 1926 if (!ch || (channelType != std::string("ns3::PointToPointChannel"))) |
1550 { | 1927 { |
1551 NS_LOG_DEBUG ("No channel can't be a p2p device"); | 1928 NS_LOG_DEBUG ("No channel can't be a p2p device"); |
| 1929 /* |
1552 // Try to see if it is an LTE NetDevice, which does not return a c
hannel | 1930 // Try to see if it is an LTE NetDevice, which does not return a c
hannel |
1553 if ((dev->GetInstanceTypeId ().GetName () == "ns3::LteUeNetDevice"
) ||· | 1931 if ((dev->GetInstanceTypeId ().GetName () == "ns3::LteUeNetDevice"
) ||· |
1554 (dev->GetInstanceTypeId ().GetName () == "ns3::LteEnbNetDevice
")|| | 1932 (dev->GetInstanceTypeId ().GetName () == "ns3::LteEnbNetDevice
")|| |
1555 (dev->GetInstanceTypeId ().GetName () == "ns3::VirtualNetDevic
e")) | 1933 (dev->GetInstanceTypeId ().GetName () == "ns3::VirtualNetDevic
e")) |
1556 { | 1934 { |
1557 WriteNonP2pLinkProperties (n->GetId (), GetIpv4Address (dev) +
"~" + GetMacAddress (dev), dev->GetInstanceTypeId ().GetName ()); | 1935 WriteNonP2pLinkProperties (n->GetId (), GetIpv4Address (dev) +
"~" + GetMacAddress (dev), channelType); |
1558 AddToIpv4AddressNodeIdTable (GetIpv4Address (dev), n->GetId ()
); | 1936 AddToIpv4AddressNodeIdTable (GetIpv4Address (dev), n->GetId ()
); |
1559 } | 1937 } |
| 1938 */ |
| 1939 std::vector<std::string> ipv4Addresses = GetIpv4Addresses (dev); |
| 1940 AddToIpv4AddressNodeIdTable(ipv4Addresses, n->GetId ()); |
| 1941 std::vector<std::string> ipv6Addresses = GetIpv6Addresses (dev); |
| 1942 AddToIpv6AddressNodeIdTable(ipv6Addresses, n->GetId ()); |
| 1943 if (!ipv4Addresses.empty ()) |
| 1944 { |
| 1945 NS_LOG_INFO ("Writing Ipv4 link"); |
| 1946 WriteNonP2pLinkProperties(n->GetId (), GetIpv4Address (dev) +
"~" + GetMacAddress (dev), channelType); |
| 1947 } |
| 1948 else if (!ipv6Addresses.empty ()) |
| 1949 { |
| 1950 NS_LOG_INFO ("Writing Ipv6 link"); |
| 1951 WriteNonP2pLinkProperties(n->GetId (), GetIpv6Address (dev) +
"~" + GetMacAddress (dev), channelType); |
| 1952 } |
1560 continue; | 1953 continue; |
1561 } | 1954 } |
1562 std::string channelType = ch->GetInstanceTypeId ().GetName (); | 1955 |
1563 NS_LOG_DEBUG ("Got ChannelType" << channelType); | 1956 else if (channelType == std::string ("ns3::PointToPointChannel")) |
1564 if (channelType == std::string ("ns3::PointToPointChannel")) | |
1565 { // Since these are duplex links, we only need to dump | 1957 { // Since these are duplex links, we only need to dump |
1566 // if srcid < dstid | 1958 // if srcid < dstid |
1567 uint32_t nChDev = ch->GetNDevices (); | 1959 uint32_t nChDev = ch->GetNDevices (); |
1568 for (uint32_t j = 0; j < nChDev; ++j) | 1960 for (uint32_t j = 0; j < nChDev; ++j) |
1569 { | 1961 { |
1570 Ptr<NetDevice> chDev = ch->GetDevice (j); | 1962 Ptr<NetDevice> chDev = ch->GetDevice (j); |
1571 uint32_t n2Id = chDev->GetNode ()->GetId (); | 1963 uint32_t n2Id = chDev->GetNode ()->GetId (); |
1572 if (n1Id < n2Id) | 1964 if (n1Id < n2Id) |
1573 {· | 1965 {· |
1574 // ouptut the p2p link | 1966 |
1575 NS_LOG_INFO ("Link:" << GetIpv4Address (dev) << ":" << Get
MacAddress (dev) << "----" << GetIpv4Address (chDev) << ":" << GetMacAddress (ch
Dev)); | 1967 std::vector<std::string> ipv4Addresses = GetIpv4Addresses
(dev); |
1576 AddToIpv4AddressNodeIdTable (GetIpv4Address (dev), n1Id); | 1968 AddToIpv4AddressNodeIdTable (ipv4Addresses, n1Id); |
1577 AddToIpv4AddressNodeIdTable (GetIpv4Address (chDev), n2Id)
; | 1969 ipv4Addresses = GetIpv4Addresses (chDev); |
| 1970 » AddToIpv4AddressNodeIdTable (ipv4Addresses, n2Id); |
| 1971 » » std::vector<std::string> ipv6Addresses = GetIpv6Addresses
(dev); |
| 1972 » » AddToIpv6AddressNodeIdTable(ipv6Addresses, n1Id); |
| 1973 » ipv6Addresses = GetIpv6Addresses (chDev); |
| 1974 AddToIpv6AddressNodeIdTable(ipv6Addresses, n2Id); |
| 1975 |
1578 P2pLinkNodeIdPair p2pPair; | 1976 P2pLinkNodeIdPair p2pPair; |
1579 p2pPair.fromNode = n1Id; | 1977 p2pPair.fromNode = n1Id; |
1580 p2pPair.toNode = n2Id; | 1978 p2pPair.toNode = n2Id; |
1581 LinkProperties lp = {GetIpv4Address (dev) + "~" + GetMacAd
dress (dev), GetIpv4Address (chDev) + "~" + GetMacAddress (chDev), ""}; | 1979 » » if (!ipv4Addresses.empty ()) |
1582 m_linkProperties[p2pPair] = lp; | 1980 » » { |
| 1981 LinkProperties lp = { GetIpv4Address (dev) + "~" + Get
MacAddress (dev), GetIpv4Address (chDev) + "~" + GetMacAddress (chDev), "" }; |
| 1982 » » » m_linkProperties[p2pPair] = lp; |
| 1983 » » } |
| 1984 » » else if (!ipv6Addresses.empty ()) |
| 1985 » » { |
| 1986 » » LinkProperties lp = { GetIpv6Address (dev) + "~" + Get
MacAddress (dev), GetIpv6Address (chDev) + "~" + GetMacAddress (chDev), "" }; |
| 1987 » » » m_linkProperties[p2pPair] = lp; |
| 1988 » » } |
1583 WriteXmlLink (n1Id, 0, n2Id); | 1989 WriteXmlLink (n1Id, 0, n2Id); |
1584 } | 1990 } |
1585 } | 1991 } |
1586 } | |
1587 else | |
1588 { | |
1589 NS_LOG_INFO ("Link:" << GetIpv4Address (dev) << " Channel Type:" <
< channelType << " Mac: " << GetMacAddress (dev)); | |
1590 WriteNonP2pLinkProperties (n->GetId (), GetIpv4Address (dev) + "~"
+ GetMacAddress (dev), channelType);· | |
1591 AddToIpv4AddressNodeIdTable (GetIpv4Address (dev), n->GetId ()); | |
1592 } | 1992 } |
1593 } | 1993 } |
1594 } | 1994 } |
1595 m_linkProperties.clear (); | 1995 m_linkProperties.clear (); |
1596 } | 1996 } |
1597 | 1997 |
1598 void | 1998 void |
1599 AnimationInterface::WriteNodes () | 1999 AnimationInterface::WriteNodes () |
1600 { | 2000 { |
1601 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i) | 2001 for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i) |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1993 FILE * f = m_f; | 2393 FILE * f = m_f; |
1994 if (!routing) | 2394 if (!routing) |
1995 { | 2395 { |
1996 element.AddAttribute ("filetype", "animation"); | 2396 element.AddAttribute ("filetype", "animation"); |
1997 } | 2397 } |
1998 else | 2398 else |
1999 { | 2399 { |
2000 element.AddAttribute ("filetype", "routing"); | 2400 element.AddAttribute ("filetype", "routing"); |
2001 f = m_routingF; | 2401 f = m_routingF; |
2002 } | 2402 } |
2003 element.Close (); | 2403 WriteN (element.ToString (false) + ">\n", f); |
2004 WriteN (element.GetElementString (), f); | |
2005 } | 2404 } |
2006 | 2405 |
2007 void· | 2406 void· |
2008 AnimationInterface::WriteXmlClose (std::string name, bool routing)· | 2407 AnimationInterface::WriteXmlClose (std::string name, bool routing)· |
2009 { | 2408 { |
2010 std::string closeString = "</" + name + ">\n";· | 2409 std::string closeString = "</" + name + ">\n";· |
2011 if (!routing) | 2410 if (!routing) |
2012 { | 2411 { |
2013 WriteN (closeString, m_f); | 2412 WriteN (closeString, m_f); |
2014 } | 2413 } |
2015 else | 2414 else |
2016 { | 2415 { |
2017 WriteN (closeString, m_routingF); | 2416 WriteN (closeString, m_routingF); |
2018 } | 2417 } |
2019 } | 2418 } |
2020 | 2419 |
2021 void· | 2420 void· |
2022 AnimationInterface::WriteXmlNode (uint32_t id, uint32_t sysId, double locX, doub
le locY) | 2421 AnimationInterface::WriteXmlNode (uint32_t id, uint32_t sysId, double locX, doub
le locY) |
2023 { | 2422 { |
2024 AnimXmlElement element ("node"); | 2423 AnimXmlElement element ("node"); |
2025 element.AddAttribute ("id", id); | 2424 element.AddAttribute ("id", id); |
2026 element.AddAttribute ("sysId", sysId); | 2425 element.AddAttribute ("sysId", sysId); |
2027 element.AddAttribute ("locX", locX); | 2426 element.AddAttribute ("locX", locX); |
2028 element.AddAttribute ("locY", locY); | 2427 element.AddAttribute ("locY", locY); |
2029 element.CloseElement (); | 2428 WriteN (element.ToString (), m_f); |
2030 WriteN (element.GetElementString (), m_f); | |
2031 } | 2429 } |
2032 | 2430 |
2033 void· | 2431 void· |
2034 AnimationInterface::WriteXmlUpdateLink (uint32_t fromId, uint32_t toId, std::str
ing linkDescription) | 2432 AnimationInterface::WriteXmlUpdateLink (uint32_t fromId, uint32_t toId, std::str
ing linkDescription) |
2035 { | 2433 { |
2036 AnimXmlElement element ("linkupdate"); | 2434 AnimXmlElement element ("linkupdate"); |
2037 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); | 2435 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); |
2038 element.AddAttribute ("fromId", fromId); | 2436 element.AddAttribute ("fromId", fromId); |
2039 element.AddAttribute ("toId", toId); | 2437 element.AddAttribute ("toId", toId); |
2040 element.AddAttribute ("ld", linkDescription, true); | 2438 element.AddAttribute ("ld", linkDescription, true); |
2041 element.CloseElement (); | 2439 WriteN (element.ToString (), m_f); |
2042 WriteN (element.GetElementString (), m_f); | |
2043 } | 2440 } |
2044 | 2441 |
2045 void· | 2442 void· |
2046 AnimationInterface::WriteXmlLink (uint32_t fromId, uint32_t toLp, uint32_t toId) | 2443 AnimationInterface::WriteXmlLink (uint32_t fromId, uint32_t toLp, uint32_t toId) |
2047 { | 2444 { |
2048 AnimXmlElement element ("link"); | 2445 AnimXmlElement element ("link"); |
2049 element.AddAttribute ("fromId", fromId); | 2446 element.AddAttribute ("fromId", fromId); |
2050 element.AddAttribute ("toId", toId); | 2447 element.AddAttribute ("toId", toId); |
2051 | 2448 |
2052 LinkProperties lprop ; | 2449 LinkProperties lprop ; |
2053 lprop.fromNodeDescription = ""; | 2450 lprop.fromNodeDescription = ""; |
2054 lprop.toNodeDescription = ""; | 2451 lprop.toNodeDescription = ""; |
2055 lprop.linkDescription = ""; | 2452 lprop.linkDescription = ""; |
2056 | 2453 |
2057 P2pLinkNodeIdPair p1 = { fromId, toId }; | 2454 P2pLinkNodeIdPair p1 = { fromId, toId }; |
2058 P2pLinkNodeIdPair p2 = { toId, fromId }; | 2455 P2pLinkNodeIdPair p2 = { toId, fromId }; |
2059 if (m_linkProperties.find (p1) != m_linkProperties.end ()) | 2456 if (m_linkProperties.find (p1) != m_linkProperties.end ()) |
2060 { | 2457 { |
2061 lprop = m_linkProperties[p1]; | 2458 lprop = m_linkProperties[p1]; |
2062 } | 2459 } |
2063 else if (m_linkProperties.find (p2) != m_linkProperties.end ()) | 2460 else if (m_linkProperties.find (p2) != m_linkProperties.end ()) |
2064 { | 2461 { |
2065 lprop = m_linkProperties[p2]; | 2462 lprop = m_linkProperties[p2]; |
2066 } | 2463 } |
2067 ·· | 2464 ·· |
2068 element.AddAttribute ("fd", lprop.fromNodeDescription, true);· | 2465 element.AddAttribute ("fd", lprop.fromNodeDescription, true);· |
2069 element.AddAttribute ("td", lprop.toNodeDescription, true);· | 2466 element.AddAttribute ("td", lprop.toNodeDescription, true);· |
2070 element.AddAttribute ("ld", lprop.linkDescription, true);· | 2467 element.AddAttribute ("ld", lprop.linkDescription, true);· |
2071 element.CloseElement (); | 2468 WriteN (element.ToString (), m_f); |
2072 WriteN (element.GetElementString (), m_f); | 2469 } |
| 2470 |
| 2471 void |
| 2472 AnimationInterface::WriteXmlIpv4Addresses (uint32_t nodeId, std::vector<std::str
ing> ipv4Addresses) |
| 2473 { |
| 2474 AnimXmlElement element ("ip"); |
| 2475 element.AddAttribute ("n", nodeId); |
| 2476 for (std::vector<std::string>::const_iterator i = ipv4Addresses.begin (); |
| 2477 i != ipv4Addresses.end (); |
| 2478 ++i) |
| 2479 { |
| 2480 AnimXmlElement valueElement ("address"); |
| 2481 valueElement.SetText (*i); |
| 2482 element.AppendChild(valueElement); |
| 2483 } |
| 2484 WriteN (element.ToString (), m_f); |
| 2485 } |
| 2486 |
| 2487 void |
| 2488 AnimationInterface::WriteXmlIpv6Addresses (uint32_t nodeId, std::vector<std::str
ing> ipv6Addresses) |
| 2489 { |
| 2490 AnimXmlElement element ("ipv6"); |
| 2491 element.AddAttribute("n", nodeId); |
| 2492 for (std::vector<std::string>::const_iterator i = ipv6Addresses.begin (); |
| 2493 i != ipv6Addresses.end (); |
| 2494 ++i) |
| 2495 { |
| 2496 AnimXmlElement valueElement ("address"); |
| 2497 valueElement.SetText (*i); |
| 2498 element.AppendChild (valueElement); |
| 2499 } |
| 2500 WriteN(element.ToString (), m_f); |
2073 } | 2501 } |
2074 | 2502 |
2075 void· | 2503 void· |
2076 AnimationInterface::WriteXmlRouting (uint32_t nodeId, std::string routingInfo) | 2504 AnimationInterface::WriteXmlRouting (uint32_t nodeId, std::string routingInfo) |
2077 { | 2505 { |
2078 AnimXmlElement element ("rt"); | 2506 AnimXmlElement element ("rt"); |
2079 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); | 2507 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); |
2080 element.AddAttribute ("id", nodeId); | 2508 element.AddAttribute ("id", nodeId); |
2081 element.AddAttribute ("info", routingInfo.c_str (), true); | 2509 element.AddAttribute ("info", routingInfo.c_str (), true); |
2082 element.CloseElement (); | 2510 WriteN (element.ToString (), m_routingF); |
2083 WriteN (element.GetElementString (), m_routingF); | |
2084 } | 2511 } |
2085 | 2512 |
2086 void· | 2513 void· |
2087 AnimationInterface::WriteXmlRp (uint32_t nodeId, std::string destination, Ipv4Ro
utePathElements rpElements) | 2514 AnimationInterface::WriteXmlRp (uint32_t nodeId, std::string destination, Ipv4Ro
utePathElements rpElements) |
2088 { | 2515 { |
2089 std::string tagName = "rp"; | 2516 std::string tagName = "rp"; |
2090 AnimXmlElement element (tagName, false); | 2517 AnimXmlElement element (tagName, false); |
2091 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); | 2518 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); |
2092 element.AddAttribute ("id", nodeId); | 2519 element.AddAttribute ("id", nodeId); |
2093 element.AddAttribute ("d", destination.c_str ()); | 2520 element.AddAttribute ("d", destination.c_str ()); |
2094 element.AddAttribute ("c", rpElements.size ()); | 2521 element.AddAttribute ("c", rpElements.size ()); |
2095 element.CloseTag (); | |
2096 element.AddLineBreak (); | |
2097 for (Ipv4RoutePathElements::const_iterator i = rpElements.begin (); | 2522 for (Ipv4RoutePathElements::const_iterator i = rpElements.begin (); |
2098 i != rpElements.end (); | 2523 i != rpElements.end (); |
2099 ++i) | 2524 ++i) |
2100 { | 2525 { |
2101 Ipv4RoutePathElement rpElement = *i; | 2526 Ipv4RoutePathElement rpElement = *i; |
2102 AnimXmlElement rpeElement ("rpe"); | 2527 AnimXmlElement rpeElement ("rpe"); |
2103 rpeElement.AddAttribute ("n", rpElement.nodeId); | 2528 rpeElement.AddAttribute ("n", rpElement.nodeId); |
2104 rpeElement.AddAttribute ("nH", rpElement.nextHop.c_str ()); | 2529 rpeElement.AddAttribute ("nH", rpElement.nextHop.c_str ()); |
2105 rpeElement.CloseElement (); | 2530 element.AppendChild (rpeElement); |
2106 element.Add (rpeElement); | 2531 } |
2107 } | 2532 WriteN (element.ToString (), m_routingF); |
2108 element.CloseElement (); | |
2109 WriteN (element.GetElementString (), m_routingF); | |
2110 } | 2533 } |
2111 | 2534 |
2112 | 2535 |
2113 void· | 2536 void· |
2114 AnimationInterface::WriteXmlPRef (uint64_t animUid, uint32_t fId, double fbTx, s
td::string metaInfo) | 2537 AnimationInterface::WriteXmlPRef (uint64_t animUid, uint32_t fId, double fbTx, s
td::string metaInfo) |
2115 { | 2538 { |
2116 AnimXmlElement element ("pr"); | 2539 AnimXmlElement element ("pr"); |
2117 element.AddAttribute ("uId", animUid); | 2540 element.AddAttribute ("uId", animUid); |
2118 element.AddAttribute ("fId", fId); | 2541 element.AddAttribute ("fId", fId); |
2119 element.AddAttribute ("fbTx", fbTx); | 2542 element.AddAttribute ("fbTx", fbTx); |
2120 if (!metaInfo.empty ()) | 2543 if (!metaInfo.empty ()) |
2121 { | 2544 { |
2122 element.AddAttribute ("meta-info", metaInfo.c_str (), true); | 2545 element.AddAttribute ("meta-info", metaInfo.c_str (), true); |
2123 } | 2546 } |
2124 element.CloseElement (); | 2547 WriteN (element.ToString (), m_f); |
2125 WriteN (element.GetElementString (), m_f); | |
2126 } | 2548 } |
2127 | 2549 |
2128 void· | 2550 void· |
2129 AnimationInterface::WriteXmlP (uint64_t animUid, std::string pktType, uint32_t t
Id, double fbRx, double lbRx) | 2551 AnimationInterface::WriteXmlP (uint64_t animUid, std::string pktType, uint32_t t
Id, double fbRx, double lbRx) |
2130 { | 2552 { |
2131 AnimXmlElement element (pktType); | 2553 AnimXmlElement element (pktType); |
2132 element.AddAttribute ("uId", animUid); | 2554 element.AddAttribute ("uId", animUid); |
2133 element.AddAttribute ("tId", tId); | 2555 element.AddAttribute ("tId", tId); |
2134 element.AddAttribute ("fbRx", fbRx); | 2556 element.AddAttribute ("fbRx", fbRx); |
2135 element.AddAttribute ("lbRx", lbRx); | 2557 element.AddAttribute ("lbRx", lbRx); |
2136 element.CloseElement (); | 2558 WriteN (element.ToString (), m_f); |
2137 WriteN (element.GetElementString (), m_f); | |
2138 } | 2559 } |
2139 | 2560 |
2140 void· | 2561 void· |
2141 AnimationInterface::WriteXmlP (std::string pktType, uint32_t fId, double fbTx, d
ouble lbTx,· | 2562 AnimationInterface::WriteXmlP (std::string pktType, uint32_t fId, double fbTx, d
ouble lbTx,· |
2142 uint32_t tId, double fbRx, do
uble lbRx, std::string metaInfo) | 2563 uint32_t tId, double fbRx, do
uble lbRx, std::string metaInfo) |
2143 { | 2564 { |
2144 AnimXmlElement element (pktType); | 2565 AnimXmlElement element (pktType); |
2145 element.AddAttribute ("fId", fId); | 2566 element.AddAttribute ("fId", fId); |
2146 element.AddAttribute ("fbTx", fbTx); | 2567 element.AddAttribute ("fbTx", fbTx); |
2147 element.AddAttribute ("lbTx", lbTx); | 2568 element.AddAttribute ("lbTx", lbTx); |
2148 if (!metaInfo.empty ()) | 2569 if (!metaInfo.empty ()) |
2149 { | 2570 { |
2150 element.AddAttribute ("meta-info", metaInfo.c_str (), true); | 2571 element.AddAttribute ("meta-info", metaInfo.c_str (), true); |
2151 } | 2572 } |
2152 element.AddAttribute ("tId", tId); | 2573 element.AddAttribute ("tId", tId); |
2153 element.AddAttribute ("fbRx", fbRx); | 2574 element.AddAttribute ("fbRx", fbRx); |
2154 element.AddAttribute ("lbRx", lbRx); | 2575 element.AddAttribute ("lbRx", lbRx); |
2155 element.CloseElement (); | 2576 WriteN (element.ToString (), m_f); |
2156 WriteN (element.GetElementString (), m_f); | |
2157 } | 2577 } |
2158 | 2578 |
2159 void· | 2579 void· |
2160 AnimationInterface::WriteXmlAddNodeCounter (uint32_t nodeCounterId, std::string
counterName, CounterType counterType) | 2580 AnimationInterface::WriteXmlAddNodeCounter (uint32_t nodeCounterId, std::string
counterName, CounterType counterType) |
2161 { | 2581 { |
2162 AnimXmlElement element ("ncs"); | 2582 AnimXmlElement element ("ncs"); |
2163 element.AddAttribute ("ncId", nodeCounterId); | 2583 element.AddAttribute ("ncId", nodeCounterId); |
2164 element.AddAttribute ("n", counterName); | 2584 element.AddAttribute ("n", counterName); |
2165 element.AddAttribute ("t", CounterTypeToString (counterType)); | 2585 element.AddAttribute ("t", CounterTypeToString (counterType)); |
2166 element.CloseElement (); | 2586 WriteN (element.ToString (), m_f); |
2167 WriteN (element.GetElementString (), m_f); | |
2168 } | 2587 } |
2169 | 2588 |
2170 void· | 2589 void· |
2171 AnimationInterface::WriteXmlAddResource (uint32_t resourceId, std::string resour
cePath) | 2590 AnimationInterface::WriteXmlAddResource (uint32_t resourceId, std::string resour
cePath) |
2172 { | 2591 { |
2173 AnimXmlElement element ("res"); | 2592 AnimXmlElement element ("res"); |
2174 element.AddAttribute ("rid", resourceId); | 2593 element.AddAttribute ("rid", resourceId); |
2175 element.AddAttribute ("p", resourcePath); | 2594 element.AddAttribute ("p", resourcePath); |
2176 element.CloseElement (); | 2595 WriteN (element.ToString (), m_f); |
2177 WriteN (element.GetElementString (), m_f); | |
2178 } | 2596 } |
2179 | 2597 |
2180 void· | 2598 void· |
2181 AnimationInterface::WriteXmlUpdateNodeImage (uint32_t nodeId, uint32_t resourceI
d) | 2599 AnimationInterface::WriteXmlUpdateNodeImage (uint32_t nodeId, uint32_t resourceI
d) |
2182 { | 2600 { |
2183 AnimXmlElement element ("nu"); | 2601 AnimXmlElement element ("nu"); |
2184 element.AddAttribute ("p", "i"); | 2602 element.AddAttribute ("p", "i"); |
2185 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); | 2603 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); |
2186 element.AddAttribute ("id", nodeId); | 2604 element.AddAttribute ("id", nodeId); |
2187 element.AddAttribute ("rid", resourceId); | 2605 element.AddAttribute ("rid", resourceId); |
2188 element.CloseElement (); | 2606 WriteN (element.ToString (), m_f); |
2189 WriteN (element.GetElementString (), m_f); | |
2190 } | 2607 } |
2191 | 2608 |
2192 void· | 2609 void· |
2193 AnimationInterface::WriteXmlUpdateNodeSize (uint32_t nodeId, double width, doubl
e height) | 2610 AnimationInterface::WriteXmlUpdateNodeSize (uint32_t nodeId, double width, doubl
e height) |
2194 { | 2611 { |
2195 AnimXmlElement element ("nu"); | 2612 AnimXmlElement element ("nu"); |
2196 element.AddAttribute ("p", "s"); | 2613 element.AddAttribute ("p", "s"); |
2197 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); | 2614 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); |
2198 element.AddAttribute ("id", nodeId); | 2615 element.AddAttribute ("id", nodeId); |
2199 element.AddAttribute ("w", width); | 2616 element.AddAttribute ("w", width); |
2200 element.AddAttribute ("h", height); | 2617 element.AddAttribute ("h", height); |
2201 element.CloseElement (); | 2618 WriteN (element.ToString (), m_f); |
2202 WriteN (element.GetElementString (), m_f); | |
2203 } | 2619 } |
2204 | 2620 |
2205 void· | 2621 void· |
2206 AnimationInterface::WriteXmlUpdateNodePosition (uint32_t nodeId, double x, doubl
e y) | 2622 AnimationInterface::WriteXmlUpdateNodePosition (uint32_t nodeId, double x, doubl
e y) |
2207 { | 2623 { |
2208 AnimXmlElement element ("nu"); | 2624 AnimXmlElement element ("nu"); |
2209 element.AddAttribute ("p", "p"); | 2625 element.AddAttribute ("p", "p"); |
2210 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); | 2626 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); |
2211 element.AddAttribute ("id", nodeId); | 2627 element.AddAttribute ("id", nodeId); |
2212 element.AddAttribute ("x", x); | 2628 element.AddAttribute ("x", x); |
2213 element.AddAttribute ("y", y); | 2629 element.AddAttribute ("y", y); |
2214 element.CloseElement (); | 2630 WriteN (element.ToString (), m_f); |
2215 WriteN (element.GetElementString (), m_f); | |
2216 } | 2631 } |
2217 | 2632 |
2218 void· | 2633 void· |
2219 AnimationInterface::WriteXmlUpdateNodeColor (uint32_t nodeId, uint8_t r, uint8_t
g, uint8_t b) | 2634 AnimationInterface::WriteXmlUpdateNodeColor (uint32_t nodeId, uint8_t r, uint8_t
g, uint8_t b) |
2220 { | 2635 { |
2221 AnimXmlElement element ("nu"); | 2636 AnimXmlElement element ("nu"); |
2222 element.AddAttribute ("p", "c"); | 2637 element.AddAttribute ("p", "c"); |
2223 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); | 2638 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); |
2224 element.AddAttribute ("id", nodeId); | 2639 element.AddAttribute ("id", nodeId); |
2225 element.AddAttribute ("r", (uint32_t) r); | 2640 element.AddAttribute ("r", (uint32_t) r); |
2226 element.AddAttribute ("g", (uint32_t) g); | 2641 element.AddAttribute ("g", (uint32_t) g); |
2227 element.AddAttribute ("b", (uint32_t) b); | 2642 element.AddAttribute ("b", (uint32_t) b); |
2228 element.CloseElement (); | 2643 WriteN (element.ToString (), m_f); |
2229 WriteN (element.GetElementString (), m_f); | |
2230 } | 2644 } |
2231 | 2645 |
2232 void· | 2646 void· |
2233 AnimationInterface::WriteXmlUpdateNodeDescription (uint32_t nodeId) | 2647 AnimationInterface::WriteXmlUpdateNodeDescription (uint32_t nodeId) |
2234 { | 2648 { |
2235 AnimXmlElement element ("nu"); | 2649 AnimXmlElement element ("nu"); |
2236 element.AddAttribute ("p", "d"); | 2650 element.AddAttribute ("p", "d"); |
2237 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); | 2651 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); |
2238 element.AddAttribute ("id", nodeId); | 2652 element.AddAttribute ("id", nodeId); |
2239 if (m_nodeDescriptions.find (nodeId) != m_nodeDescriptions.end ()) | 2653 if (m_nodeDescriptions.find (nodeId) != m_nodeDescriptions.end ()) |
2240 { | 2654 { |
2241 element.AddAttribute ("descr", m_nodeDescriptions[nodeId], true);· | 2655 element.AddAttribute ("descr", m_nodeDescriptions[nodeId], true);· |
2242 } | 2656 } |
2243 element.CloseElement (); | 2657 WriteN (element.ToString (), m_f); |
2244 WriteN (element.GetElementString (), m_f); | |
2245 } | 2658 } |
2246 | 2659 |
2247 | 2660 |
2248 void· | 2661 void· |
2249 AnimationInterface::WriteXmlUpdateNodeCounter (uint32_t nodeCounterId, uint32_t
nodeId, double counterValue) | 2662 AnimationInterface::WriteXmlUpdateNodeCounter (uint32_t nodeCounterId, uint32_t
nodeId, double counterValue) |
2250 { | 2663 { |
2251 AnimXmlElement element ("nc"); | 2664 AnimXmlElement element ("nc"); |
2252 element.AddAttribute ("c", nodeCounterId); | 2665 element.AddAttribute ("c", nodeCounterId); |
2253 element.AddAttribute ("i", nodeId); | 2666 element.AddAttribute ("i", nodeId); |
2254 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); | 2667 element.AddAttribute ("t", Simulator::Now ().GetSeconds ()); |
2255 element.AddAttribute ("v", counterValue); | 2668 element.AddAttribute ("v", counterValue); |
2256 element.CloseElement (); | 2669 WriteN (element.ToString (), m_f); |
2257 WriteN (element.GetElementString (), m_f); | |
2258 } | 2670 } |
2259 | 2671 |
2260 void· | 2672 void· |
2261 AnimationInterface::WriteXmlUpdateBackground (std::string fileName, double x, do
uble y, double scaleX, double scaleY, double opacity) | 2673 AnimationInterface::WriteXmlUpdateBackground (std::string fileName, double x, do
uble y, double scaleX, double scaleY, double opacity) |
2262 { | 2674 { |
2263 AnimXmlElement element ("bg"); | 2675 AnimXmlElement element ("bg"); |
2264 element.AddAttribute ("f", fileName); | 2676 element.AddAttribute ("f", fileName); |
2265 element.AddAttribute ("x", x); | 2677 element.AddAttribute ("x", x); |
2266 element.AddAttribute ("y", y); | 2678 element.AddAttribute ("y", y); |
2267 element.AddAttribute ("sx", scaleX); | 2679 element.AddAttribute ("sx", scaleX); |
2268 element.AddAttribute ("sy", scaleY); | 2680 element.AddAttribute ("sy", scaleY); |
2269 element.AddAttribute ("o", opacity); | 2681 element.AddAttribute ("o", opacity); |
2270 element.CloseElement (); | 2682 WriteN (element.ToString (), m_f); |
2271 WriteN (element.GetElementString (), m_f); | 2683 } |
2272 } | 2684 |
2273 | 2685 void· |
2274 void· | 2686 AnimationInterface::WriteXmlNonP2pLinkProperties (uint32_t id, std::string ipAdd
ress, std::string channelType) |
2275 AnimationInterface::WriteXmlNonP2pLinkProperties (uint32_t id, std::string ipv4A
ddress, std::string channelType) | |
2276 { | 2687 { |
2277 AnimXmlElement element ("nonp2plinkproperties"); | 2688 AnimXmlElement element ("nonp2plinkproperties"); |
2278 element.AddAttribute ("id", id); | 2689 element.AddAttribute ("id", id); |
2279 element.AddAttribute ("ipv4Address", ipv4Address); | 2690 element.AddAttribute ("ipAddress", ipAddress); |
2280 element.AddAttribute ("channelType", channelType); | 2691 element.AddAttribute ("channelType", channelType); |
2281 element.CloseElement (); | 2692 WriteN (element.ToString (), m_f); |
2282 WriteN (element.GetElementString (), m_f); | |
2283 } | 2693 } |
2284 | 2694 |
2285 | 2695 |
2286 | 2696 |
2287 /***** AnimXmlElement *****/ | 2697 /***** AnimXmlElement *****/ |
2288 | 2698 |
2289 AnimationInterface::AnimXmlElement::AnimXmlElement (std::string tagName, bool em
ptyElement): | 2699 AnimationInterface::AnimXmlElement::AnimXmlElement(std::string tagName, bool emp
tyElement) : |
2290 m_tagName (tagName), | 2700 » m_tagName(tagName), |
2291 m_emptyElement (emptyElement
) | 2701 » m_text("") |
2292 { | 2702 { |
2293 m_elementString = "<" + tagName + " "; | |
2294 } | 2703 } |
2295 | 2704 |
2296 template <typename T> | 2705 template <typename T> |
2297 void | 2706 void |
2298 AnimationInterface::AnimXmlElement::AddAttribute (std::string attribute, T value
, bool xmlEscape) | 2707 AnimationInterface::AnimXmlElement::AddAttribute(std::string attribute, T value,
bool xmlEscape) |
2299 { | 2708 { |
2300 std::ostringstream oss; | 2709 » std::ostringstream oss; |
2301 oss << std::setprecision (10); | 2710 » oss << std::setprecision(10); |
2302 oss << value; | 2711 » oss << value; |
2303 m_elementString += attribute.c_str (); | 2712 » std::string attributeString = attribute.c_str(); |
2304 if (xmlEscape) | 2713 » if (xmlEscape) |
2305 { | 2714 » { |
2306 m_elementString += "=\""; | 2715 » » attributeString += "=\""; |
2307 std::string valueStr = oss.str (); | 2716 » » std::string valueStr = oss.str(); |
2308 for (std::string::iterator it = valueStr.begin (); it != valueStr.end ();
++it) | 2717 » » for (std::string::iterator it = valueStr.begin(); it != valueStr
.end(); ++it) |
2309 { | 2718 » » { |
2310 switch (*it) | 2719 » » » switch (*it) |
2311 { | 2720 » » » { |
2312 case '&': | 2721 » » » case '&': |
2313 m_elementString += "&"; | 2722 » » » » attributeString += "&"; |
2314 break; | 2723 » » » » break; |
2315 case '\"': | 2724 » » » case '\"': |
2316 m_elementString += """; | 2725 » » » » attributeString += """; |
2317 break; | 2726 » » » » break; |
2318 case '\'': | 2727 » » » case '\'': |
2319 m_elementString += "'"; | 2728 » » » » attributeString += "'"; |
2320 break; | 2729 » » » » break; |
2321 case '<': | 2730 » » » case '<': |
2322 m_elementString += "<"; | 2731 » » » » attributeString += "<"; |
2323 break; | 2732 » » » » break; |
2324 case '>': | 2733 » » » case '>': |
2325 m_elementString += ">"; | 2734 » » » » attributeString += ">"; |
2326 break; | 2735 » » » » break; |
2327 default: | 2736 » » » default: |
2328 m_elementString += *it; | 2737 » » » » attributeString += *it; |
2329 break; | 2738 » » » » break; |
2330 } | 2739 » » » } |
2331 } | 2740 » » } |
2332 m_elementString += "\" "; | 2741 » » attributeString += "\" "; |
2333 } | 2742 » } |
2334 else | 2743 » else |
2335 { | 2744 » { |
2336 m_elementString += "=\"" + oss.str () + "\" "; | 2745 » » attributeString += "=\"" + oss.str() + "\" "; |
2337 } | 2746 » } |
2338 } | 2747 » m_attributes.push_back(attributeString); |
2339 | 2748 } |
2340 void | 2749 |
2341 AnimationInterface::AnimXmlElement::Close () | 2750 void |
2342 { | 2751 AnimationInterface::AnimXmlElement::AppendChild(AnimXmlElement e) |
2343 m_elementString += ">\n"; | 2752 { |
2344 } | 2753 » m_children.push_back(e.ToString()); |
2345 | 2754 } |
2346 void | 2755 |
2347 AnimationInterface::AnimXmlElement::CloseElement () | 2756 void |
2348 { | 2757 AnimationInterface::AnimXmlElement::SetText(std::string text) |
2349 if (m_emptyElement) | 2758 { |
2350 { | 2759 » m_text = text; |
2351 m_elementString += "/>\n"; | |
2352 } | |
2353 else | |
2354 { | |
2355 m_elementString += "</" + m_tagName + ">\n"; | |
2356 } | |
2357 } | |
2358 | |
2359 void | |
2360 AnimationInterface::AnimXmlElement::CloseTag () | |
2361 { | |
2362 m_elementString += ">"; | |
2363 } | |
2364 | |
2365 void | |
2366 AnimationInterface::AnimXmlElement::AddLineBreak () | |
2367 { | |
2368 m_elementString += "\n"; | |
2369 } | |
2370 | |
2371 void | |
2372 AnimationInterface::AnimXmlElement::Add (AnimXmlElement e) | |
2373 { | |
2374 m_elementString += e.GetElementString (); | |
2375 } | 2760 } |
2376 | 2761 |
2377 std::string | 2762 std::string |
2378 AnimationInterface::AnimXmlElement::GetElementString () | 2763 AnimationInterface::AnimXmlElement::ToString(bool autoClose) |
2379 { | 2764 { |
2380 return m_elementString; | 2765 » std::string elementString = "<" + m_tagName + " "; |
2381 } | 2766 |
| 2767 »······· |
| 2768 » » for (std::vector<std::string>::const_iterator i = m_attributes.b
egin(); |
| 2769 » » » i != m_attributes.end(); |
| 2770 » » » ++i) |
| 2771 » » { |
| 2772 » » » elementString += *i; |
| 2773 » » } |
| 2774 » » if (m_children.empty() && m_text.empty()) |
| 2775 » » { |
| 2776 » » » if (autoClose) |
| 2777 » » » {· |
| 2778 » » » » elementString += "/>"; |
| 2779 » » » } |
| 2780 » » } |
| 2781 » » else |
| 2782 » » {· |
| 2783 » » » elementString += ">"; |
| 2784 » » » if (!m_text.empty()) |
| 2785 » » » { |
| 2786 » » » » elementString += m_text; |
| 2787 » » » } |
| 2788 » » » if (!m_children.empty()) |
| 2789 » » » { |
| 2790 » » » » elementString += "\n"; |
| 2791 » » » » for (std::vector<std::string>::const_iterator i
= m_children.begin(); |
| 2792 » » » » » i != m_children.end(); |
| 2793 » » » » » ++i) |
| 2794 » » » » { |
| 2795 » » » » » elementString += *i + "\n"; |
| 2796 » » » » } |
| 2797 |
| 2798 » » » } |
| 2799 » » » if (autoClose) |
| 2800 » » » { |
| 2801 » » » » elementString += "</" + m_tagName + ">"; |
| 2802 » » » } |
| 2803 » » } |
| 2804 |
| 2805 »······· |
| 2806 » return elementString + ((autoClose) ?"\n": ""); |
| 2807 } |
| 2808 |
2382 | 2809 |
2383 | 2810 |
2384 | 2811 |
2385 | 2812 |
2386 /***** AnimByteTag *****/ | 2813 /***** AnimByteTag *****/ |
2387 | 2814 |
2388 TypeId | 2815 TypeId |
2389 AnimByteTag::GetTypeId (void) | 2816 AnimByteTag::GetTypeId (void) |
2390 { | 2817 { |
2391 static TypeId tid = TypeId ("ns3::AnimByteTag") | 2818 static TypeId tid = TypeId ("ns3::AnimByteTag") |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2471 | 2898 |
2472 void· | 2899 void· |
2473 AnimationInterface::AnimPacketInfo::ProcessRxBegin (Ptr<const NetDevice> nd, con
st double fbRx) | 2900 AnimationInterface::AnimPacketInfo::ProcessRxBegin (Ptr<const NetDevice> nd, con
st double fbRx) |
2474 { | 2901 { |
2475 Ptr <Node> n = nd->GetNode (); | 2902 Ptr <Node> n = nd->GetNode (); |
2476 m_fbRx = fbRx; | 2903 m_fbRx = fbRx; |
2477 m_rxnd = nd; | 2904 m_rxnd = nd; |
2478 } | 2905 } |
2479 | 2906 |
2480 } // namespace ns3 | 2907 } // namespace ns3 |
LEFT | RIGHT |