A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
nsclick-defines.cc
Go to the documentation of this file.
1
/*
2
* This program is free software; you can redistribute it and/or modify
3
* it under the terms of the GNU General Public License version 2 as
4
* published by the Free Software Foundation;
5
*
6
* This program is distributed in the hope that it will be useful,
7
* but WITHOUT ANY WARRANTY; without even the implied warranty of
8
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
* GNU General Public License for more details.
10
*
11
* You should have received a copy of the GNU General Public License
12
* along with this program; if not, write to the Free Software
13
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14
*
15
* Authors: Sascha Jopen <jopen@cs.uni-bonn.de>
16
*/
17
18
#include "ns3/click-internet-stack-helper.h"
19
#include "ns3/core-module.h"
20
#include "ns3/ipv4-click-routing.h"
21
22
#include <map>
23
24
using namespace
ns3
;
25
26
NS_LOG_COMPONENT_DEFINE
(
"NsclickRouting"
);
27
28
int
29
main(
int
argc,
char
* argv[])
30
{
31
#ifdef NS3_CLICK
32
std::string clickConfigFolder =
"src/click/examples"
;
33
34
CommandLine
cmd
(__FILE__);
35
cmd
.AddValue(
"clickConfigFolder"
,
36
"Base folder for click configuration files"
,
37
clickConfigFolder);
38
cmd
.Parse(argc, argv);
39
40
//
41
// Explicitly create the nodes required by the topology (shown above).
42
//
43
NS_LOG_INFO
(
"Create a node."
);
44
NodeContainer
n;
45
n.
Create
(1);
46
47
//
48
// Install Click on the nodes
49
//
50
std::map<std::string, std::string> defines;
51
// Strings, especially with blanks in it, have to be enclosed in quotation
52
// marks, like in click configuration files.
53
defines[
"OUTPUT"
] =
"\"Hello World!\""
;
54
55
ClickInternetStackHelper clickinternet;
56
clickinternet.SetClickFile(n, clickConfigFolder +
"/nsclick-defines.click"
);
57
clickinternet.SetRoutingTableElement(n,
"rt"
);
58
clickinternet.SetDefines(n, defines);
59
clickinternet.Install(n);
60
61
//
62
// Now, do the actual simulation.
63
//
64
NS_LOG_INFO
(
"Run Simulation."
);
65
Simulator::Stop
(
Seconds
(20.0));
66
Simulator::Run
();
67
Simulator::Destroy
();
68
NS_LOG_INFO
(
"Done."
);
69
#else
70
NS_FATAL_ERROR
(
"Can't use ns-3-click without NSCLICK compiled in"
);
71
#endif
72
73
return
0;
74
}
ns3::CommandLine
Parse command-line arguments.
Definition:
command-line.h:232
ns3::NodeContainer
keep track of a set of node pointers.
Definition:
node-container.h:40
ns3::NodeContainer::Create
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Definition:
node-container.cc:84
ns3::Simulator::Destroy
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
Definition:
simulator.cc:140
ns3::Simulator::Run
static void Run()
Run the simulation.
Definition:
simulator.cc:176
ns3::Simulator::Stop
static void Stop()
Tell the Simulator the calling event should be the last one executed.
Definition:
simulator.cc:184
NS_FATAL_ERROR
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition:
fatal-error.h:179
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
NS_LOG_INFO
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition:
log.h:275
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition:
nstime.h:1336
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
second.cmd
cmd
Definition:
second.py:33
src
click
examples
nsclick-defines.cc
Generated on Fri Mar 31 2023 13:30:38 for ns-3 by
1.9.1