A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  .AddConstructor <RemoteChannelBundle> ();
38  return tid;
39 }
40 
42  : m_remoteSystemId (-1),
43  m_guaranteeTime (0),
44  m_delay (NS_TIME_INFINITY)
45 {
46 }
47 
48 RemoteChannelBundle::RemoteChannelBundle (const uint32_t remoteSystemId)
49  : m_remoteSystemId (remoteSystemId),
50  m_guaranteeTime (0),
51  m_delay (NS_TIME_INFINITY)
52 {
53 }
54 
55 void
57 {
58  m_channels[channel->GetId ()] = channel;
59  m_delay = ns3::Min (m_delay, delay);
60 }
61 
62 uint32_t
64 {
65  return m_remoteSystemId;
66 }
67 
68 Time
70 {
71  return m_guaranteeTime;
72 }
73 
74 void
76 {
77  NS_ASSERT (time >= Simulator::Now ());
78 
79  m_guaranteeTime = time;
80 }
81 
82 Time
84 {
85  return m_delay;
86 }
87 
88 void
90 {
91  m_nullEventId = id;
92 }
93 
94 EventId
96 {
97  return m_nullEventId;
98 }
99 
100 int
102 {
103  return m_channels.size ();
104 }
105 
106 void
108 {
110 }
111 
112 std::ostream& operator<< (std::ostream& out, ns3::RemoteChannelBundle& bundle )
113 {
114  out << "RemoteChannelBundle Rank = " << bundle.m_remoteSystemId
115  << ", GuaranteeTime = " << bundle.m_guaranteeTime
116  << ", Delay = " << bundle.m_delay << std::endl;
117 
118  for (std::map < uint32_t, Ptr < Channel > > ::const_iterator pair = bundle.m_channels.begin ();
119  pair != bundle.m_channels.end ();
120  ++pair)
121  {
122  out << "\t" << (*pair).second << std::endl;
123  }
124 
125  return out;
126 }
127 
128 
129 } // namespace ns3
130 
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
EventId GetEventId(void) const
#define NS_ASSERT(condition)
Definition: assert.h:64
Collection of NS3 channels between local and remote nodes.
Time GetGuaranteeTime(void) const
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.
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Definition: int64x64.h:90
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:43
#define NS_TIME_INFINITY
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
an identifier for simulation events.
Definition: event-id.h:46
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:63
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611