A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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 {
29
AnimPacketInfo::AnimPacketInfo
()
30
: m_txnd (0), m_fbTx (0), m_lbTx (0),
31
m_txLoc (
Vector
(0,0,0))
32
{
33
}
34
35
AnimPacketInfo::AnimPacketInfo
(
Ptr <const NetDevice>
txnd,
const
Time
& fbTx,
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
44
void
AnimPacketInfo::ProcessRxBegin
(
Ptr<const NetDevice>
nd,
const
Time
& fbRx)
45
{
46
m_rx
[nd->GetNode ()->GetId ()] =
AnimRxInfo
(fbRx, nd, 0);
47
}
48
49
bool
AnimPacketInfo::ProcessRxEnd
(
Ptr<const NetDevice>
nd,
const
Time
& lbRx,
Vector
rxLoc)
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
70
AnimRxInfo
AnimPacketInfo::GetRxInfo
(
Ptr<const NetDevice>
nd)
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
77
void
AnimPacketInfo::RemoveRxInfo
(
Ptr<const NetDevice>
nd)
78
{
79
uint32_t NodeId = nd->GetNode ()->GetId ();
80
m_rx
.erase (
m_rx
.find (NodeId));
81
}
82
83
void
AnimPacketInfo::ProcessRxDrop
(
Ptr<const NetDevice>
nd)
84
{
85
}
86
87
bool
AnimRxInfo::IsPhyRxComplete
()
88
{
89
return
m_PhyRxComplete
;
90
}
91
92
void
AnimRxInfo::SetPhyRxComplete
()
93
{
94
m_PhyRxComplete
=
true
;
95
}
96
97
}
// namespace ns3
ns3::AnimRxInfo::rxRange
double rxRange
Reception range.
Definition:
animation-interface-helper.h:93
ns3::Time
keep track of time values and allow control of global simulation resolution
Definition:
nstime.h:81
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
ns3::AnimPacketInfo::GetRxInfo
AnimRxInfo GetRxInfo(Ptr< const NetDevice > nd)
GetRxInfo.
Definition:
animation-interface-helper.cc:70
ns3::AnimPacketInfo::RemoveRxInfo
void RemoveRxInfo(Ptr< const NetDevice > nd)
RemoveRxInfo.
Definition:
animation-interface-helper.cc:77
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("AnimationInterfaceHelper")
ns3::AnimRxInfo
AnimRxInfo helper class.
Definition:
animation-interface-helper.h:47
ns3::AnimPacketInfo::m_txLoc
Vector m_txLoc
Transmitter's location.
Definition:
animation-interface-helper.h:183
ns3::AnimPacketInfo::ProcessRxEnd
bool ProcessRxEnd(Ptr< const NetDevice > nd, const Time &fbRx, Vector rxLoc)
Process RxEnd notifications.
Definition:
animation-interface-helper.cc:49
NS_ASSERT
#define NS_ASSERT(condition)
Definition:
assert.h:64
ns3::Vector3D
a 3d vector
Definition:
vector.h:31
ns3::AnimPacketInfo::ProcessRxBegin
void ProcessRxBegin(Ptr< const NetDevice > nd, const Time &fbRx)
Process RxBegin notifications.
Definition:
animation-interface-helper.cc:44
ns3::Time::GetSeconds
double GetSeconds(void) const
Definition:
nstime.h:274
ns3::AnimPacketInfo::ProcessRxDrop
void ProcessRxDrop(Ptr< const NetDevice > nd)
Process RxDrop notifications.
Definition:
animation-interface-helper.cc:83
ns3::CalculateDistance
double CalculateDistance(const Vector3D &a, const Vector3D &b)
Definition:
vector.cc:71
ns3::AnimRxInfo::m_PhyRxComplete
bool m_PhyRxComplete
Definition:
animation-interface-helper.h:109
ns3::AnimRxInfo::m_rxnd
Ptr< const NetDevice > m_rxnd
Ptr to receiving NetDevice.
Definition:
animation-interface-helper.h:86
ns3::AnimRxInfo::m_fbRx
double m_fbRx
First bit receive time.
Definition:
animation-interface-helper.h:72
ns3::AnimPacketInfo::firstlastbitDelta
double firstlastbitDelta
Time delta between First bit Rx and Last bit Rx.
Definition:
animation-interface-helper.h:237
ns3::AnimPacketInfo::m_txNodeId
uint32_t m_txNodeId
Tx Node Id if NetDevice is unknown.
Definition:
animation-interface-helper.h:162
ns3::AnimRxInfo::m_lbRx
double m_lbRx
Last bit receive time.
Definition:
animation-interface-helper.h:79
ns3::AnimRxInfo::IsPhyRxComplete
bool IsPhyRxComplete()
Check if Wifi Phy Rx is Complete.
Definition:
animation-interface-helper.cc:87
ns3::AnimPacketInfo::m_rx
std::map< uint32_t, AnimRxInfo > m_rx
Collection of receivers.
Definition:
animation-interface-helper.h:191
ns3::AnimPacketInfo::m_txnd
Ptr< const NetDevice > m_txnd
Ptr to NetDevice that is transmitting.
Definition:
animation-interface-helper.h:155
ns3::AnimPacketInfo::AnimPacketInfo
AnimPacketInfo()
Default constructor.
Definition:
animation-interface-helper.cc:29
ns3::AnimRxInfo::SetPhyRxComplete
void SetPhyRxComplete()
Set Wifi Phy Rx Complete.
Definition:
animation-interface-helper.cc:92
src
netanim
helper
animation-interface-helper.cc
Generated on Sat Apr 19 2014 14:07:04 for ns-3 by
1.8.6