blob: f80a81654e0e3fb365424b743bfa2fb4be62d558 [file] [log] [blame]
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -08001/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011-2012 University of California, Los Angeles
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 * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
19 */
20// ndn-congestion-topo-plugin.cc
21#include "ns3/core-module.h"
22#include "ns3/network-module.h"
23#include "ns3/ndnSIM-module.h"
24
25using namespace ns3;
26
27/**
28 * This scenario simulates a grid topology (using topology reader module)
29 *
30 * /------\ /------\
31 * | Src1 |<--+ +-->| Dst1 |
32 * \------/ \ / \------/
33 * \ /
34 * +-->/------\ "bottleneck" /------\<-+
35 * | Rtr1 |<===============>| Rtr2 |
36 * +-->\------/ \------/<-+
37 * / \
38 * /------\ / \ /------\
39 * | Src2 |<--+ +-->| Dst2 |
40 * \------/ \------/
41 *
42 * To run scenario and see what is happening, use the following command:
43 *
44 * NS_LOG=ndn.Consumer:ndn.Producer ./waf --run=ndn-congestion-topo-plugin
45 */
46
47int
48main (int argc, char *argv[])
49{
50 CommandLine cmd;
51 cmd.Parse (argc, argv);
52
53 AnnotatedTopologyReader topologyReader ("", 25);
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080054 topologyReader.SetFileName ("src/ndnSIM/examples/topologies/topo-6-node.txt");
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -080055 topologyReader.Read ();
56
57 // Install CCNx stack on all nodes
58 ndn::StackHelper ccnxHelper;
Alexander Afanasyeve095f0f2012-11-21 17:43:32 -080059 ccnxHelper.SetForwardingStrategy ("ns3::ndn::fw::BestRoute");
60 ccnxHelper.SetContentStore ("ns3::ndn::cs::Lru",
61 "MaxSize", "10000");
Alexander Afanasyevaa1c4c32012-11-21 16:17:03 -080062 ccnxHelper.InstallAll ();
63
64 // Installing global routing interface on all nodes
65 ndn::GlobalRoutingHelper ccnxGlobalRoutingHelper;
66 ccnxGlobalRoutingHelper.InstallAll ();
67
68 // Getting containers for the consumer/producer
69 Ptr<Node> consumer1 = Names::Find<Node> ("Src1");
70 Ptr<Node> consumer2 = Names::Find<Node> ("Src2");
71
72 Ptr<Node> producer1 = Names::Find<Node> ("Dst1");
73 Ptr<Node> producer2 = Names::Find<Node> ("Dst2");
74
75 ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
76 consumerHelper.SetAttribute ("Frequency", StringValue ("100")); // 100 interests a second
77
78 // on the first consumer node install a Consumer application
79 // that will express interests in /dst1 namespace
80 consumerHelper.SetPrefix ("/dst1");
81 consumerHelper.Install (consumer1);
82
83 // on the second consumer node install a Consumer application
84 // that will express interests in /dst2 namespace
85 consumerHelper.SetPrefix ("/dst2");
86 consumerHelper.Install (consumer2);
87
88 ndn::AppHelper producerHelper ("ns3::ndn::Producer");
89 producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
90
91 // Register /dst1 prefix with global routing controller and
92 // install producer that will satisfy Interests in /dst1 namespace
93 ccnxGlobalRoutingHelper.AddOrigins ("/dst1", producer1);
94 producerHelper.SetPrefix ("/dst1");
95 producerHelper.Install (producer1);
96
97 // Register /dst2 prefix with global routing controller and
98 // install producer that will satisfy Interests in /dst2 namespace
99 ccnxGlobalRoutingHelper.AddOrigins ("/dst2", producer2);
100 producerHelper.SetPrefix ("/dst2");
101 producerHelper.Install (producer2);
102
103 // Calculate and install FIBs
104 ccnxGlobalRoutingHelper.CalculateRoutes ();
105
106 Simulator::Stop (Seconds (20.0));
107
108 Simulator::Run ();
109 Simulator::Destroy ();
110
111 return 0;
112}