author | Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
Mon, 01 Oct 2007 14:15:56 +0200 | |
changeset 1866 | e7dbcc4df546 |
parent 1381 | 6dd346ffeddc |
child 2535 | 08297f16760f |
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 |
* All rights reserved. |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
5 |
* |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
6 |
* 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
|
7 |
* 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
|
8 |
* published by the Free Software Foundation; |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
9 |
* |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
10 |
* 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
|
11 |
* 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
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
13 |
* GNU General Public License for more details. |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
14 |
* |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
15 |
* 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
|
16 |
* 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
|
17 |
* 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
|
18 |
* |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
19 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
20 |
*/ |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
21 |
#include "ascii-trace.h" |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
22 |
|
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
23 |
#include "ns3/trace-context.h" |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
24 |
#include "ns3/simulator.h" |
729
b5e744285e92
rename i-node to node
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
728
diff
changeset
|
25 |
#include "ns3/node.h" |
1362
162bd608c970
remove TraceRoot
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1229
diff
changeset
|
26 |
#include "ns3/node-list.h" |
1229
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1195
diff
changeset
|
27 |
#include "ns3/packet.h" |
1281 | 28 |
#include "ns3/queue.h" |
389
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 |
namespace ns3 { |
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 |
AsciiTrace::AsciiTrace (std::string filename) |
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 |
m_os.open (filename.c_str ()); |
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 |
AsciiTrace::~AsciiTrace () |
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 |
m_os.close (); |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
39 |
} |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
40 |
void |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
41 |
AsciiTrace::TraceAllQueues (void) |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
42 |
{ |
903
9ebdbfc46d48
use pretty printing in ascii output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
734
diff
changeset
|
43 |
Packet::EnableMetadata (); |
1376 | 44 |
NodeList::Connect ("/nodes/*/devices/*/queue/enqueue", |
1281 | 45 |
MakeCallback (&AsciiTrace::LogDevQueueEnqueue, this)); |
1376 | 46 |
NodeList::Connect ("/nodes/*/devices/*/queue/dequeue", |
1281 | 47 |
MakeCallback (&AsciiTrace::LogDevQueueDequeue, this)); |
1376 | 48 |
NodeList::Connect ("/nodes/*/devices/*/queue/drop", |
1281 | 49 |
MakeCallback (&AsciiTrace::LogDevQueueDrop, this)); |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
50 |
} |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
51 |
void |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
52 |
AsciiTrace::TraceAllNetDeviceRx (void) |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
53 |
{ |
903
9ebdbfc46d48
use pretty printing in ascii output
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
734
diff
changeset
|
54 |
Packet::EnableMetadata (); |
1362
162bd608c970
remove TraceRoot
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1229
diff
changeset
|
55 |
NodeList::Connect ("/nodes/*/devices/*/rx", |
162bd608c970
remove TraceRoot
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1229
diff
changeset
|
56 |
MakeCallback (&AsciiTrace::LogDevRx, this)); |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
57 |
} |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
58 |
|
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
59 |
void |
1281 | 60 |
AsciiTrace::LogDevQueueEnqueue (TraceContext const &context, |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
61 |
Ptr<const Packet> packet) |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
62 |
{ |
1281 | 63 |
m_os << "+ "; |
64 |
m_os << Simulator::Now ().GetSeconds () << " "; |
|
65 |
context.Print (m_os); |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
66 |
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
|
67 |
packet->Print (m_os); |
1281 | 68 |
m_os << std::endl; |
69 |
} |
|
70 |
||
71 |
void |
|
72 |
AsciiTrace::LogDevQueueDequeue (TraceContext const &context, |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
73 |
Ptr<const Packet> packet) |
1281 | 74 |
{ |
75 |
m_os << "- "; |
|
76 |
m_os << Simulator::Now ().GetSeconds () << " "; |
|
77 |
context.Print (m_os); |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
78 |
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
|
79 |
packet->Print (m_os); |
1281 | 80 |
m_os << std::endl; |
81 |
} |
|
82 |
||
83 |
void |
|
84 |
AsciiTrace::LogDevQueueDrop (TraceContext const &context, |
|
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
85 |
Ptr<const Packet> packet) |
1281 | 86 |
{ |
87 |
m_os << "d "; |
|
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
88 |
m_os << Simulator::Now ().GetSeconds () << " "; |
1229
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1195
diff
changeset
|
89 |
context.Print (m_os); |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
90 |
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
|
91 |
packet->Print (m_os); |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
92 |
m_os << std::endl; |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
93 |
} |
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
94 |
void |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
95 |
AsciiTrace::LogDevRx (TraceContext const &context, Ptr<const Packet> p) |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
96 |
{ |
1281 | 97 |
m_os << "r " << Simulator::Now ().GetSeconds () << " "; |
1229
e4cfe4094c10
build with the new TraceContextElement API
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1195
diff
changeset
|
98 |
context.Print (m_os); |
1866
e7dbcc4df546
do not use Packet objects directly. Use Ptr<Packet> instead
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
1381
diff
changeset
|
99 |
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
|
100 |
p->Print (m_os); |
389
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
101 |
m_os << std::endl; |
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 |
|
d8f84756cf21
split out AsciiTrace class from simple example
mathieu@mathieu.inria.fr
parents:
diff
changeset
|
104 |
}//namespace ns3 |