|
gjc@3519
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
|
gjc@3519
|
2 |
/*
|
|
gjc@3519
|
3 |
* Copyright (c) 2008 INESC Porto
|
|
gjc@3519
|
4 |
*
|
|
gjc@3519
|
5 |
* This program is free software; you can redistribute it and/or modify
|
|
gjc@3519
|
6 |
* it under the terms of the GNU General Public License version 2 as
|
|
gjc@3519
|
7 |
* published by the Free Software Foundation;
|
|
gjc@3519
|
8 |
*
|
|
gjc@3519
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
gjc@3519
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
gjc@3519
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
gjc@3519
|
12 |
* GNU General Public License for more details.
|
|
gjc@3519
|
13 |
*
|
|
gjc@3519
|
14 |
* You should have received a copy of the GNU General Public License
|
|
gjc@3519
|
15 |
* along with this program; if not, write to the Free Software
|
|
gjc@3519
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
gjc@3519
|
17 |
*
|
|
gjc@3519
|
18 |
* C++ helper functions for use by the python visualizer (for things
|
|
gjc@3519
|
19 |
* Python is too slow at).
|
|
gjc@3519
|
20 |
*
|
|
gjc@3519
|
21 |
* Author: Gustavo Carneiro <gjc@inescporto.pt>
|
|
gjc@3519
|
22 |
*/
|
|
gjc@3519
|
23 |
#ifndef NS3_PYVIZ_H
|
|
gjc@3519
|
24 |
#define NS3_PYVIZ_H
|
|
gjc@3519
|
25 |
|
|
gjc@3519
|
26 |
#include "ns3/nstime.h"
|
|
gjc@3595
|
27 |
#include "ns3/node.h"
|
|
gjc@3595
|
28 |
#include "ns3/channel.h"
|
|
gjc@3595
|
29 |
#include "ns3/packet.h"
|
|
gjc@3595
|
30 |
#include "ns3/mac48-address.h"
|
|
gjc@3595
|
31 |
#include <map>
|
|
gjc@3519
|
32 |
|
|
gjc@3530
|
33 |
namespace ns3 {
|
|
gjc@3530
|
34 |
|
|
gjc@3530
|
35 |
class PyViz
|
|
gjc@3519
|
36 |
{
|
|
gjc@3530
|
37 |
public:
|
|
gjc@3530
|
38 |
PyViz ();
|
|
gjc@3530
|
39 |
~PyViz ();
|
|
gjc@3530
|
40 |
|
|
gjc@3530
|
41 |
// Run simulation until a given (simulated, absolute) time is reached
|
|
gjc@3530
|
42 |
void SimulatorRunUntil (Time time);
|
|
gjc@3595
|
43 |
|
|
gjc@3595
|
44 |
struct TransmissionSample
|
|
gjc@3595
|
45 |
{
|
|
gjc@3595
|
46 |
Ptr<Node> transmitter;
|
|
gjc@3595
|
47 |
Ptr<Node> receiver; // NULL if broadcast
|
|
gjc@3595
|
48 |
Ptr<Channel> channel;
|
|
gjc@3595
|
49 |
uint32_t bytes;
|
|
gjc@3595
|
50 |
};
|
|
gjc@3595
|
51 |
|
|
gjc@3595
|
52 |
typedef std::vector<TransmissionSample> TransmissionSampleList;
|
|
gjc@3595
|
53 |
|
|
gjc@3595
|
54 |
TransmissionSampleList GetTransmissionSamples () const;
|
|
gjc@3595
|
55 |
|
|
gjc@3595
|
56 |
private:
|
|
gjc@3595
|
57 |
|
|
gjc@3595
|
58 |
struct TxRecord
|
|
gjc@3595
|
59 |
{
|
|
gjc@3595
|
60 |
Ptr<Node> srcNode;
|
|
gjc@3595
|
61 |
};
|
|
gjc@3595
|
62 |
std::map<uint32_t, TxRecord> m_txRecords;
|
|
gjc@3595
|
63 |
|
|
gjc@3595
|
64 |
struct TransmissionSampleKey
|
|
gjc@3595
|
65 |
{
|
|
gjc@3595
|
66 |
bool operator < (TransmissionSampleKey const &other) const;
|
|
gjc@3595
|
67 |
Ptr<Node> transmitter;
|
|
gjc@3595
|
68 |
Ptr<Node> receiver; // NULL if broadcast
|
|
gjc@3595
|
69 |
Ptr<Channel> channel;
|
|
gjc@3595
|
70 |
};
|
|
gjc@3595
|
71 |
|
|
gjc@3595
|
72 |
struct TransmissionSampleValue
|
|
gjc@3595
|
73 |
{
|
|
gjc@3595
|
74 |
TransmissionSampleValue () : bytes (0) {}
|
|
gjc@3595
|
75 |
uint32_t bytes;
|
|
gjc@3595
|
76 |
};
|
|
gjc@3595
|
77 |
|
|
gjc@3595
|
78 |
std::map<TransmissionSampleKey, TransmissionSampleValue> m_transmissionSamples;
|
|
gjc@3595
|
79 |
|
|
gjc@3595
|
80 |
void TraceNetDevTx (std::string context, Ptr<const Packet> packet, Mac48Address address);
|
|
gjc@3595
|
81 |
void TraceNetDevRx (std::string context, Ptr<const Packet> packet, Mac48Address address);
|
|
gjc@3595
|
82 |
|
|
gjc@3530
|
83 |
};
|
|
gjc@3519
|
84 |
|
|
gjc@3530
|
85 |
|
|
gjc@3519
|
86 |
}
|
|
gjc@3519
|
87 |
|
|
gjc@3519
|
88 |
#endif /* NS3_PYVIZ_H */
|