A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
mpi
model
remote-channel-bundle-manager.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-manager.h
"
23
24
#include "
remote-channel-bundle.h
"
25
#include "
null-message-simulator-impl.h
"
26
27
#include "ns3/simulator.h"
28
29
namespace
ns3
{
30
31
bool
ns3::RemoteChannelBundleManager::g_initialized
=
false
;
32
ns3::RemoteChannelBundleManager::RemoteChannelMap
ns3::RemoteChannelBundleManager::g_remoteChannelBundles
;
33
34
Ptr<RemoteChannelBundle>
35
RemoteChannelBundleManager::Find
(uint32_t systemId)
36
{
37
ns3::RemoteChannelBundleManager::RemoteChannelMap::iterator kv =
g_remoteChannelBundles
.find (systemId);
38
39
if
( kv ==
g_remoteChannelBundles
.end ())
40
{
41
return
0;
42
}
43
else
44
{
45
return
kv->second;
46
}
47
}
48
49
Ptr<RemoteChannelBundle>
50
RemoteChannelBundleManager::Add
(uint32_t systemId)
51
{
52
NS_ASSERT
(!
g_initialized
);
53
NS_ASSERT
(
g_remoteChannelBundles
.find (systemId) ==
g_remoteChannelBundles
.end ());
54
55
Ptr<RemoteChannelBundle>
remoteChannelBundle = Create<RemoteChannelBundle> (systemId);
56
57
g_remoteChannelBundles
[systemId] = remoteChannelBundle;
58
59
return
remoteChannelBundle;
60
}
61
62
std::size_t
63
RemoteChannelBundleManager::Size
(
void
)
64
{
65
return
g_remoteChannelBundles
.size();
66
}
67
68
void
69
RemoteChannelBundleManager::InitializeNullMessageEvents
(
void
)
70
{
71
NS_ASSERT
(!
g_initialized
);
72
73
for
( RemoteChannelMap::const_iterator iter =
g_remoteChannelBundles
.begin ();
74
iter !=
g_remoteChannelBundles
.end ();
75
++iter )
76
{
77
Ptr<RemoteChannelBundle>
bundle = iter->second;
78
bundle->Send (bundle->GetDelay ());
79
80
NullMessageSimulatorImpl::GetInstance
()->
ScheduleNullMessageEvent
(bundle);
81
}
82
83
g_initialized
=
true
;
84
}
85
86
Time
87
RemoteChannelBundleManager::GetSafeTime
(
void
)
88
{
89
NS_ASSERT
(
g_initialized
);
90
91
Time
safeTime =
Simulator::GetMaximumSimulationTime
();
92
93
for
(RemoteChannelMap::const_iterator kv =
g_remoteChannelBundles
.begin ();
94
kv !=
g_remoteChannelBundles
.end ();
95
++kv)
96
{
97
safeTime =
Min
(safeTime, kv->second->GetGuaranteeTime ());
98
}
99
100
return
safeTime;
101
}
102
103
void
104
RemoteChannelBundleManager::Destroy
(
void
)
105
{
106
NS_ASSERT
(
g_initialized
);
107
108
g_remoteChannelBundles
.clear();
109
g_initialized
=
false
;
110
}
111
112
}
// namespace ns3
ns3::RemoteChannelBundleManager::RemoteChannelMap
std::map< uint32_t, Ptr< RemoteChannelBundle > > RemoteChannelMap
Definition:
remote-channel-bundle-manager.h:95
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:102
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:73
null-message-simulator-impl.h
NS_ASSERT
#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
ns3::NullMessageSimulatorImpl::GetInstance
static NullMessageSimulatorImpl * GetInstance(void)
Definition:
null-message-simulator-impl.cc:598
ns3::RemoteChannelBundleManager::g_remoteChannelBundles
static RemoteChannelMap g_remoteChannelBundles
Definition:
remote-channel-bundle-manager.h:96
ns3::Min
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition:
int64x64.h:197
ns3::RemoteChannelBundleManager::GetSafeTime
static Time GetSafeTime(void)
Definition:
remote-channel-bundle-manager.cc:87
ns3::RemoteChannelBundleManager::InitializeNullMessageEvents
static void InitializeNullMessageEvents(void)
Setup initial Null Message events for every RemoteChannelBundle.
Definition:
remote-channel-bundle-manager.cc:69
ns3::RemoteChannelBundleManager::g_initialized
static bool g_initialized
Definition:
remote-channel-bundle-manager.h:102
ns3::RemoteChannelBundleManager::Destroy
static void Destroy(void)
Destroy the singleton.
Definition:
remote-channel-bundle-manager.cc:104
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::RemoteChannelBundleManager::Find
static Ptr< RemoteChannelBundle > Find(uint32_t systemId)
Definition:
remote-channel-bundle-manager.cc:35
remote-channel-bundle-manager.h
ns3::RemoteChannelBundleManager::Add
static Ptr< RemoteChannelBundle > Add(uint32_t systemId)
Add RemoteChannelBundle from this task to MPI task on other side of the link.
Definition:
remote-channel-bundle-manager.cc:50
remote-channel-bundle.h
ns3::RemoteChannelBundleManager::Size
static std::size_t Size(void)
Definition:
remote-channel-bundle-manager.cc:63
ns3::NullMessageSimulatorImpl::ScheduleNullMessageEvent
void ScheduleNullMessageEvent(Ptr< RemoteChannelBundle > bundle)
Definition:
null-message-simulator-impl.cc:265
ns3::Simulator::GetMaximumSimulationTime
static Time GetMaximumSimulationTime(void)
Get the maximum representable simulation time.
Definition:
simulator.cc:371
Generated on Wed Nov 7 2018 10:02:06 for ns-3 by
1.8.14