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
src
netanim
helper
animation-interface-helper.cc
Generated on Fri Dec 21 2012 19:00:43 for ns-3 by
1.8.1.2