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
pyviz.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008 INESC Porto
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* C++ helper functions for use by the python visualizer (for things
19
* Python is too slow at).
20
*
21
* Author: Gustavo Carneiro <gjc@inescporto.pt>
22
*/
23
#ifndef NS3_PYVIZ_H
24
#define NS3_PYVIZ_H
25
26
#include "ns3/nstime.h"
27
#include "ns3/event-id.h"
28
#include "ns3/node.h"
29
#include "ns3/channel.h"
30
#include "ns3/packet.h"
31
#include "ns3/mac48-address.h"
32
#include "ns3/ipv4-header.h"
33
#include "ns3/ipv4-l3-protocol.h"
34
35
#include <map>
36
#include <set>
37
38
namespace
ns3 {
39
51
class
PyViz
52
{
53
public
:
54
PyViz
();
55
~PyViz
();
56
57
void
RegisterDropTracePath
(std::string
const
&tracePath);
58
59
void
RegisterCsmaLikeDevice
(std::string
const
&deviceTypeName);
60
void
RegisterWifiLikeDevice
(std::string
const
&deviceTypeName);
61
void
RegisterPointToPointLikeDevice
(std::string
const
&deviceTypeName);
62
63
// Run simulation until a given (simulated, absolute) time is reached
64
void
SimulatorRunUntil
(
Time
time);
65
66
static
void
Pause
(std::string
const
&message);
67
std::vector<std::string>
GetPauseMessages
()
const
;
68
69
struct
TransmissionSample
70
{
71
Ptr<Node>
transmitter
;
72
Ptr<Node>
receiver
;
// NULL if broadcast
73
Ptr<Channel>
channel
;
74
uint32_t
bytes
;
75
};
76
typedef
std::vector<TransmissionSample>
TransmissionSampleList
;
77
TransmissionSampleList
GetTransmissionSamples
()
const
;
78
79
struct
PacketDropSample
80
{
81
Ptr<Node>
transmitter
;
82
uint32_t
bytes
;
83
};
84
typedef
std::vector<PacketDropSample>
PacketDropSampleList
;
85
PacketDropSampleList
GetPacketDropSamples
()
const
;
86
87
88
struct
PacketSample
89
{
90
Time
time
;
91
Ptr<Packet>
packet
;
92
Ptr<NetDevice>
device
;
93
};
94
struct
TxPacketSample
:
PacketSample
95
{
96
Mac48Address
to
;
97
};
98
struct
RxPacketSample
:
PacketSample
99
{
100
Mac48Address
from
;
101
};
102
103
struct
LastPacketsSample
104
{
105
std::vector<RxPacketSample>
lastReceivedPackets
;
106
std::vector<TxPacketSample>
lastTransmittedPackets
;
107
std::vector<PacketSample>
lastDroppedPackets
;
108
};
109
LastPacketsSample
GetLastPackets
(uint32_t nodeId)
const
;
110
111
112
void
SetNodesOfInterest
(std::set<uint32_t> nodes);
113
114
struct
NetDeviceStatistics
115
{
116
NetDeviceStatistics
() :
transmittedBytes
(0),
receivedBytes
(0),
117
transmittedPackets
(0),
receivedPackets
(0) {}
118
uint64_t
transmittedBytes
;
119
uint64_t
receivedBytes
;
120
uint32_t
transmittedPackets
;
121
uint32_t
receivedPackets
;
122
};
123
124
struct
NodeStatistics
125
{
126
uint32_t
nodeId
;
127
std::vector<NetDeviceStatistics>
statistics
;
128
};
129
130
std::vector<NodeStatistics>
GetNodesStatistics
()
const
;
131
132
enum
PacketCaptureMode
{
133
PACKET_CAPTURE_DISABLED
=1,
// packet capture is disabled
134
PACKET_CAPTURE_FILTER_HEADERS_OR
,
// packet capture if any of the indicated headers is present
135
PACKET_CAPTURE_FILTER_HEADERS_AND
,
// packet capture if all of the indicated headers are present
136
};
137
138
struct
PacketCaptureOptions
139
{
140
std::set<TypeId>
headers
;
141
uint32_t
numLastPackets
;
142
PacketCaptureMode
mode
;
143
};
144
145
void
SetPacketCaptureOptions
(uint32_t nodeId,
PacketCaptureOptions
options);
146
147
148
// Yes, I know, this is just a utility function, not really related to the class in any way.
149
150
// -#- @lineX1(direction=inout); @lineY1(direction=inout); @lineX2(direction=inout); @lineY2(direction=inout) -#-
151
static
void
LineClipping
(
double
boundsX1,
double
boundsY1,
double
boundsX2,
double
boundsY2,
double
&lineX1,
double
&lineY1,
double
&lineX2,
double
&lineY2);
// don't break this line or pybindgen will not be able to pick up the above annotation :(
152
153
154
private
:
155
156
bool
GetPacketCaptureOptions
(uint32_t nodeId,
const
PacketCaptureOptions
**outOptions)
const
;
157
static
bool
FilterPacket
(
Ptr<const Packet>
packet,
const
PacketCaptureOptions
&options);
158
159
160
typedef
std::pair<Ptr<Channel>, uint32_t>
TxRecordKey
;
161
162
struct
TxRecordValue
163
{
164
Time
time
;
165
Ptr<Node>
srcNode
;
166
bool
isBroadcast
;
167
};
168
169
struct
TransmissionSampleKey
170
{
171
bool
operator <
(
TransmissionSampleKey
const
&other)
const
;
172
bool
operator ==
(
TransmissionSampleKey
const
&other)
const
;
173
Ptr<Node>
transmitter
;
174
Ptr<Node>
receiver
;
// NULL if broadcast
175
Ptr<Channel>
channel
;
176
};
177
178
struct
TransmissionSampleValue
179
{
180
uint32_t
bytes
;
181
};
182
183
// data
184
std::map<uint32_t, PacketCaptureOptions>
m_packetCaptureOptions
;
185
std::vector<std::string>
m_pauseMessages
;
186
std::map<TxRecordKey, TxRecordValue>
m_txRecords
;
187
std::map<TransmissionSampleKey, TransmissionSampleValue>
m_transmissionSamples
;
188
std::map<Ptr<Node>, uint32_t>
m_packetDrops
;
189
std::set<uint32_t>
m_nodesOfInterest
;
// list of node IDs whose transmissions will be monitored
190
std::map<uint32_t, Time>
m_packetsOfInterest
;
// list of packet UIDs that will be monitored
191
std::map<uint32_t, LastPacketsSample>
m_lastPackets
;
192
std::map<uint32_t, std::vector<NetDeviceStatistics> >
m_nodesStatistics
;
193
194
// Trace callbacks
195
void
TraceNetDevTxCommon
(std::string
const
&context,
Ptr<const Packet>
packet,
Mac48Address
const
&destination);
196
void
TraceNetDevRxCommon
(std::string
const
&context,
Ptr<const Packet>
packet,
Mac48Address
const
&source);
197
198
void
TraceNetDevTxWifi
(std::string context,
Ptr<const Packet>
packet);
199
void
TraceNetDevRxWifi
(std::string context,
Ptr<const Packet>
packet);
200
201
void
TraceDevQueueDrop
(std::string context,
Ptr<const Packet>
packet);
202
void
TraceIpv4Drop
(std::string context,
ns3::Ipv4Header
const
&hdr,
Ptr<const Packet>
packet,
203
ns3::Ipv4L3Protocol::DropReason
reason,
Ptr<Ipv4>
dummy_ipv4, uint32_t interface);
204
205
void
TraceNetDevTxCsma
(std::string context,
Ptr<const Packet>
packet);
206
void
TraceNetDevRxCsma
(std::string context,
Ptr<const Packet>
packet);
207
void
TraceNetDevPromiscRxCsma
(std::string context,
Ptr<const Packet>
packet);
208
209
void
TraceNetDevTxPointToPoint
(std::string context,
Ptr<const Packet>
packet);
210
void
TraceNetDevRxPointToPoint
(std::string context,
Ptr<const Packet>
packet);
211
212
void
TraceNetDevTxWimax
(std::string context,
Ptr<const Packet>
packet,
Mac48Address
const
&destination);
213
void
TraceNetDevRxWimax
(std::string context,
Ptr<const Packet>
packet,
Mac48Address
const
&source);
214
215
void
TraceNetDevTxLte
(std::string context,
Ptr<const Packet>
packet,
Mac48Address
const
&destination);
216
void
TraceNetDevRxLte
(std::string context,
Ptr<const Packet>
packet,
Mac48Address
const
&source);
217
218
inline
NetDeviceStatistics
&
FindNetDeviceStatistics
(
int
node,
int
interface);
219
220
void
DoPause
(std::string
const
&message);
221
222
bool
m_stop
;
223
Time
m_runUntil
;
224
void
CallbackStopSimulation
();
225
};
226
227
228
}
229
230
#endif
/* NS3_PYVIZ_H */
src
visualizer
model
pyviz.h
Generated on Fri Dec 21 2012 19:00:48 for ns-3 by
1.8.1.2