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