A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
realtime-simulator-impl.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2008 University of Washington
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
19
#ifndef REALTIME_SIMULATOR_IMPL_H
20
#define REALTIME_SIMULATOR_IMPL_H
21
22
#include "
simulator-impl.h
"
23
#include "
system-thread.h
"
24
25
#include "
scheduler.h
"
26
#include "
synchronizer.h
"
27
#include "
event-impl.h
"
28
29
#include "
ptr.h
"
30
#include "
assert.h
"
31
#include "
log.h
"
32
#include "
system-mutex.h
"
33
34
#include <list>
35
36
namespace
ns3 {
37
38
class
RealtimeSimulatorImpl
:
public
SimulatorImpl
39
{
40
public
:
41
static
TypeId
GetTypeId
(
void
);
42
47
enum
SynchronizationMode
{
48
SYNC_BEST_EFFORT
,
49
SYNC_HARD_LIMIT
,
50
};
51
52
RealtimeSimulatorImpl
();
53
~RealtimeSimulatorImpl
();
54
55
virtual
void
Destroy
();
56
virtual
bool
IsFinished
(
void
)
const
;
57
virtual
void
Stop
(
void
);
58
virtual
void
Stop
(
Time
const
&time);
59
virtual
EventId
Schedule
(
Time
const
&time,
EventImpl
*event);
60
virtual
void
ScheduleWithContext
(uint32_t context,
Time
const
&time,
EventImpl
*event);
61
virtual
EventId
ScheduleNow
(
EventImpl
*event);
62
virtual
EventId
ScheduleDestroy
(
EventImpl
*event);
63
virtual
void
Remove
(
const
EventId
&ev);
64
virtual
void
Cancel
(
const
EventId
&ev);
65
virtual
bool
IsExpired
(
const
EventId
&ev)
const
;
66
virtual
void
Run
(
void
);
67
virtual
Time
Now
(
void
)
const
;
68
virtual
Time
GetDelayLeft
(
const
EventId
&
id
)
const
;
69
virtual
Time
GetMaximumSimulationTime
(
void
)
const
;
70
virtual
void
SetScheduler
(
ObjectFactory
schedulerFactory);
71
virtual
uint32_t
GetSystemId
(
void
)
const
;
72
virtual
uint32_t
GetContext
(
void
)
const
;
73
74
void
ScheduleRealtimeWithContext
(uint32_t context,
Time
const
&time,
EventImpl
*event);
75
void
ScheduleRealtime
(
Time
const
&time,
EventImpl
*event);
76
void
ScheduleRealtimeNowWithContext
(uint32_t context,
EventImpl
*event);
77
void
ScheduleRealtimeNow
(
EventImpl
*event);
78
Time
RealtimeNow
(
void
)
const
;
79
80
void
SetSynchronizationMode
(
RealtimeSimulatorImpl::SynchronizationMode
mode);
81
RealtimeSimulatorImpl::SynchronizationMode
GetSynchronizationMode
(
void
)
const
;
82
83
void
SetHardLimit
(
Time
limit);
84
Time
GetHardLimit
(
void
)
const
;
85
86
private
:
87
bool
Running
(
void
)
const
;
88
bool
Realtime
(
void
)
const
;
89
uint64_t
NextTs
(
void
)
const
;
90
void
ProcessOneEvent
(
void
);
91
virtual
void
DoDispose
(
void
);
92
93
typedef
std::list<EventId>
DestroyEvents
;
94
DestroyEvents
m_destroyEvents
;
95
bool
m_stop
;
96
bool
m_running
;
97
98
// The following variables are protected using the m_mutex
99
Ptr<Scheduler>
m_events
;
100
int
m_unscheduledEvents
;
101
uint32_t
m_uid
;
102
uint32_t
m_currentUid
;
103
uint64_t
m_currentTs
;
104
uint32_t
m_currentContext
;
105
106
mutable
SystemMutex
m_mutex
;
107
108
Ptr<Synchronizer>
m_synchronizer
;
109
113
SynchronizationMode
m_synchronizationMode
;
114
118
Time
m_hardLimit
;
119
120
SystemThread::ThreadId
m_main
;
121
};
122
123
}
// namespace ns3
124
125
#endif
/* REALTIME_SIMULATOR_IMPL_H */
src
core
model
realtime-simulator-impl.h
Generated on Tue Nov 13 2012 10:32:11 for ns-3 by
1.8.1.2