A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
animation-interface-helper.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
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
5  * published by the Free Software Foundation;
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
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
14  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15  *
16  * Author: John Abraham<john.abraham@gatech.edu>
17  */
18 
19 // Animation Interface helpers
20 
21 #include "ns3/animation-interface-helper.h"
22 #include "ns3/log.h"
23 
24 #include <iostream>
25 
26 NS_LOG_COMPONENT_DEFINE ("AnimationInterfaceHelper");
27 
28 namespace ns3 {
30  : m_txnd (0), m_fbTx (0), m_lbTx (0),
31  m_txLoc (Vector (0,0,0))
32 {
33 }
34 
36  const Time& lbTx, Vector txLoc, uint32_t txNodeId)
37  : m_txnd (txnd), m_fbTx (fbTx.GetSeconds ()), m_lbTx (lbTx.GetSeconds ()),
38  m_txLoc (txLoc)
39 {
40  if (!m_txnd)
41  m_txNodeId = txNodeId;
42 }
43 
45 {
46  m_rx[nd->GetNode ()->GetId ()] = AnimRxInfo (fbRx, nd, 0);
47 }
48 
50 {
51  uint32_t NodeId = nd->GetNode ()->GetId ();
52  // Find the RxInfo
53  if (m_rx.find (NodeId) == m_rx.end ())
54  {
55  return false;
56  }
57  AnimRxInfo& rxInfo = m_rx[NodeId];
58  // Check if the NetDevice matches. A node may have several NetDevices
59  if (rxInfo.m_rxnd != nd)
60  {
61  return false;
62  }
63  rxInfo.rxRange = CalculateDistance (m_txLoc, rxLoc);
64  rxInfo.m_lbRx = lbRx.GetSeconds ();
65  rxInfo.SetPhyRxComplete ();
66  firstlastbitDelta = rxInfo.m_lbRx - rxInfo.m_fbRx;
67  return true;
68 }
69 
71 {
72  uint32_t NodeId = nd->GetNode ()->GetId ();
73  NS_ASSERT (m_rx.find (NodeId) != m_rx.end ());
74  return m_rx[NodeId];
75 }
76 
78 {
79  uint32_t NodeId = nd->GetNode ()->GetId ();
80  m_rx.erase (m_rx.find (NodeId));
81 }
82 
84 {
85 }
86 
88 {
89  return m_PhyRxComplete;
90 }
91 
93 {
94  m_PhyRxComplete = true;
95 }
96 
97 } // namespace ns3
double rxRange
Reception range.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:60
AnimRxInfo GetRxInfo(Ptr< const NetDevice > nd)
GetRxInfo.
void RemoveRxInfo(Ptr< const NetDevice > nd)
RemoveRxInfo.
AnimRxInfo helper class.
Vector m_txLoc
Transmitter's location.
bool ProcessRxEnd(Ptr< const NetDevice > nd, const Time &fbRx, Vector rxLoc)
Process RxEnd notifications.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:61
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
a 3d vector
Definition: vector.h:31
void ProcessRxBegin(Ptr< const NetDevice > nd, const Time &fbRx)
Process RxBegin notifications.
double GetSeconds(void) const
Definition: nstime.h:272
void ProcessRxDrop(Ptr< const NetDevice > nd)
Process RxDrop notifications.
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Definition: vector.cc:71
Ptr< const NetDevice > m_rxnd
Ptr to receiving NetDevice.
double m_fbRx
First bit receive time.
double firstlastbitDelta
Time delta between First bit Rx and Last bit Rx.
uint32_t m_txNodeId
Tx Node Id if NetDevice is unknown.
double m_lbRx
Last bit receive time.
bool IsPhyRxComplete()
Check if Wifi Phy Rx is Complete.
std::map< uint32_t, AnimRxInfo > m_rx
Collection of receivers.
Ptr< const NetDevice > m_txnd
Ptr to NetDevice that is transmitting.
AnimPacketInfo()
Default constructor.
void SetPhyRxComplete()
Set Wifi Phy Rx Complete.