A Discrete-Event Network Simulator
API
remote-channel-bundle.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright 2013. 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 
22 #include "remote-channel-bundle.h"
23 
26 
27 #include <ns3/simulator.h>
28 
29 namespace ns3 {
30 
31 #define NS_TIME_INFINITY ns3::Time (0x7fffffffffffffffLL)
32 
34 {
35  static TypeId tid = TypeId ("ns3::RemoteChannelBundle")
36  .SetParent<Object> ()
37  .SetGroupName ("Mpi")
38  .AddConstructor <RemoteChannelBundle> ();
39  return tid;
40 }
41 
43  : m_remoteSystemId (UINT32_MAX),
44  m_guaranteeTime (0),
45  m_delay (NS_TIME_INFINITY)
46 {
47 }
48 
49 RemoteChannelBundle::RemoteChannelBundle (const uint32_t remoteSystemId)
50  : m_remoteSystemId (remoteSystemId),
51  m_guaranteeTime (0),
52  m_delay (NS_TIME_INFINITY)
53 {
54 }
55 
56 void
58 {
59  m_channels[channel->GetId ()] = channel;
60  m_delay = ns3::Min (m_delay, delay);
61 }
62 
63 uint32_t
65 {
66  return m_remoteSystemId;
67 }
68 
69 Time
71 {
72  return m_guaranteeTime;
73 }
74 
75 void
77 {
78  NS_ASSERT (time >= Simulator::Now ());
79 
80  m_guaranteeTime = time;
81 }
82 
83 Time
85 {
86  return m_delay;
87 }
88 
89 void
91 {
92  m_nullEventId = id;
93 }
94 
95 EventId
97 {
98  return m_nullEventId;
99 }
100 
101 std::size_t
103 {
104  return m_channels.size ();
105 }
106 
107 void
109 {
111 }
112 
113 std::ostream& operator<< (std::ostream& out, ns3::RemoteChannelBundle& bundle )
114 {
115  out << "RemoteChannelBundle Rank = " << bundle.m_remoteSystemId
116  << ", GuaranteeTime = " << bundle.m_guaranteeTime
117  << ", Delay = " << bundle.m_delay << std::endl;
118 
119  for (std::map < uint32_t, Ptr < Channel > > ::const_iterator pair = bundle.m_channels.begin ();
120  pair != bundle.m_channels.end ();
121  ++pair)
122  {
123  out << "\t" << (*pair).second << std::endl;
124  }
125 
126  return out;
127 }
128 
129 
130 } // namespace ns3
131 
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
Collection of NS3 channels between local and remote nodes.
channel
Definition: third.py:92
std::size_t GetSize(void) const
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:197
void AddChannel(Ptr< Channel > channel, Time delay)
static void SendNullMessage(const Time &guaranteeUpdate, Ptr< RemoteChannelBundle > bundle)
Send a Null Message to across the specified bundle.
std::map< uint32_t, Ptr< Channel > > m_channels
std::ostream & operator<<(std::ostream &os, const Angles &a)
print a struct Angles to output
Definition: angles.cc:42
EventId GetEventId(void) const
Every class exported by the ns3 library is enclosed in the ns3 namespace.
#define NS_TIME_INFINITY
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:193
An identifier for simulation events.
Definition: event-id.h:53
void SetEventId(EventId id)
Set the event ID of the Null Message send event current scheduled for this channel.
A base class which provides memory management and object aggregation.
Definition: object.h:87
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915