author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Mon, 31 Mar 2008 14:56:41 -0700 | |
changeset 2834 | 1aab57845b07 |
parent 2594 | a8f89acd17a1 |
permissions | -rw-r--r-- |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
2 |
/* |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
3 |
* Copyright (c) 2007 INRIA |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
4 |
* |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation; |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
8 |
* |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
13 |
* |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
17 |
* |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
19 |
*/ |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
20 |
#include "ascii-trace.h" |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
21 |
|
2535
08297f16760f
port AsciiTrace to Config::ConnectWithContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1866
diff
changeset
|
22 |
#include "ns3/config.h" |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
23 |
#include "ns3/simulator.h" |
729
b5e744285e92
rename i-node to node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
24 |
#include "ns3/node.h" |
1229
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1195
diff
changeset
|
25 |
#include "ns3/packet.h" |
1281 | 26 |
#include "ns3/queue.h" |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
27 |
|
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
28 |
namespace ns3 { |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
29 |
|
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
30 |
AsciiTrace::AsciiTrace (std::string filename) |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
31 |
{ |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
32 |
m_os.open (filename.c_str ()); |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
33 |
} |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
34 |
AsciiTrace::~AsciiTrace () |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
35 |
{ |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
36 |
m_os.close (); |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
37 |
} |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
38 |
void |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
39 |
AsciiTrace::TraceAllQueues (void) |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
40 |
{ |
903
9ebdbfc46d48
use pretty printing in ascii output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
734
diff
changeset
|
41 |
Packet::EnableMetadata (); |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2542
diff
changeset
|
42 |
Config::Connect ("/NodeList/*/DeviceList/*/TxQueue/Enqueue", |
2535
08297f16760f
port AsciiTrace to Config::ConnectWithContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1866
diff
changeset
|
43 |
MakeCallback (&AsciiTrace::LogDevQueueEnqueue, this)); |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2542
diff
changeset
|
44 |
Config::Connect ("/NodeList/*/DeviceList/*/TxQueue/Dequeue", |
2535
08297f16760f
port AsciiTrace to Config::ConnectWithContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1866
diff
changeset
|
45 |
MakeCallback (&AsciiTrace::LogDevQueueDequeue, this)); |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2542
diff
changeset
|
46 |
Config::Connect ("/NodeList/*/DeviceList/*/TxQueue/Drop", |
2535
08297f16760f
port AsciiTrace to Config::ConnectWithContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1866
diff
changeset
|
47 |
MakeCallback (&AsciiTrace::LogDevQueueDrop, this)); |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
48 |
} |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
49 |
void |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
50 |
AsciiTrace::TraceAllNetDeviceRx (void) |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
51 |
{ |
903
9ebdbfc46d48
use pretty printing in ascii output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
734
diff
changeset
|
52 |
Packet::EnableMetadata (); |
2594
a8f89acd17a1
Config::Connect -> Config::ConnectWithoutContext && Config::ConnectWithContext -> Config::Connect
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2542
diff
changeset
|
53 |
Config::Connect ("/NodeList/*/DeviceList/*/Rx", |
2535
08297f16760f
port AsciiTrace to Config::ConnectWithContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1866
diff
changeset
|
54 |
MakeCallback (&AsciiTrace::LogDevRx, this)); |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
55 |
} |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
56 |
|
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
57 |
void |
2535
08297f16760f
port AsciiTrace to Config::ConnectWithContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1866
diff
changeset
|
58 |
AsciiTrace::LogDevQueueEnqueue (std::string context, |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
59 |
Ptr<const Packet> packet) |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
60 |
{ |
1281 | 61 |
m_os << "+ "; |
62 |
m_os << Simulator::Now ().GetSeconds () << " "; |
|
2535
08297f16760f
port AsciiTrace to Config::ConnectWithContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1866
diff
changeset
|
63 |
m_os << context; |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
64 |
m_os << " pkt-uid=" << packet->GetUid () << " "; |
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
65 |
packet->Print (m_os); |
1281 | 66 |
m_os << std::endl; |
67 |
} |
|
68 |
||
69 |
void |
|
2535
08297f16760f
port AsciiTrace to Config::ConnectWithContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1866
diff
changeset
|
70 |
AsciiTrace::LogDevQueueDequeue (std::string context, |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
71 |
Ptr<const Packet> packet) |
1281 | 72 |
{ |
73 |
m_os << "- "; |
|
74 |
m_os << Simulator::Now ().GetSeconds () << " "; |
|
2535
08297f16760f
port AsciiTrace to Config::ConnectWithContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1866
diff
changeset
|
75 |
m_os << context; |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
76 |
m_os << " pkt-uid=" << packet->GetUid () << " "; |
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
77 |
packet->Print (m_os); |
1281 | 78 |
m_os << std::endl; |
79 |
} |
|
80 |
||
81 |
void |
|
2535
08297f16760f
port AsciiTrace to Config::ConnectWithContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1866
diff
changeset
|
82 |
AsciiTrace::LogDevQueueDrop (std::string context, |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
83 |
Ptr<const Packet> packet) |
1281 | 84 |
{ |
85 |
m_os << "d "; |
|
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
86 |
m_os << Simulator::Now ().GetSeconds () << " "; |
2535
08297f16760f
port AsciiTrace to Config::ConnectWithContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1866
diff
changeset
|
87 |
m_os << context; |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
88 |
m_os << " pkt-uid=" << packet->GetUid () << " "; |
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
89 |
packet->Print (m_os); |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
90 |
m_os << std::endl; |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
91 |
} |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
92 |
void |
2535
08297f16760f
port AsciiTrace to Config::ConnectWithContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1866
diff
changeset
|
93 |
AsciiTrace::LogDevRx (std::string context, |
08297f16760f
port AsciiTrace to Config::ConnectWithContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1866
diff
changeset
|
94 |
Ptr<const Packet> p) |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
95 |
{ |
1281 | 96 |
m_os << "r " << Simulator::Now ().GetSeconds () << " "; |
2535
08297f16760f
port AsciiTrace to Config::ConnectWithContext
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1866
diff
changeset
|
97 |
m_os << context; |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
98 |
m_os << " pkt-uid=" << p->GetUid () << " "; |
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
99 |
p->Print (m_os); |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
100 |
m_os << std::endl; |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
101 |
} |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
102 |
|
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
103 |
}//namespace ns3 |