A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
mpi-test-fixtures.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright 2018. Lawrence Livermore National Security, LLC.
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
* Author: Steven Smith <smith84@llnl.gov>
19
*/
20
21
#include <iomanip>
22
#include <sstream>
23
#include <ios>
24
42
namespace
ns3
{
43
44
template
<
typename
T>
class
Ptr;
45
class
Address;
46
class
Packet;
47
48
57
#define RANK0COUT(x) \
58
do \
59
if (SinkTracer::GetWorldRank () == 0) \
60
{ \
61
std::cout << "TEST : "
; \
62
std::ios_base::fmtflags f( std::cout.flags() ); \
63
std::cout << std::setfill('0') << std::setw(5) << SinkTracer::GetLineCount (); \
64
std::cout.flags( f ); \
65
std::cout << " : " << x; \
66
} \
67
while (false)
68
77
#define RANK0COUTAPPEND(x) \
78
do \
79
if (SinkTracer::GetWorldRank () == 0) \
80
{ \
81
std::cout << x ; \
82
} \
83
while (false)
84
90
class
SinkTracer
91
{
92
93
public
:
97
static
void
Init
(
void
);
98
103
static
void
SinkTrace
(
const
ns3::Ptr<const ns3::Packet>
packet,
104
const
ns3::Address
&srcAddress,
105
const
ns3::Address
&destAddress);
106
113
static
void
Verify
(
unsigned
long
expectedCount);
114
121
static
std::string
FormatAddress
(
const
ns3::Address
address
);
122
128
static
int
GetWorldRank
(
void
)
129
{
130
return
m_worldRank
;
131
}
132
138
static
int
GetWorldSize
(
void
)
139
{
140
return
m_worldSize
;
141
}
142
147
static
int
GetLineCount
(
void
)
148
{
149
return
m_line
++;
150
}
151
152
private
:
153
static
unsigned
long
m_sinkCount
;
154
static
unsigned
long
m_line
;
155
static
int
m_worldRank
;
156
static
int
m_worldSize
;
157
};
158
159
}
// namespace ns3
ns3::Address
a polymophic address class
Definition:
address.h:91
ns3::Ptr< const ns3::Packet >
ns3::SinkTracer
Collects data about incoming packets.
Definition:
mpi-test-fixtures.h:91
ns3::SinkTracer::SinkTrace
static void SinkTrace(const ns3::Ptr< const ns3::Packet > packet, const ns3::Address &srcAddress, const ns3::Address &destAddress)
PacketSink receive trace callback.
Definition:
mpi-test-fixtures.cc:50
ns3::SinkTracer::GetWorldRank
static int GetWorldRank(void)
Get the MPI rank in the world communicator.
Definition:
mpi-test-fixtures.h:128
ns3::SinkTracer::Init
static void Init(void)
PacketSink Init.
Definition:
mpi-test-fixtures.cc:40
ns3::SinkTracer::m_worldRank
static int m_worldRank
MPI CommWorld rank.
Definition:
mpi-test-fixtures.h:155
ns3::SinkTracer::GetLineCount
static int GetLineCount(void)
Get current line count and increment it.
Definition:
mpi-test-fixtures.h:147
ns3::SinkTracer::Verify
static void Verify(unsigned long expectedCount)
Verify the sink trace count observed matches the expected count.
Definition:
mpi-test-fixtures.cc:58
ns3::SinkTracer::m_worldSize
static int m_worldSize
MPI CommWorld size.
Definition:
mpi-test-fixtures.h:156
ns3::SinkTracer::m_line
static unsigned long m_line
Current output line number for ordering output.
Definition:
mpi-test-fixtures.h:154
ns3::SinkTracer::GetWorldSize
static int GetWorldSize(void)
Get the MPI size of the world communicator.
Definition:
mpi-test-fixtures.h:138
ns3::SinkTracer::m_sinkCount
static unsigned long m_sinkCount
Running sum of number of SinkTrace calls observed.
Definition:
mpi-test-fixtures.h:153
ns3::SinkTracer::FormatAddress
static std::string FormatAddress(const ns3::Address address)
Get the source address and port, as a formatted string.
Definition:
mpi-test-fixtures.cc:80
first.address
address
Definition:
first.py:44
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
mpi
examples
mpi-test-fixtures.h
Generated on Tue Feb 6 2024 19:21:24 for ns-3 by
1.9.1