A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
34 //
35 // Explicitly create the nodes required by the topology (shown above).
36 //
37  NS_LOG_INFO ("Create a node.");
38  NodeContainer n;
39  n.Create (1);
40 
41 //
42 // Install Click on the nodes
43 //
44  std::map<std::string, std::string> defines;
45 // Strings, especially with blanks in it, have to be enclosed in quotation
46 // marks, like in click configuration files.
47  defines["OUTPUT"] = "\"Hello World!\"";
48 
49  ClickInternetStackHelper clickinternet;
50  clickinternet.SetClickFile (n, "src/click/examples/nsclick-defines.click");
51  clickinternet.SetRoutingTableElement (n, "rt");
52  clickinternet.SetDefines(n, defines);
53  clickinternet.Install (n);
54 
55 //
56 // Now, do the actual simulation.
57 //
58  NS_LOG_INFO ("Run Simulation.");
59  Simulator::Stop (Seconds (20.0));
60  Simulator::Run ();
62  NS_LOG_INFO ("Done.");
63 #else
64  NS_FATAL_ERROR ("Can't use ns-3-click without NSCLICK compiled in");
65 #endif
66 }
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
static void Run(void)
Run the simulation until one of:
Definition: simulator.cc:157
#define NS_LOG_INFO(msg)
Definition: log.h:298
int main(int argc, char *argv[])
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
static void Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
Definition: simulator.cc:121
keep track of a set of node pointers.
static void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
Definition: simulator.cc:165
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.