A Discrete-Event Network Simulator
API
mpi-test-fixtures.h
Go to the documentation of this file.
1/*
2 * Copyright 2018. Lawrence Livermore National Security, LLC.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Steven Smith <smith84@llnl.gov>
18 */
19
20#include <iomanip>
21#include <ios>
22#include <sstream>
23
41namespace ns3
42{
43
44template <typename T>
45class Ptr;
46class Address;
47class Packet;
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
91{
92 public:
96 static void Init();
97
102 static void SinkTrace(const ns3::Ptr<const ns3::Packet> packet,
103 const ns3::Address& srcAddress,
104 const ns3::Address& destAddress);
105
112 static void Verify(unsigned long expectedCount);
113
120 static std::string FormatAddress(const ns3::Address address);
121
127 static int GetWorldRank()
128 {
129 return m_worldRank;
130 }
131
137 static int GetWorldSize()
138 {
139 return m_worldSize;
140 }
141
146 static int GetLineCount()
147 {
148 return m_line++;
149 }
150
151 private:
152 static unsigned long m_sinkCount;
153 static unsigned long m_line;
154 static int m_worldRank;
155 static int m_worldSize;
156};
157
158} // namespace ns3
a polymophic address class
Definition: address.h:92
Collects data about incoming packets.
static void SinkTrace(const ns3::Ptr< const ns3::Packet > packet, const ns3::Address &srcAddress, const ns3::Address &destAddress)
PacketSink receive trace callback.
static int m_worldRank
MPI CommWorld rank.
static void Verify(unsigned long expectedCount)
Verify the sink trace count observed matches the expected count.
static int m_worldSize
MPI CommWorld size.
static unsigned long m_line
Current output line number for ordering output.
static void Init()
PacketSink Init.
static int GetWorldSize()
Get the MPI size of the world communicator.
static int GetLineCount()
Get current line count and increment it.
static int GetWorldRank()
Get the MPI rank in the world communicator.
static unsigned long m_sinkCount
Running sum of number of SinkTrace calls observed.
static std::string FormatAddress(const ns3::Address address)
Get the source address and port, as a formatted string.
address
Definition: first.py:40
Every class exported by the ns3 library is enclosed in the ns3 namespace.