Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2016 Fraunhofer ESK
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author:Karsten Roscher <karsten.roscher@esk.fraunhofer.de>
*/
#ifndef TRACI_NODE_LIFECYCLE_H
#define TRACI_NODE_LIFECYCLE_H
#include <map>
#include <string>
#include "ns3/ptr.h"
#include "ns3/node.h"
#include "ns3/event-id.h"
#include "ns3/random-variable-stream.h"
#include "traci-node-manager.h"
namespace ns3
{
class TraCiNodeLifecyclePolicy
{
public:
/*!
* @brief Create policy.
*/
TraCiNodeLifecyclePolicy ();
/*!
* @brief Destructor of the policy.
*/
virtual ~TraCiNodeLifecyclePolicy ();
/**
* @brief Set random startup delay.
*
* @param rand Pointer to a random variable stream.
*/
void
SetRandomActivationDelay (Ptr<RandomVariableStream> rand);
/**
* @brief Set the earliest activation time.
*
* Nodes won't be started before this time. If a random activation
* delay is set, it will be added to this time to avoid synchronized
* start at that time.
*
* @param startTime Earliest start time for nodes
*/
void
SetEarliestActivationTime (Time startTime);
/*!
* @brief Handle node activation via TraCI
* @param node Node to activate
* @param vehicle Vehicle instance assigned
*/
void
HandleActivateNode (Ptr<Node> node, Ptr<traci::Vehicle> vehicle);
/*!
* @brief Handle node shutdown via TraCI.
* @param node Node to deactivate
*/
void
HandleShutdownNode (Ptr<Node> node);
private:
/*!
* @brief Handle delayed activation of a node.
* @param node Node to activate.
*/
void
HandleDelayedActivation (Ptr<Node> node);
/**
* Pointer to a random variable stream modeling a random delay
* before the node is activated from a life cycle perspective.
* for an ezC2X stack installation.
*/
Ptr<RandomVariableStream>
m_randomDelay;
//! Map of nodes waiting for activation
typedef std::map<Ptr<Node>, EventId> ActivationMap;
//! Nodes waiting for activation.
ActivationMap m_waitingNodes;
//! Earliest activation time.
Time m_earliestActivationTime;
};
/*!
* @brief Node manager controlling the node life cycle (via NodeLifecycleManager).
*/
typedef TraCiNodeManager<TraCiNodeLifecyclePolicy> TraCiNodeLifecycleManager;
} // namespace ns3
#endif /* TRACI_NODE_LIFECYCLE_H */