├── RELEASE_NOTES.rst ├── bindings ├── callbacks_list.py ├── module-helpers.cpp └── module-helpers.hpp ├── docs ├── .gitignore ├── source │ ├── meta │ │ └── authors.rst │ ├── _static │ │ ├── root-rates.png │ │ ├── l2-rate-tracer.png │ │ ├── ndnSIM-structure.pdf │ │ ├── ndnSIM-structure.png │ │ ├── topo-tree-25-node.png │ │ ├── nfd-forwarding-overview.pdf │ │ ├── nfd-forwarding-overview.png │ │ └── apps │ │ │ ├── zipf-n100-frq100-duration10.png │ │ │ ├── zipf-n100-frq100-duration50.png │ │ │ ├── zipf-n100-frq100-duration100.png │ │ │ └── zipf-n100-frq100-duration1000.png │ ├── community-contributions.rst │ ├── tutorial.rst │ └── cs.rst ├── ns3_html_theme │ ├── static │ │ ├── bc_s.png │ │ ├── nav_f.png │ │ ├── tab_b.png │ │ ├── bar-top.png │ │ ├── favicon.ico │ │ ├── irl-logo.png │ │ ├── ndn-logo.png │ │ ├── ns-3-small.png │ │ ├── ns-3-inverted-notext-small.png │ │ └── ns3_stylesheet.css │ ├── ns3_doxy_footer.html │ ├── theme.conf │ ├── ns3_doxy_header.html │ ├── layout.html │ └── README.rst ├── analytics.html ├── doxygen.hpp └── redmine_issue.py ├── .gitignore ├── examples ├── README.md ├── wscript ├── graphs │ ├── drop-graph.R │ └── rate-graph.R ├── topologies │ ├── topo-6-node.txt │ ├── topo-tree.txt │ ├── topo-grid.txt │ ├── topo-abilene.txt │ ├── topo-load-balancer.txt │ ├── topo-tree-25-node.txt │ ├── topo-grid-3x3.txt │ ├── topo-grid-3x3-loss.txt │ ├── topo-11-node-two-bottlenecks.txt │ └── topo-grid-3x3-red-queues.txt ├── ndn-custom-apps │ ├── hijacker.hpp │ ├── hijacker.cpp │ └── custom-app.hpp ├── ndn-cxx-simple.cpp ├── ndn-simple-with-content-freshness │ ├── one-interest-requester.hpp │ └── one-interest-requester.cpp ├── ndn-custom-apps.cpp ├── ndn-cxx-simple │ ├── real-app-starter.hpp │ └── real-app.hpp ├── ndn-load-balancer │ └── random-load-balancer-strategy.hpp ├── ndn-simple.py └── ndn-simple-for-nrt-helper │ └── requester-app.cpp ├── .jenkins ├── .gitmodules ├── .jenkins.d ├── 20-tests.sh ├── 00-prepare.sh ├── util.sh ├── 10-build.sh ├── README.md └── 01-deps.sh ├── .waf-tools ├── compiler-features.py ├── dependency-checker.py ├── type_traits.py ├── version.py └── sphinx_build.py ├── tests ├── unit-tests │ ├── README.md │ ├── tests-common.hpp │ ├── helper │ │ ├── ndn-stack-helper.t.cpp │ │ └── ndn-fib-helper.t.cpp │ └── NFD │ │ └── ncc.t.cpp ├── wscript ├── main.cpp ├── boost-test.hpp └── other │ └── ndn-test.sh ├── .clang-format ├── model ├── ndn-common.cpp ├── ndn-block-header.hpp ├── null-transport.hpp ├── ndn-app-link-service.hpp ├── ndn-global-router.cpp ├── ndn-common.hpp ├── ndn-app-link-service.cpp └── ndn-net-device-transport.hpp ├── README.md ├── utils ├── ndn-ns3-packet-tag.hpp ├── batches.cpp ├── ndn-time.hpp ├── tracers │ ├── l2-tracer.cpp │ ├── l2-tracer.hpp │ ├── ndn-l3-tracer.cpp │ └── l2-rate-tracer.hpp ├── ndn-time.cpp ├── batches.hpp ├── ndn-rtt-mean-deviation.hpp ├── mem-usage.hpp └── topology │ └── rocketfuel-weights-reader.hpp ├── helper ├── lfid │ ├── remove-loops.hpp │ └── fib-nexthop.cpp ├── ndn-network-region-table-helper.hpp ├── ndn-strategy-choice-helper.cpp └── ndn-link-control-helper.hpp ├── apps ├── ndn-consumer-batches.hpp ├── ndn-producer.hpp ├── ndn-consumer-cbr.hpp ├── ndn-consumer-window.hpp ├── ndn-consumer-zipf-mandelbrot.hpp ├── ndn-consumer-batches.cpp └── ndn-consumer-pcon.hpp ├── ndn-all.hpp ├── .travis.yml └── AUTHORS.rst /RELEASE_NOTES.rst: -------------------------------------------------------------------------------- 1 | docs/source/RELEASE_NOTES.rst -------------------------------------------------------------------------------- /bindings/callbacks_list.py: -------------------------------------------------------------------------------- 1 | callback_classes = [ 2 | ] 3 | -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | doxygen/ 3 | introspected-doxygen.h 4 | ndnSIM.tag 5 | 6 | -------------------------------------------------------------------------------- /docs/source/meta/authors.rst: -------------------------------------------------------------------------------- 1 | ndnSIM Team 2 | =========== 3 | 4 | .. include:: ../../../AUTHORS.rst 5 | -------------------------------------------------------------------------------- /docs/source/_static/root-rates.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/source/_static/root-rates.png -------------------------------------------------------------------------------- /docs/ns3_html_theme/static/bc_s.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/ns3_html_theme/static/bc_s.png -------------------------------------------------------------------------------- /docs/ns3_html_theme/static/nav_f.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/ns3_html_theme/static/nav_f.png -------------------------------------------------------------------------------- /docs/ns3_html_theme/static/tab_b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/ns3_html_theme/static/tab_b.png -------------------------------------------------------------------------------- /docs/ns3_html_theme/static/bar-top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/ns3_html_theme/static/bar-top.png -------------------------------------------------------------------------------- /docs/ns3_html_theme/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/ns3_html_theme/static/favicon.ico -------------------------------------------------------------------------------- /docs/ns3_html_theme/static/irl-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/ns3_html_theme/static/irl-logo.png -------------------------------------------------------------------------------- /docs/ns3_html_theme/static/ndn-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/ns3_html_theme/static/ndn-logo.png -------------------------------------------------------------------------------- /docs/source/_static/l2-rate-tracer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/source/_static/l2-rate-tracer.png -------------------------------------------------------------------------------- /docs/ns3_html_theme/static/ns-3-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/ns3_html_theme/static/ns-3-small.png -------------------------------------------------------------------------------- /docs/source/_static/ndnSIM-structure.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/source/_static/ndnSIM-structure.pdf -------------------------------------------------------------------------------- /docs/source/_static/ndnSIM-structure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/source/_static/ndnSIM-structure.png -------------------------------------------------------------------------------- /docs/source/_static/topo-tree-25-node.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/source/_static/topo-tree-25-node.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | .waf3-* 3 | .waf-1* 4 | *~ 5 | .DS_Store 6 | docs/doxygen.warnings.log 7 | docs/introspected-doxygen.hpp 8 | docs/ndnSIM.tag 9 | -------------------------------------------------------------------------------- /docs/source/_static/nfd-forwarding-overview.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/source/_static/nfd-forwarding-overview.pdf -------------------------------------------------------------------------------- /docs/source/_static/nfd-forwarding-overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/source/_static/nfd-forwarding-overview.png -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | Please refer to http://ndnsim.net/examples.html (../docs/source/examples.rst) 2 | for detailed information about the examples. 3 | 4 | -------------------------------------------------------------------------------- /docs/source/_static/apps/zipf-n100-frq100-duration10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/source/_static/apps/zipf-n100-frq100-duration10.png -------------------------------------------------------------------------------- /docs/source/_static/apps/zipf-n100-frq100-duration50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/source/_static/apps/zipf-n100-frq100-duration50.png -------------------------------------------------------------------------------- /docs/ns3_html_theme/static/ns-3-inverted-notext-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/ns3_html_theme/static/ns-3-inverted-notext-small.png -------------------------------------------------------------------------------- /docs/source/_static/apps/zipf-n100-frq100-duration100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/source/_static/apps/zipf-n100-frq100-duration100.png -------------------------------------------------------------------------------- /docs/source/_static/apps/zipf-n100-frq100-duration1000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/named-data-ndnSIM/ndnSIM/HEAD/docs/source/_static/apps/zipf-n100-frq100-duration1000.png -------------------------------------------------------------------------------- /.jenkins: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 5 | 6 | for file in "$DIR"/.jenkins.d/*; do 7 | [[ -f $file && -x $file ]] || continue 8 | echo "Run: $file" 9 | "$file" 10 | done 11 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "NFD"] 2 | path = NFD 3 | url = https://github.com/named-data-ndnSIM/NFD 4 | branch = NFD-0.7.0-ndnSIM 5 | [submodule "ndn-cxx"] 6 | path = ndn-cxx 7 | url = https://github.com/named-data-ndnSIM/ndn-cxx 8 | branch = ndn-cxx-0.7.0-ndnSIM 9 | -------------------------------------------------------------------------------- /.jenkins.d/20-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 5 | source "$JDIR"/util.sh 6 | 7 | set -x 8 | 9 | pushd ns-3 >/dev/null 10 | 11 | export BOOST_TEST_BUILD_INFO=1 12 | export BOOST_TEST_COLOR_OUTPUT=1 13 | export BOOST_TEST_DETECT_MEMORY_LEAK=0 14 | export BOOST_TEST_LOGGER=HRF,test_suite,stdout:XML,all,build/xunit-log.xml 15 | 16 | # Run unit tests 17 | ./waf --run "ndnSIM-unit-tests" 18 | 19 | popd >/dev/null 20 | -------------------------------------------------------------------------------- /.jenkins.d/00-prepare.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | set -x 4 | 5 | git rm -qrf . 6 | git clone --depth=1 https://github.com/named-data-ndnSIM/ns-3-dev ns-3 7 | git clone https://github.com/named-data-ndnSIM/pybindgen.git pybindgen 8 | mkdir -p ns-3/src/ndnSIM 9 | mv .git ns-3/src/ndnSIM/ 10 | (cd ns-3/src/ndnSIM/ && git reset -q && git checkout . && git submodule update --init) 11 | 12 | mv ns-3/src/ndnSIM/.jenkins.d . # move CI scripts back, so the rest of them can be executed 13 | -------------------------------------------------------------------------------- /.waf-tools/compiler-features.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | 3 | from waflib.Configure import conf 4 | 5 | OVERRIDE = ''' 6 | class Base 7 | { 8 | virtual void 9 | f(int a); 10 | }; 11 | 12 | class Derived : public Base 13 | { 14 | virtual void 15 | f(int a) override; 16 | }; 17 | ''' 18 | 19 | @conf 20 | def check_override(self): 21 | if self.check_cxx(msg='Checking for override specifier', 22 | fragment=OVERRIDE, 23 | features='cxx', mandatory=False): 24 | self.define('HAVE_CXX_OVERRIDE', 1) 25 | 26 | def configure(conf): 27 | conf.check_override() 28 | -------------------------------------------------------------------------------- /examples/wscript: -------------------------------------------------------------------------------- 1 | ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | 3 | from waflib import Utils, Logs 4 | 5 | def build(bld): 6 | # This may be necessary for visualizer to work 7 | all_modules = [mod[len("ns3-"):] for mod in bld.env['NS3_ENABLED_MODULES']] 8 | 9 | examples = bld.path.ant_glob(['*.cpp'], excl=['*-mpi.cpp']) 10 | if 'NS3_MPI' in bld.env['DEFINES_MPI']: 11 | examples += bld.path.ant_glob(['*-mpi.cpp']) 12 | 13 | for i in examples: 14 | name = i.change_ext('').path_from(bld.path.get_bld()) 15 | obj = bld.create_ns3_program(name, all_modules) 16 | obj.source = [i] + bld.path.ant_glob(['%s/**/*.cpp' % name]) 17 | 18 | -------------------------------------------------------------------------------- /docs/analytics.html: -------------------------------------------------------------------------------- 1 |
2 | ndnSIM: NS-3 based NDN simulator API Reference - Generated using Doxygen $doxygenversion 3 |
4 | 5 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.jenkins.d/util.sh: -------------------------------------------------------------------------------- 1 | has() { 2 | local saved_xtrace 3 | [[ $- == *x* ]] && saved_xtrace=-x || saved_xtrace=+x 4 | set +x 5 | 6 | local p=$1 7 | shift 8 | local i ret=1 9 | for i in "$@"; do 10 | if [[ "${i}" == "${p}" ]]; then 11 | ret=0 12 | break 13 | fi 14 | done 15 | 16 | set ${saved_xtrace} 17 | return ${ret} 18 | } 19 | 20 | sudo_preserve_env() { 21 | local saved_xtrace 22 | [[ $- == *x* ]] && saved_xtrace=-x || saved_xtrace=+x 23 | set +x 24 | 25 | local vars=() 26 | while [[ $# -gt 0 ]]; do 27 | local arg=$1 28 | shift 29 | case ${arg} in 30 | --) break ;; 31 | *) vars+=("${arg}=${!arg}") ;; 32 | esac 33 | done 34 | 35 | set ${saved_xtrace} 36 | sudo env "${vars[@]}" "$@" 37 | } 38 | -------------------------------------------------------------------------------- /tests/unit-tests/README.md: -------------------------------------------------------------------------------- 1 | ndnSIM unit tests 2 | ================= 3 | 4 | ndnSIM uses [Boost Unit Test Framework](http://www.boost.org/doc/libs/1_48_0/libs/test/doc/html/index.html) 5 | for testing features of the implementation. 6 | 7 | ndnSIM unit tests should be placed into `ndnSIM/tests/unit-tests/` folder. All `.cpp` files placed 8 | in this folder will be automatically compiled together. 9 | 10 | Running unit-tests 11 | ------------------ 12 | 13 | To run unit tests, NS-3 and ndnSIM need to be configured and build with the unit test support. To 14 | enable both general NS-3 unit tests and ndnSIM unit tests, add `--enable-tests` during configuration 15 | phase. For example, run the following from the NS-3 root folder: 16 | 17 | ./waf configure --enable-tests 18 | ./waf build 19 | 20 | To run unit tests: 21 | 22 | ./waf --run ndnSIM-unit-tests 23 | -------------------------------------------------------------------------------- /examples/graphs/drop-graph.R: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env Rscript 2 | # Copyright (c) 2012-2015 Alexander Afanasyev 3 | 4 | 5 | # install.packages ('ggplot2') 6 | library(ggplot2) 7 | ## # install.packages ('scales') 8 | ## library (scales) 9 | 10 | ######################### 11 | # Rate trace processing # 12 | ######################### 13 | data = read.table("drop-trace.txt", header=T) 14 | data$Node = factor(data$Node) 15 | data$Kilobits <- data$Kilobytes * 8 16 | data$Type = factor(data$Type) 17 | 18 | ## data.rtr = data[grep("Rtr", data$Node),] 19 | 20 | # graph rates on all nodes in Kilobits 21 | g.all <- ggplot(data, aes(x=Time, y=Kilobits, color=Type)) + 22 | geom_point(size=2) + 23 | geom_line() + 24 | ylab("Packet drop rate [Kbits/s]") + 25 | facet_wrap(~ Node) + 26 | theme_bw() 27 | 28 | png("src/ndnSIM/docs/source/_static/l2-rate-tracer.png", width=800, height=500) 29 | print(g.all) 30 | x = dev.off() 31 | -------------------------------------------------------------------------------- /tests/wscript: -------------------------------------------------------------------------------- 1 | ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | 3 | def build(bld): 4 | # To allow tests to use features from all enabled modules 5 | all_modules = [mod[len("ns3-"):] for mod in bld.env['NS3_ENABLED_MODULES']] 6 | 7 | # Unit tests 8 | tests = bld.create_ns3_program('ndnSIM-unit-tests', all_modules) 9 | tests.source = bld.path.ant_glob(['main.cpp', 'unit-tests/**/*.cpp']) 10 | tests.includes = ['#', '.', '../NFD/', "../NFD/daemon", "../NFD/core", "../helper", "../model", "../apps", "../utils", "../examples"] 11 | tests.defines = 'TEST_CONFIG_PATH=\"%s/conf-test\"' %(bld.bldnode) 12 | 13 | # Other tests 14 | for i in bld.path.ant_glob(['other/*.cpp']): 15 | name = str(i)[:-len(".cpp")] 16 | obj = bld.create_ns3_program(name, all_modules) 17 | obj.source = [i] + bld.path.ant_glob(['%s/**/*.cpp' % name]) 18 | obj.install_path = None 19 | -------------------------------------------------------------------------------- /.jenkins.d/10-build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 5 | source "$JDIR"/util.sh 6 | 7 | set -x 8 | 9 | pushd ns-3 >/dev/null 10 | 11 | git submodule update --init 12 | 13 | # Cleanup 14 | sudo rm -Rf build/ .waf-1* .waf3-1* 15 | find . -name '*.pyc' | sudo xargs rm -f 16 | 17 | if has OSX $NODE_LABELS; then 18 | export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/libxml2/lib/pkgconfig" 19 | if [[ -n $USE_OPENSSL_1_1 ]]; then 20 | OPENSSL="--with-openssl=/usr/local/opt/openssl@1.1" 21 | fi 22 | fi 23 | 24 | ./waf -j${WAF_JOBS:-1} configure -d debug --enable-examples --enable-tests $OPENSSL 25 | ./waf -j${WAF_JOBS:-1} build 26 | 27 | # Install 28 | sudo_preserve_env PATH -- ./waf -j${WAF_JOBS:-1} install 29 | 30 | if has Linux $NODE_LABELS; then 31 | sudo ldconfig 32 | elif has FreeBSD $NODE_LABELS; then 33 | sudo ldconfig -a 34 | fi 35 | 36 | popd >/dev/null 37 | -------------------------------------------------------------------------------- /tests/main.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #define BOOST_TEST_MAIN 1 21 | #define BOOST_TEST_DYN_LINK 1 22 | 23 | #include "boost-test.hpp" 24 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | # This style requires customized clang-format from https://github.com/cawka/clang 2 | # 3 | BasedOnStyle: GNU 4 | --- 5 | Language: Cpp 6 | AlwaysBreakAfterDefinitionReturnType: true 7 | AlwaysBreakAfterDeclarationReturnType: true 8 | ColumnLimit: 100 9 | SpaceBeforeParens: ControlStatements 10 | Cpp11BracedListStyle: true 11 | BreakBeforeBraces: Stroustrup 12 | PointerAlignment: Left 13 | PenaltyReturnTypeOnItsOwnLine: 0 14 | AllowShortBlocksOnASingleLine: false 15 | # AllowShortCaseLabelsOnASingleLine: false 16 | AllowShortFunctionsOnASingleLine: false 17 | AllowShortIfStatementsOnASingleLine: false 18 | AllowShortLoopsOnASingleLine: false 19 | 20 | BreakConstructorInitializersBeforeComma: true 21 | NamespaceIndentation: None 22 | Standard: Cpp11 23 | 24 | AlwaysBreakTemplateDeclarations: true 25 | IndentWidth: 2 26 | PenaltyBreakBeforeFirstCallParameter: 500 27 | SpacesBeforeTrailingComments: 1 28 | UseTab: Never 29 | ConstructorInitializerIndentWidth: 2 30 | 31 | SpaceBetweenTemplateAndOpeningAngle: false 32 | BreakBeforeBinaryOperators: NonAssignment 33 | ContinuationIndentWidth: 2 -------------------------------------------------------------------------------- /model/ndn-common.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "ndn-common.hpp" 21 | 22 | namespace ns3 { 23 | namespace ndn { 24 | 25 | ATTRIBUTE_HELPER_CPP(Name); 26 | 27 | } // namespace ndn 28 | } // namespace ns3 29 | -------------------------------------------------------------------------------- /.waf-tools/dependency-checker.py: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | from waflib import Options, Logs 4 | from waflib.Configure import conf 5 | 6 | def addDependencyOptions(self, opt, name, extraHelp=''): 7 | opt.add_option('--with-%s' % name, type='string', default=None, 8 | dest='with_%s' % name, 9 | help='Path to %s, e.g., /usr/local %s' % (name, extraHelp)) 10 | setattr(Options.OptionsContext, "addDependencyOptions", addDependencyOptions) 11 | 12 | @conf 13 | def checkDependency(self, name, **kw): 14 | root = kw.get('path', getattr(Options.options, 'with_%s' % name)) 15 | kw['msg'] = kw.get('msg', 'Checking for %s library' % name) 16 | kw['uselib_store'] = kw.get('uselib_store', name.upper()) 17 | kw['define_name'] = kw.get('define_name', 'HAVE_%s' % kw['uselib_store']) 18 | kw['mandatory'] = kw.get('mandatory', True) 19 | 20 | if root: 21 | isOk = self.check_cxx(includes="%s/include" % root, 22 | libpath="%s/lib" % root, 23 | **kw) 24 | else: 25 | isOk = self.check_cxx(**kw) 26 | 27 | if isOk: 28 | self.env[kw['define_name']] = True 29 | -------------------------------------------------------------------------------- /.waf-tools/type_traits.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | # 3 | # Copyright (c) 2014, Regents of the University of California 4 | # 5 | # GPL 3.0 license, see the COPYING.md file for more information 6 | 7 | from waflib import Configure 8 | 9 | IS_DEFAULT_CONSTRUCTIBLE_CHECK = ''' 10 | #include 11 | static_assert(std::is_default_constructible::value, ""); 12 | ''' 13 | 14 | IS_MOVE_CONSTRUCTIBLE_CHECK = ''' 15 | #include 16 | static_assert(std::is_move_constructible::value, ""); 17 | ''' 18 | 19 | def configure(conf): 20 | if conf.check_cxx(msg='Checking for std::is_default_constructible', 21 | fragment=IS_DEFAULT_CONSTRUCTIBLE_CHECK, 22 | features='cxx', mandatory=False): 23 | conf.define('HAVE_IS_DEFAULT_CONSTRUCTIBLE', 1) 24 | conf.env['HAVE_IS_DEFAULT_CONSTRUCTIBLE'] = True 25 | 26 | if conf.check_cxx(msg='Checking for std::is_move_constructible', 27 | fragment=IS_MOVE_CONSTRUCTIBLE_CHECK, 28 | features='cxx', mandatory=False): 29 | conf.define('HAVE_IS_MOVE_CONSTRUCTIBLE', 1) 30 | conf.env['HAVE_IS_MOVE_CONSTRUCTIBLE'] = True 31 | -------------------------------------------------------------------------------- /.jenkins.d/README.md: -------------------------------------------------------------------------------- 1 | CONTINUOUS INTEGRATION SCRIPTS 2 | ============================== 3 | 4 | Environment Variables Used in Build Scripts 5 | ------------------------------------------- 6 | 7 | - `NODE_LABELS`: the variable defines a list of OS properties. The set values are used by the 8 | build scripts to select proper behavior for different OS. 9 | 10 | The list should include at least `[OS_TYPE]`, `[DISTRO_TYPE]`, and `[DISTRO_VERSION]`. 11 | 12 | Possible values for Linux: 13 | 14 | * `[OS_TYPE]`: `Linux` 15 | * `[DISTRO_TYPE]`: `Ubuntu` 16 | * `[DISTRO_VERSION]`: `Ubuntu-16.04`, `Ubuntu-18.04` 17 | 18 | Possible values for macOS: 19 | 20 | * `[OS_TYPE]`: `OSX` 21 | * `[DISTRO_TYPE]`: `OSX` (can be absent) 22 | * `[DISTRO_VERSION]`: `OSX-10.12`, `OSX-10.13`, `OSX-10.14` 23 | 24 | - `JOB_NAME`: optional variable to define type of the job. Depending on the defined job type, 25 | the build scripts can perform different tasks. 26 | 27 | Possible values: 28 | 29 | * empty: default build process 30 | * `code-coverage` (Ubuntu Linux is assumed): debug build with tests and code coverage analysis 31 | * `limited-build`: only a single debug build with tests 32 | 33 | - `WAF_JOBS`: number of parallel build jobs used by waf, defaults to 1. 34 | -------------------------------------------------------------------------------- /bindings/module-helpers.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2016 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "module-helpers.hpp" 21 | 22 | namespace nfd { 23 | namespace fib { 24 | 25 | std::shared_ptr 26 | getFaceFromFibNextHop(const NextHop& nextHop) 27 | { 28 | return nextHop.getFace().shared_from_this(); 29 | } 30 | 31 | } // namespace fib 32 | } // namespace nfd 33 | -------------------------------------------------------------------------------- /docs/ns3_html_theme/ns3_doxy_footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 18 | 19 | 20 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ndnSIM 2 | ====== 3 | 4 | [![Build Status](https://travis-ci.org/named-data-ndnSIM/ndnSIM.svg)](https://travis-ci.org/named-data-ndnSIM/ndnSIM) 5 | 6 | A new release of [NS-3 based Named Data Networking (NDN) simulator](http://ndnsim.net/) 7 | went through extensive refactoring and rewriting. The key new features of the new 8 | version: 9 | 10 | - [NDN Packet Specification](http://named-data.net/doc/NDN-packet-spec/current/) 11 | 12 | - ndnSIM uses implementation of basic NDN primitives from 13 | [ndn-cxx library (NDN C++ library with eXperimental eXtensions)](http://named-data.net/doc/ndn-cxx/) 14 | 15 | Based on version `0.7.0` 16 | 17 | - All NDN forwarding and management is implemented directly using source code of 18 | [Named Data Networking Forwarding Daemon (NFD)](http://named-data.net/doc/NFD/) 19 | 20 | Based on version `0.7.0` 21 | 22 | - Allows [simulation of real applications](http://ndnsim.net/guide-to-simulate-real-apps.html) 23 | written against ndn-cxx library 24 | 25 | - Requires a modified version of NS-3 based on version `ns-3.30.1` 26 | 27 | [ndnSIM documentation](http://ndnsim.net) 28 | --------------------------------------------- 29 | 30 | For more information, including downloading and compilation instruction, please refer to 31 | http://ndnsim.net or documentation in `docs/` folder. 32 | -------------------------------------------------------------------------------- /tests/boost-test.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDN_TESTS_BOOST_TEST_HPP 21 | #define NDN_TESTS_BOOST_TEST_HPP 22 | 23 | // suppress warnings from Boost.Test 24 | #pragma GCC system_header 25 | #pragma clang system_header 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | #endif // NDN_TESTS_BOOST_TEST_HPP 32 | -------------------------------------------------------------------------------- /bindings/module-helpers.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2016 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDNSIM_BINDINGS_MODULE_HELPERS_HPP 21 | #define NDNSIM_BINDINGS_MODULE_HELPERS_HPP 22 | 23 | #include 24 | 25 | namespace nfd { 26 | namespace fib { 27 | 28 | std::shared_ptr 29 | getFaceFromFibNextHop(const NextHop& nextHop); 30 | 31 | } // namespace fib 32 | } // namespace nfd 33 | 34 | #endif // NDNSIM_BINDINGS_MODULE_HELPERS_HPP 35 | -------------------------------------------------------------------------------- /examples/topologies/topo-6-node.txt: -------------------------------------------------------------------------------- 1 | # topo-6-node.txt 2 | 3 | # /------\ /------\ 4 | # | Src1 |<--+ +-->| Dst1 | 5 | # \------/ \ / \------/ 6 | # \ / 7 | # +-->/------\ "bottleneck" /------\<-+ 8 | # | Rtr1 |<===============>| Rtr2 | 9 | # +-->\------/ \------/<-+ 10 | # / \ 11 | # /------\ / \ /------\ 12 | # | Src2 |<--+ +-->| Dst2 | 13 | # \------/ \------/ 14 | 15 | router 16 | 17 | # node comment yPos xPos 18 | Src1 NA 1 3 19 | Src2 NA 3 3 20 | Rtr1 NA 2 5 21 | Rtr2 NA 2 7 22 | Dst1 NA 1 9 23 | Dst2 NA 3 9 24 | 25 | link 26 | 27 | # srcNode dstNode bandwidth metric delay queue 28 | Src1 Rtr1 10Mbps 1 10ms 20 29 | Src2 Rtr1 10Mbps 1 10ms 20 30 | Rtr1 Rtr2 1Mbps 1 10ms 20 31 | Dst1 Rtr2 10Mbps 1 10ms 20 32 | Dst2 Rtr2 10Mbps 1 10ms 20 33 | 34 | -------------------------------------------------------------------------------- /docs/ns3_html_theme/theme.conf: -------------------------------------------------------------------------------- 1 | [theme] 2 | inherit = basic 3 | stylesheet = default.css 4 | pygments_style = sphinx 5 | 6 | [options] 7 | projectname = ndnSIM 8 | homepage = http://ndnsim.net/ 9 | homepage2 = http://irl.cs.ucla.edu/ 10 | apidocs = ndnSIM API 11 | apidocsurl = http://ndnSIM.net/doxygen/annotated.html 12 | customstylesheet = ns3_stylesheet.css 13 | logo = ndn-logo.png 14 | logo2 = irl-logo.png 15 | # logo = ns-3-inverted-notext-small.png 16 | logoalt = ns-3 Logo 17 | projectbrief = NS-3 based Named Data Networking (NDN) simulator 18 | projectnumber = ndnSIM: simulation of NDN, ICN, Information-Centric Networking 19 | 20 | favicon = favicon.ico 21 | docstitle = Documentation 22 | 23 | rightsidebar = false 24 | stickysidebar = false 25 | collapsiblesidebar = true 26 | externalrefs = true 27 | 28 | bgcolor = white 29 | textcolor = black 30 | linkcolor = #91A501 31 | visitedlinkcolor = #91A501 32 | 33 | headbgcolor = #E3E3E3 34 | headtextcolor = #373737 35 | headlinkcolor = #91A501 36 | 37 | relbarbgcolor = #D5D5D5 38 | relbarlinkcolor = #373737 39 | relbartextcolor = #373737 40 | 41 | sidebarbgcolor = #FAFAFA 42 | sidebartextcolor = #373737 43 | sidebarlinkcolor = #91A501 44 | sidebarbtncolor = #D5D5D5 45 | 46 | footerbgcolor = #D5D5D5 47 | footertextcolor = #364D7C 48 | 49 | codebgcolor = ##FBFCFD 50 | codetextcolor = black 51 | 52 | bodyfont = 'Lucida Grande', Verdana, Geneva, Arial, sans-serif 53 | headfont = 'Lucida Grande', Verdana, Geneva, Arial, sans-serif 54 | 55 | -------------------------------------------------------------------------------- /examples/topologies/topo-tree.txt: -------------------------------------------------------------------------------- 1 | # topo-tree.txt 2 | 3 | # /------\ /------\ /------\ /------\ 4 | # |leaf-1| |leaf-2| |leaf-3| |leaf-4| 5 | # \------/ \------/ \------/ \------/ 6 | # ^ ^ ^ ^ 7 | # | | | | 8 | # \ / \ / 9 | # \ / \ / 10Mbps / 1ms 10 | # \ / \ / 11 | # | | | | 12 | # v v v v 13 | # /-------\ /-------\ 14 | # | rtr-1 | | rtr-2 | 15 | # \-------/ \-------/ 16 | # ^ ^ 17 | # | | 18 | # \ / 10 Mpbs / 1ms 19 | # +--------+ +--------+ 20 | # | | 21 | # v v 22 | # /--------\ 23 | # | root | 24 | # \--------/ 25 | # 26 | 27 | router 28 | 29 | #node city y x mpi-partition 30 | leaf-1 NA 80 40 1 31 | leaf-2 NA 80 20 3 32 | leaf-3 NA 80 0 2 33 | leaf-4 NA 80 -20 4 34 | rtr-1 NA 60 20 1 35 | rtr-2 NA 60 0 2 36 | root NA 40 10 0 37 | 38 | link 39 | 40 | # from to capacity metric delay queue 41 | leaf-1 rtr-1 10Mbps 1 1ms 100 42 | leaf-2 rtr-1 10Mbps 1 1ms 100 43 | leaf-3 rtr-2 10Mbps 1 1ms 100 44 | leaf-4 rtr-2 10Mbps 1 1ms 100 45 | rtr-1 root 10Mbps 1 1ms 100 46 | rtr-2 root 10Mbps 1 1ms 100 47 | -------------------------------------------------------------------------------- /docs/doxygen.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | /** 21 | * \mainpage ndnSIM documentation 22 | * 23 | * Please refer to ndnSIM documentation page 24 | */ 25 | 26 | // explicit instantiation and registering 27 | 28 | /** 29 | * @brief ContentStore with LRU cache replacement policy 30 | */ 31 | template class ContentStoreImpl; 32 | /** 33 | * @brief ContentStore with random cache replacement policy 34 | */ 35 | 36 | template class ContentStoreImpl; 37 | 38 | /** 39 | * @brief ContentStore with FIFO cache replacement policy 40 | */ 41 | template class ContentStoreImpl; 42 | -------------------------------------------------------------------------------- /examples/graphs/rate-graph.R: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012,2015 Alexander Afanasyev 2 | 3 | # install.packages('ggplot2') 4 | library(ggplot2) 5 | # install.packages('scales') 6 | library(scales) 7 | 8 | # install.packages('doBy') 9 | library(doBy) 10 | 11 | ######################### 12 | # Rate trace processing # 13 | ######################### 14 | data = read.table("rate-trace.txt", header=T) 15 | data$Node = factor(data$Node) 16 | data$FaceId <- factor(data$FaceId) 17 | data$Kilobits <- data$Kilobytes * 8 18 | data$Type = factor(data$Type) 19 | 20 | # exlude irrelevant types 21 | data = subset(data, Type %in% c("InInterests", "OutInterests", "InData", "OutData")) 22 | 23 | # combine stats from all faces 24 | data.combined = summaryBy(. ~ Time + Node + Type, data=data, FUN=sum) 25 | 26 | data.root = subset (data.combined, Node == "root") 27 | data.leaves = subset(data.combined, Node %in% c("leaf-1", "leaf-2", "leaf-3", "leaf-4")) 28 | 29 | # graph rates on all nodes in Kilobits 30 | g.all <- ggplot(data.combined) + 31 | geom_point(aes (x=Time, y=Kilobits.sum, color=Type), size=1) + 32 | ylab("Rate [Kbits/s]") + 33 | facet_wrap(~ Node) 34 | 35 | print(g.all) 36 | 37 | # graph rates on the root nodes in Packets 38 | g.root <- ggplot(data.root) + 39 | geom_point(aes (x=Time, y=Kilobits.sum, color=Type), size=2) + 40 | geom_line(aes (x=Time, y=Kilobits.sum, color=Type), size=0.5) + 41 | ylab("Rate [Kbits/s]") 42 | 43 | print(g.root) 44 | 45 | png("src/ndnSIM/docs/source/_static/root-rates.png", width=500, height=250) 46 | print(g.root) 47 | retval <- dev.off() 48 | -------------------------------------------------------------------------------- /examples/ndn-custom-apps/hijacker.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | // hijacker.hpp 21 | 22 | #ifndef HIJACKER_H_ 23 | #define HIJACKER_H_ 24 | 25 | #include "ns3/ndnSIM/apps/ndn-app.hpp" 26 | 27 | namespace ns3 { 28 | 29 | class Hijacker : public ndn::App { 30 | public: 31 | static TypeId 32 | GetTypeId(); 33 | 34 | Hijacker(); 35 | 36 | // Receive all Interests but do nothing in response 37 | void 38 | OnInterest(std::shared_ptr interest); 39 | 40 | protected: 41 | // inherited from Application base class. 42 | virtual void 43 | StartApplication(); 44 | 45 | virtual void 46 | StopApplication(); 47 | }; 48 | 49 | } // namespace ns3 50 | 51 | #endif // HIJACKER_H_ 52 | -------------------------------------------------------------------------------- /docs/source/community-contributions.rst: -------------------------------------------------------------------------------- 1 | .. _community-contributions: 2 | 3 | Contributions of the ndnSIM User Community 4 | ========================================== 5 | 6 | Some of the very much appreciated contributions of the user community include 7 | the following: 8 | 9 | #. **Script for automated installation on Ubuntu 14.04, 15.04, 16.04 and 17.04.** 10 | 11 | The `script `__ 12 | was created and is maintained by Kiran Ramesh, Karthik S, Ayush Agarwal, 13 | Viyom Mittal, Vivek Jain, and Mohit P. Tahiliani, 14 | Wireless Information Networking Group (WiNG), NITK Surathkal. 15 | 16 | #. **Adding custom fields to packets in ndnSIM 2.3 without forking the entire repository.** 17 | 18 | The `article `__ 19 | was published by Travis Mick. 20 | 21 | #. **Run ndnSIM with scenario template without root access.** 22 | 23 | The `article `__ 24 | was published by Christian Kreuzberger. 25 | 26 | #. **How-To: Install ndnSIM with BRITE on Ubuntu 14.04.** 27 | 28 | The `article `__ 29 | was published by Christian Kreuzberger. 30 | 31 | #. **Installing ndnSIM on Ubuntu 15.04.** 32 | 33 | The `article `__ 34 | was published by Bhupendra Moharil. 35 | 36 | .. note:: If you have contributed to ndnSIM, please let us know, so that we can 37 | add your contribution. 38 | -------------------------------------------------------------------------------- /utils/ndn-ns3-packet-tag.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDN_NS3_PACKET_TAG_HPP 21 | #define NDN_NS3_PACKET_TAG_HPP 22 | 23 | #include "ns3/packet.h" 24 | #include "ns3/ptr.h" 25 | #include 26 | 27 | namespace ns3 { 28 | namespace ndn { 29 | 30 | class Ns3PacketTag : public ::ndn::Tag { 31 | public: 32 | static size_t 33 | getTypeId() 34 | { 35 | return 0xaee87802; // md5("Ns3PacketTag")[0:8] 36 | } 37 | 38 | Ns3PacketTag(Ptr packet) 39 | : m_packet(packet) 40 | { 41 | } 42 | 43 | Ptr 44 | getPacket() const 45 | { 46 | return m_packet; 47 | } 48 | 49 | private: 50 | Ptr m_packet; 51 | }; 52 | 53 | } // namespace ndn 54 | } // namespace ns3 55 | 56 | #endif // NDN_NS3_PACKET_TAG_HPP 57 | -------------------------------------------------------------------------------- /tests/unit-tests/tests-common.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDNSIM_TESTS_UNIT_TESTS_TESTS_COMMON_HPP 21 | #define NDNSIM_TESTS_UNIT_TESTS_TESTS_COMMON_HPP 22 | 23 | #include "ns3/core-module.h" 24 | #include "model/ndn-global-router.hpp" 25 | #include "helper/ndn-scenario-helper.hpp" 26 | 27 | #include "boost-test.hpp" 28 | 29 | namespace ns3 { 30 | namespace ndn { 31 | 32 | class CleanupFixture 33 | { 34 | public: 35 | ~CleanupFixture() 36 | { 37 | Simulator::Destroy(); 38 | Names::Clear(); 39 | GlobalRouter::clear(); 40 | } 41 | }; 42 | 43 | class ScenarioHelperWithCleanupFixture : public ScenarioHelper, public CleanupFixture 44 | { 45 | public: 46 | }; 47 | 48 | } // namespace ndn 49 | } // namespace ns3 50 | 51 | #endif // NDNSIM_TESTS_UNIT_TESTS_TESTS_COMMON_HPP 52 | -------------------------------------------------------------------------------- /helper/lfid/remove-loops.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2019 Klaus Schneider, The University of Arizona 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: Klaus Schneider 19 | */ 20 | 21 | #ifndef LFID_REMOVE_LOOPS_H 22 | #define LFID_REMOVE_LOOPS_H 23 | 24 | #include 25 | 26 | #include "ns3/ndnSIM/helper/lfid/abstract-fib.hpp" 27 | 28 | namespace ns3 { 29 | namespace ndn { 30 | 31 | // No Vertex Property 32 | // Edge Property: Weight. 33 | using DiGraph = 34 | boost::adjacency_list>; 36 | 37 | void 38 | getDigraphFromFib(DiGraph& dg, const AbstractFib::AllNodeFib& allNodeFIB, const int dstId); 39 | 40 | int 41 | removeLoops(AbstractFib::AllNodeFib& allNodeFIB, bool printOutput = true); 42 | 43 | int 44 | removeDeadEnds(AbstractFib::AllNodeFib& allNodeFIB, bool printOutput = true); 45 | 46 | } // namespace ndn 47 | } // namespace ns3 48 | 49 | #endif //LFID_REMOVE_LOOPS_H 50 | -------------------------------------------------------------------------------- /utils/batches.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "batches.hpp" 21 | 22 | namespace ns3 { 23 | 24 | ATTRIBUTE_HELPER_CPP(Batches); 25 | 26 | std::ostream& 27 | operator<<(std::ostream& os, const Batches& batch) 28 | { 29 | for (Batches::const_iterator i = batch.begin(); i != batch.end(); i++) 30 | os << std::get<0>(*i) << " " << std::get<1>(*i) << " "; 31 | 32 | return os; 33 | } 34 | 35 | /** 36 | * \brief Read components from input and add them to components. Will read input stream till eof 37 | * Substrings separated by slashes will become separate components 38 | */ 39 | std::istream& 40 | operator>>(std::istream& is, Batches& batch) 41 | { 42 | Time time; 43 | uint32_t amount; 44 | while (!is.eof()) { 45 | is >> time >> amount; 46 | batch.Add(time, amount); 47 | // std::cout << time << ", " << amount << ". \n"; 48 | } 49 | 50 | return is; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /examples/ndn-cxx-simple.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "ndn-cxx-simple/real-app.hpp" 21 | #include "ndn-cxx-simple/real-app-starter.hpp" 22 | 23 | #include "ns3/core-module.h" 24 | #include "ns3/network-module.h" 25 | #include "ns3/ndnSIM-module.h" 26 | 27 | namespace ns3 { 28 | 29 | NS_OBJECT_ENSURE_REGISTERED(RealAppStarter); 30 | 31 | int 32 | main(int argc, char* argv[]) 33 | { 34 | CommandLine cmd; 35 | cmd.Parse(argc, argv); 36 | 37 | Ptr node = CreateObject(); 38 | 39 | ndn::StackHelper ndnHelper; 40 | ndnHelper.Install(node); 41 | 42 | ndn::AppHelper appHelper("RealAppStarter"); 43 | appHelper.Install(node) 44 | .Start(Seconds(6.5)); 45 | 46 | Simulator::Stop(Seconds(20.0)); 47 | 48 | Simulator::Run(); 49 | Simulator::Destroy(); 50 | 51 | return 0; 52 | } 53 | 54 | } // namespace ns3 55 | 56 | int 57 | main(int argc, char* argv[]) 58 | { 59 | return ns3::main(argc, argv); 60 | } 61 | -------------------------------------------------------------------------------- /utils/ndn-time.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDNSIM_UTILS_TIME_HPP 21 | #define NDNSIM_UTILS_TIME_HPP 22 | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" 24 | 25 | #include 26 | 27 | namespace ns3 { 28 | namespace ndn { 29 | namespace time { 30 | 31 | class CustomSystemClock : public CustomClock { 32 | public: 33 | system_clock::time_point 34 | getNow() const; 35 | 36 | std::string 37 | getSince() const; 38 | 39 | system_clock::duration 40 | toWaitDuration(system_clock::duration d) const; 41 | }; 42 | 43 | class CustomSteadyClock : public CustomClock { 44 | public: 45 | steady_clock::time_point 46 | getNow() const; 47 | 48 | std::string 49 | getSince() const; 50 | 51 | steady_clock::duration 52 | toWaitDuration(steady_clock::duration d) const; 53 | }; 54 | 55 | } // namespace time 56 | } // namespace ndn 57 | } // namespace ns3 58 | 59 | #endif // NDNSIM_UTILS_TIME_HPP 60 | -------------------------------------------------------------------------------- /tests/other/ndn-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | size=100 4 | rate=1000 5 | sim_time=$(( 2000 / rate )) 6 | 7 | # scenarios using the ndnSIM CS 8 | echo "Using ndnSIM's CS.." 9 | 10 | # scenarios using the Lru replacement policy 11 | echo "Lru replacement policy.." 12 | 13 | # scenarios for the evaluation of memory overhead per PIT entry 14 | echo "Evaluation of memory overhead per PIT entry.." 15 | 16 | echo "CS size = " $size, "interest rate = " $rate 17 | 18 | # using multicast forwarding strategy 19 | echo "Using multicast forwarding strategy.." 20 | 21 | ../../../waf --run ndn-test --command-template="%s --old-cs=ns3::ndn::cs::Lru --cs-size=${size} --rate=${rate} --sim-time=${sim_time} --pit=$(true) --strategy="/localhost/nfd/strategy/multicast" " 22 | 23 | echo 24 | 25 | # using best route forwarding strategy 26 | echo "Using best route forwarding strategy.." 27 | 28 | ../../../waf --run ndn-test --command-template="%s --old-cs=ns3::ndn::cs::Lru --cs-size=${size} --rate=${rate} --pit=$(true) --strategy="/localhost/nfd/strategy/best-route" --sim-time=${sim_time}" 29 | 30 | echo 31 | 32 | size=100000 33 | rate=100 34 | sim_time=$(( 2000 / rate )) 35 | 36 | # scenarios using the NFD's CS 37 | echo "Using NFD's CS.." 38 | 39 | # scenarios for the evaluation of memory overhead per CS entry 40 | echo "Evaluation of memory overhead per CS entry.." 41 | 42 | echo "CS size = " $size, "interest rate = " $rate 43 | 44 | # using multicast forwarding strategy 45 | echo "Using multicast forwarding strategy.." 46 | 47 | ../../../waf --run ndn-test --command-template="%s --cs-size=${size} --rate=${rate} --strategy="/localhost/nfd/strategy/multicast" --sim-time=${sim_time}" 48 | 49 | echo 50 | 51 | # using best route forwarding strategy 52 | echo "Using best route forwarding strategy.." 53 | 54 | ../../../waf --run ndn-test --command-template="%s --cs-size=${size} --rate=${rate} --strategy="/localhost/nfd/strategy/best-route" --sim-time=${sim_time}" 55 | -------------------------------------------------------------------------------- /examples/topologies/topo-grid.txt: -------------------------------------------------------------------------------- 1 | # any empty lines and lines starting with '#' symbol are ignored 2 | # 3 | # The file should contain exactly two sections: router and link, each starting with the corresponding keyword 4 | # 5 | # router section defines topology nodes and their relative positions (e.g., to use in visualizer) 6 | router 7 | 8 | # each line in this section represents one router and should have the following data 9 | # node comment yPos xPos 10 | 11 | router0 NA 0 1 12 | router1 NA 1 1 13 | router2 NA 1 2 14 | router3 NA 1 3 15 | router4 NA 1 4 16 | router5 NA 1 4 17 | router6 NA 1 4 18 | router7 NA 1 4 19 | producer NA 2 1 20 | 21 | 22 | # Note that `node` can be any string. It is possible to access to the node by name using Names::Find, see examples. 23 | 24 | # link section defines point-to-point links between nodes and characteristics of these links 25 | link 26 | 27 | # Each line should be in the following format (only first two are required, the rest can be omitted) 28 | # srcNode dstNode bandwidth metric delay queue 29 | # bandwidth: link bandwidth 30 | # metric: routing metric // Set real routing metrics inside simulation file! 31 | # delay: link delay 32 | # queue: MaxPackets for transmission queue on the link (both directions) 33 | 34 | router0 router1 100Mbps 1 5ms 35 | router0 router3 100Mbps 2 5ms 36 | 37 | router1 router2 100Mbps 3 5ms 38 | router1 router4 100Mbps 4 5ms 39 | 40 | router2 router5 100Mbps 5 5ms 41 | 42 | router3 router4 100Mbps 16 5ms 43 | router3 router6 100Mbps 1 5ms 44 | 45 | router4 router5 100Mbps 8 5ms 46 | router4 router7 100Mbps 4 5ms 47 | 48 | router6 router7 100Mbps 5 5ms 49 | 50 | router5 producer 10Mbps 10 5ms 51 | router7 producer 10Mbps 2 5ms 52 | -------------------------------------------------------------------------------- /model/ndn-block-header.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDNSIM_NDN_BLOCK_HEADER_HPP 21 | #define NDNSIM_NDN_BLOCK_HEADER_HPP 22 | 23 | #include "ns3/header.h" 24 | 25 | #include "ndn-common.hpp" 26 | 27 | namespace nfdFace = nfd::face; 28 | 29 | namespace ns3 { 30 | namespace ndn { 31 | 32 | class BlockHeader : public Header { 33 | public: 34 | static ns3::TypeId 35 | GetTypeId(); 36 | 37 | virtual TypeId 38 | GetInstanceTypeId(void) const; 39 | 40 | BlockHeader(); 41 | 42 | BlockHeader(const Block& packet); 43 | 44 | virtual uint32_t 45 | GetSerializedSize(void) const; 46 | 47 | virtual void 48 | Serialize(ns3::Buffer::Iterator start) const; 49 | 50 | virtual uint32_t 51 | Deserialize(ns3::Buffer::Iterator start); 52 | 53 | virtual void 54 | Print(std::ostream& os) const; 55 | 56 | Block& 57 | getBlock(); 58 | 59 | const Block& 60 | getBlock() const; 61 | 62 | private: 63 | Block m_block; 64 | }; 65 | 66 | } // namespace ndn 67 | } // namespace ns3 68 | 69 | #endif // NDNSIM_NDN_BLOCK_HEADER_HPP 70 | -------------------------------------------------------------------------------- /utils/tracers/l2-tracer.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "l2-tracer.hpp" 21 | 22 | #include "ns3/node.h" 23 | #include "ns3/config.h" 24 | #include "ns3/names.h" 25 | #include "ns3/callback.h" 26 | 27 | #include "ns3/point-to-point-net-device.h" 28 | #include "ns3/queue.h" 29 | #include 30 | 31 | namespace ns3 { 32 | 33 | L2Tracer::L2Tracer(Ptr node) 34 | : m_nodePtr(node) 35 | { 36 | m_node = boost::lexical_cast(m_nodePtr->GetId()); 37 | 38 | Connect(); 39 | 40 | std::string name = Names::FindName(node); 41 | if (!name.empty()) { 42 | m_node = name; 43 | } 44 | } 45 | 46 | void 47 | L2Tracer::Connect() 48 | { 49 | for (uint32_t devId = 0; devId < m_nodePtr->GetNDevices(); devId++) { 50 | Ptr p2pnd = 51 | DynamicCast(m_nodePtr->GetDevice(devId)); 52 | if (p2pnd) { 53 | p2pnd->GetQueue()->TraceConnectWithoutContext("Drop", MakeCallback(&L2Tracer::Drop, this)); 54 | } 55 | } 56 | } 57 | 58 | } // namespace ns3 59 | -------------------------------------------------------------------------------- /apps/ndn-consumer-batches.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDN_CONSUMER_BATCHES_H 21 | #define NDN_CONSUMER_BATCHES_H 22 | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" 24 | 25 | #include "ndn-consumer.hpp" 26 | #include "ns3/traced-value.h" 27 | #include "ns3/ndnSIM/utils/batches.hpp" 28 | 29 | namespace ns3 { 30 | namespace ndn { 31 | 32 | /** 33 | * @ingroup ndn-apps 34 | * \brief Ndn application for sending out Interest packets in batches 35 | */ 36 | class ConsumerBatches : public Consumer { 37 | public: 38 | static TypeId 39 | GetTypeId(); 40 | 41 | /** 42 | * \brief Default constructor 43 | */ 44 | ConsumerBatches(); 45 | 46 | private: 47 | virtual void 48 | StartApplication(); ///< @brief Called at time specified by Start 49 | 50 | void 51 | AddBatch(uint32_t amount); 52 | 53 | protected: 54 | /** 55 | * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN 56 | * protocol 57 | */ 58 | virtual void 59 | ScheduleNextPacket(); 60 | 61 | private: 62 | bool m_initial; 63 | 64 | Batches m_batches; 65 | }; 66 | 67 | } // namespace ndn 68 | } // namespace ns3 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /.jenkins.d/01-deps.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | JDIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 5 | source "$JDIR"/util.sh 6 | 7 | set -x 8 | 9 | if has OSX $NODE_LABELS; then 10 | FORMULAE=(boost pkg-config libxml2) 11 | if [[ -n $USE_OPENSSL_1_1 ]]; then 12 | FORMULAE+=(openssl@1.1) 13 | else 14 | FORMULAE+=(openssl) 15 | fi 16 | 17 | brew update 18 | if [[ -n $TRAVIS ]]; then 19 | # Travis images come with a large number of brew packages 20 | # pre-installed, don't waste time upgrading all of them 21 | for FORMULA in "${FORMULAE[@]}"; do 22 | brew outdated $FORMULA || brew upgrade $FORMULA 23 | done 24 | else 25 | brew upgrade 26 | fi 27 | brew install "${FORMULAE[@]}" 28 | brew cleanup 29 | fi 30 | 31 | if has Ubuntu $NODE_LABELS; then 32 | sudo apt-get -qq update 33 | sudo apt-get -qy install build-essential pkg-config libboost-all-dev \ 34 | libsqlite3-dev libssl-dev 35 | 36 | if [[ $JOB_NAME == *"code-coverage" ]]; then 37 | sudo apt-get -qy install gcovr lcov libgd-perl 38 | fi 39 | fi 40 | 41 | if has Ubuntu-16.04 $NODE_LABELS; then 42 | sudo apt-get -qy install python-setuptools python-dev python-pygraphviz castxml \ 43 | python-kiwi python-gnome2 ipython libcairo2-dev python3-gi \ 44 | libgirepository1.0-dev python-gi python-gi-cairo \ 45 | gir1.2-gtk-3.0 gir1.2-goocanvas-2.0 python-pip 46 | sudo pip install pygraphviz pycairo PyGObject pygccxml 47 | elif has Ubuntu $NODE_LABELS; then 48 | sudo apt-get -qy install build-essential libsqlite3-dev libboost-all-dev libssl-dev \ 49 | git python3-setuptools castxml \ 50 | gir1.2-goocanvas-2.0 gir1.2-gtk-3.0 libgirepository1.0-dev \ 51 | python3-dev python3-gi python3-gi-cairo \ 52 | python3-pip python3-pygraphviz python3-pygccxml 53 | sudo pip3 install kiwi 54 | fi 55 | -------------------------------------------------------------------------------- /docs/ns3_html_theme/ns3_doxy_header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | $projectname: $title 7 | $title 8 | 9 | 10 | 11 | $treeview 12 | $search 13 | $mathjax 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 |
23 | 24 | 25 | 26 | 34 | 38 | 39 | 40 | 41 | 42 | 43 | 46 | 47 | 48 |
35 |
NS-3 based Named Data Networking (NDN) simulator
36 | ndnSIM 2.5: NDN, CCN, CCNx, content centric networks 37 |
$searchbox 44 | API Documentation 45 |
49 |
50 | 51 | 52 | -------------------------------------------------------------------------------- /examples/ndn-simple-with-content-freshness/one-interest-requester.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | // dumb-requester.hpp 21 | 22 | #ifndef DUMB_REQUESTER_H_ 23 | #define DUMB_REQUESTER_H_ 24 | 25 | #include "ns3/ndnSIM/model/ndn-common.hpp" 26 | 27 | #include "ns3/ndnSIM/apps/ndn-app.hpp" 28 | 29 | namespace ns3 { 30 | 31 | /** 32 | * @brief A dumb requester application 33 | * 34 | * This app keeps requesting every second the same content object 35 | */ 36 | class OneInterestRequester : public ndn::App { 37 | public: 38 | // register NS-3 type "OneInterestRequester" 39 | static TypeId 40 | GetTypeId(); 41 | 42 | OneInterestRequester(); 43 | 44 | // (overridden from ndn::App) Processing upon start of the application 45 | virtual void 46 | StartApplication(); 47 | 48 | // (overridden from ndn::App) Processing when application is stopped 49 | virtual void 50 | StopApplication(); 51 | 52 | // (overridden from ndn::App) Callback that will be called when Data arrives 53 | virtual void 54 | OnData(std::shared_ptr data); 55 | 56 | private: 57 | void 58 | SendInterest(); 59 | 60 | private: 61 | bool m_isRunning; 62 | ndn::Name m_name; 63 | }; 64 | 65 | } // namespace ns3 66 | 67 | #endif // DUMB_REQUESTER_H_ 68 | -------------------------------------------------------------------------------- /examples/ndn-custom-apps/hijacker.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | // hijacker.cpp 21 | 22 | #include "hijacker.hpp" 23 | 24 | #include "ns3/log.h" 25 | 26 | #include "ns3/ndnSIM/helper/ndn-fib-helper.hpp" 27 | 28 | NS_LOG_COMPONENT_DEFINE("Hijacker"); 29 | 30 | namespace ns3 { 31 | 32 | // Necessary if you are planning to use ndn::AppHelper 33 | NS_OBJECT_ENSURE_REGISTERED(Hijacker); 34 | 35 | TypeId 36 | Hijacker::GetTypeId() 37 | { 38 | static TypeId tid = TypeId("Hijacker").SetParent().AddConstructor(); 39 | 40 | return tid; 41 | } 42 | 43 | Hijacker::Hijacker() 44 | { 45 | } 46 | 47 | void 48 | Hijacker::OnInterest(std::shared_ptr interest) 49 | { 50 | ndn::App::OnInterest(interest); // forward call to perform app-level tracing 51 | // do nothing else (hijack interest) 52 | 53 | NS_LOG_DEBUG("Do nothing for incoming interest for" << interest->getName()); 54 | } 55 | 56 | void 57 | Hijacker::StartApplication() 58 | { 59 | App::StartApplication(); 60 | 61 | // equivalent to setting interest filter for "/prefix" prefix 62 | ndn::FibHelper::AddRoute(GetNode(), "/prefix/sub", m_face, 0); 63 | } 64 | 65 | void 66 | Hijacker::StopApplication() 67 | { 68 | App::StopApplication(); 69 | } 70 | 71 | } // namespace ns3 72 | -------------------------------------------------------------------------------- /.waf-tools/version.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | 3 | from waflib.Configure import conf 4 | from waflib import Utils 5 | import os 6 | 7 | def splitVersion(version): 8 | base = version.split('-')[0] 9 | split = [v for v in base.split('.')] 10 | return base, version, split 11 | 12 | @conf 13 | def getVersion(conf, submodule, **kw): 14 | tagPrefix = kw.get('tag', '%s-' % submodule) 15 | baseVersion = kw.get('base_version', '0.0.0') 16 | submodule = conf.path.find_node(submodule) 17 | 18 | gitVersion = baseVersion 19 | 20 | didGetVersion = False 21 | try: 22 | cmd = ['git', 'describe', '--always', '--match', '%s*' % tagPrefix] 23 | p = Utils.subprocess.Popen(cmd, stdout=Utils.subprocess.PIPE, 24 | cwd=submodule.abspath(), 25 | stderr=None, stdin=None) 26 | out = p.communicate()[0].strip().decode('utf-8') 27 | didGetVersion = (p.returncode == 0 and out != "") 28 | if didGetVersion: 29 | if out.startswith(tagPrefix): 30 | gitVersion = out[len(tagPrefix):] 31 | else: 32 | gitVersion = "%s-commit-%s" % (baseVersion, out) 33 | except OSError: 34 | pass 35 | 36 | versionFile = submodule.find_node('VERSION.info') 37 | 38 | if not didGetVersion and versionFile is not None: 39 | try: 40 | return splitVersion(versionFile.read()) 41 | except (OSError, IOError): 42 | pass 43 | 44 | # version was obtained from git, update VERSION file if necessary 45 | if versionFile is not None: 46 | try: 47 | version = versionFile.read() 48 | versionFile = None # no need to update 49 | except (OSError, IOError): 50 | Logs.warn("VERSION file exists, but not readable") 51 | else: 52 | versionFile = submodule.make_node('VERSION.info') 53 | 54 | if versionFile: 55 | try: 56 | versionFile.write(gitVersion) 57 | except (OSError, IOError): 58 | Logs.warn("VERSION file is not writeable") 59 | 60 | return splitVersion(gitVersion) 61 | -------------------------------------------------------------------------------- /docs/source/tutorial.rst: -------------------------------------------------------------------------------- 1 | .. ndnSIM: NS-3 based NDN simulator documentation master file 2 | 3 | Welcome 4 | ======= 5 | 6 | The ndnSIM 2.0 is NS-3 module that implements Named Data Networking (NDN) communication 7 | model, the clean slate Internet design. 8 | 9 | We invite you to `join our mailing list 10 | `_ to see and participate in 11 | discussions about ndnSIM implementation and simulations in general (`mailing list archives 12 | `_). 13 | 14 | Contents: 15 | 16 | .. toctree:: 17 | :maxdepth: 4 18 | 19 | intro 20 | getting-started 21 | faq 22 | examples 23 | best-practices 24 | helpers 25 | cs 26 | fw 27 | applications 28 | metric 29 | parallel-simulations 30 | guide-to-simulate-real-apps 31 | ndnsim-research-papers 32 | community-contributions 33 | 34 | 35 | .. toctree:: 36 | :hidden: 37 | :glob: 38 | 39 | meta/* 40 | RELEASE_NOTES 41 | 42 | 43 | ------- 44 | 45 | If you refer to ndnSIM in a published work, please cite the following papers, not just the ndnSIM website. Thank you! 46 | 47 | **For ndnSIM >= 2.0:** 48 | 49 | - **S. Mastorakis, A. Afanasyev, and L. Zhang, "On the Evolution of ndnSIM: an Open-Source Simulator for NDN Experimentation," ACM SIGCOMM Computer Communication Review (CCR), July 2017** (`PDF `__, `BibTex `__) 50 | 51 | - **S. Mastorakis, A. Afanasyev, I. Moiseenko, and L. Zhang, "ndnSIM 2: An updated NDN simulator for NS-3," NDN, Technical Report NDN-0028, Revision 2, 2016** (`PDF `__, `BibTex `__) 52 | 53 | **For ndnSIM 1.0:** 54 | 55 | - **A. Afanasyev, I. Moiseenko, and L. Zhang, "ndnSIM: NDN simulator for NS-3," NDN, Technical Report NDN-0005, 2012** (`PDF `__, `BibTex `__) 56 | 57 | .. * :ref:`search` 58 | -------------------------------------------------------------------------------- /examples/topologies/topo-abilene.txt: -------------------------------------------------------------------------------- 1 | # any empty lines and lines starting with '#' symbol are ignored 2 | # 3 | # The file should contain exactly two sections: router and link, each starting with the corresponding keyword 4 | # 5 | # router section defines topology nodes and their relative positions (e.g., to use in visualizer) 6 | router 7 | 8 | # each line in this section represents one router and should have the following data 9 | # node comment yPos xPos 10 | 11 | router0 NA 0 1 12 | router1 NA 1 1 13 | router2 NA 1 2 14 | router3 NA 1 3 15 | router4 NA 1 4 16 | router5 NA 1 4 17 | router6 NA 1 4 18 | router7 NA 1 4 19 | router8 NA 2 1 20 | router9 NA 2 1 21 | producer NA 2 1 22 | 23 | # Note that `node` can be any string. It is possible to access to the node by name using Names::Find, see examples. 24 | 25 | # link section defines point-to-point links between nodes and characteristics of these links 26 | link 27 | 28 | # Each line should be in the following format (only first two are required, the rest can be omitted) 29 | # srcNode dstNode bandwidth metric delay queue 30 | # bandwidth: link bandwidth 31 | # metric: routing metric // Set real routing metrics inside simulation file! 32 | # delay: link delay 33 | # queue: MaxPackets for transmission queue on the link (both directions) 34 | 35 | 36 | # label LinkType LinkLabel LinkNote cost 37 | 38 | router0 router1 100Mbps 71 5ms 39 | router0 router2 100Mbps 20 5ms 40 | 41 | router1 producer 100Mbps 16 5ms 42 | 43 | router2 router9 100Mbps 54 5ms 44 | 45 | router3 router4 100Mbps 71 5ms 46 | router3 router6 100Mbps 102 5ms 47 | 48 | router4 router5 100Mbps 31 5ms 49 | router4 router6 100Mbps 93 5ms 50 | 51 | router5 router8 10Mbps 137 5ms 52 | 53 | router6 router7 100Mbps 55 5ms 54 | 55 | router7 router8 10Mbps 65 5ms 56 | router7 producer 10Mbps 45 5ms 57 | 58 | router8 router9 10Mbps 70 5ms 59 | 60 | router9 producer 10Mbps 43 5ms 61 | -------------------------------------------------------------------------------- /examples/ndn-custom-apps.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | // ndn-custom-apps.cpp 21 | 22 | #include "ns3/core-module.h" 23 | #include "ns3/network-module.h" 24 | #include "ns3/ndnSIM-module.h" 25 | 26 | namespace ns3 { 27 | 28 | /** 29 | * This scenario simulates a one-node two-custom-app scenario: 30 | * 31 | * +------+ <-----> (CustomApp) 32 | * | Node | 33 | * +------+ <-----> (Hijacker) 34 | * 35 | * NS_LOG=CustomApp ./waf --run=ndn-custom-apps 36 | */ 37 | int 38 | main(int argc, char* argv[]) 39 | { 40 | // Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize 41 | CommandLine cmd; 42 | cmd.Parse(argc, argv); 43 | 44 | // Creating nodes 45 | Ptr node = CreateObject(); 46 | 47 | // Install NDN stack on all nodes 48 | ndn::StackHelper ndnHelper; 49 | ndnHelper.SetDefaultRoutes(true); 50 | ndnHelper.InstallAll(); 51 | 52 | // App1 53 | ndn::AppHelper app1("CustomApp"); 54 | app1.Install(node); 55 | 56 | // App2 57 | ndn::AppHelper app2("Hijacker"); 58 | app2.Install(node); // last node 59 | 60 | Simulator::Stop(Seconds(20.0)); 61 | 62 | Simulator::Run(); 63 | Simulator::Destroy(); 64 | 65 | return 0; 66 | } 67 | 68 | } // namespace ns3 69 | 70 | int 71 | main(int argc, char* argv[]) 72 | { 73 | return ns3::main(argc, argv); 74 | } 75 | -------------------------------------------------------------------------------- /ndn-all.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDNSIM_NDN_ALL_HPP 21 | #define NDNSIM_NDN_ALL_HPP 22 | 23 | #include "ns3/ndnSIM/helper/ndn-stack-helper.hpp" 24 | #include "ns3/ndnSIM/helper/ndn-app-helper.hpp" 25 | #include "ns3/ndnSIM/helper/ndn-global-routing-helper.hpp" 26 | #include "ns3/ndnSIM/helper/ndn-network-region-table-helper.hpp" 27 | // #include "ns3/ndnSIM/helper/ndn-ip-faces-helper.hpp" 28 | // #include "ns3/ndnSIM/helper/ndn-link-control-helper.hpp" 29 | 30 | #include "ns3/ndnSIM/utils/topology/annotated-topology-reader.hpp" 31 | #include "ns3/ndnSIM/utils/topology/rocketfuel-map-reader.hpp" 32 | #include "ns3/ndnSIM/utils/topology/rocketfuel-weights-reader.hpp" 33 | #include "ns3/ndnSIM/utils/tracers/l2-rate-tracer.hpp" 34 | #include "ns3/ndnSIM/utils/tracers/ndn-app-delay-tracer.hpp" 35 | #include "ns3/ndnSIM/utils/tracers/ndn-cs-tracer.hpp" 36 | #include "ns3/ndnSIM/utils/tracers/ndn-l3-rate-tracer.hpp" 37 | 38 | // #include "ns3/ndnSIM/model/ndn-app-face.hpp" 39 | #include "ns3/ndnSIM/model/ndn-l3-protocol.hpp" 40 | // #include "ns3/ndnSIM/model/ndn-net-device-face.hpp" 41 | 42 | // #include "ns3/ndnSIM/apps/ndn-app.hpp" 43 | 44 | #include "ns3/ndnSIM/NFD/daemon/fw/forwarder.hpp" 45 | #include "ns3/ndnSIM/NFD/daemon/table/fib.hpp" 46 | 47 | #include "ns3/ndnSIM/bindings/module-helpers.hpp" 48 | 49 | #endif // NDNSIM_NDN_ALL_HPP 50 | -------------------------------------------------------------------------------- /utils/ndn-time.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "ndn-time.hpp" 21 | 22 | #include "ns3/simulator.h" 23 | 24 | namespace ns3 { 25 | namespace ndn { 26 | namespace time { 27 | 28 | system_clock::time_point 29 | CustomSystemClock::getNow() const 30 | { 31 | boost::chrono::nanoseconds ns(Simulator::Now().GetNanoSeconds()); 32 | return system_clock::time_point(ns); 33 | } 34 | 35 | std::string 36 | CustomSystemClock::getSince() const 37 | { 38 | return " since start of simulation"; 39 | } 40 | 41 | system_clock::duration 42 | CustomSystemClock::toWaitDuration(system_clock::duration d) const 43 | { 44 | BOOST_ASSERT_MSG(false, "Must not be called"); 45 | return time::microseconds(1); 46 | } 47 | 48 | //////////////////////////////////// 49 | 50 | steady_clock::time_point 51 | CustomSteadyClock::getNow() const 52 | { 53 | boost::chrono::nanoseconds ns(Simulator::Now().GetNanoSeconds()); 54 | return steady_clock::time_point(ns); 55 | } 56 | 57 | std::string 58 | CustomSteadyClock::getSince() const 59 | { 60 | return " since start of simulation"; 61 | } 62 | 63 | steady_clock::duration 64 | CustomSteadyClock::toWaitDuration(steady_clock::duration d) const 65 | { 66 | BOOST_ASSERT_MSG(false, "Must not be called"); 67 | return time::microseconds(1); 68 | } 69 | 70 | } // namespace time 71 | } // namespace ndn 72 | } // namespace ns3 73 | -------------------------------------------------------------------------------- /examples/ndn-cxx-simple/real-app-starter.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDNSIM_EXAMPLES_NDN_CXX_SIMPLE_REAL_APP_STARTER_HPP 21 | #define NDNSIM_EXAMPLES_NDN_CXX_SIMPLE_REAL_APP_STARTER_HPP 22 | 23 | #include "real-app.hpp" 24 | 25 | #include "ns3/ndnSIM/helper/ndn-stack-helper.hpp" 26 | #include "ns3/application.h" 27 | 28 | namespace ns3 { 29 | 30 | // Class inheriting from ns3::Application 31 | class RealAppStarter : public Application 32 | { 33 | public: 34 | static TypeId 35 | GetTypeId() 36 | { 37 | static TypeId tid = TypeId("RealAppStarter") 38 | .SetParent() 39 | .AddConstructor(); 40 | 41 | return tid; 42 | } 43 | 44 | protected: 45 | // inherited from Application base class. 46 | virtual void 47 | StartApplication() 48 | { 49 | // Create an instance of the app, and passing the dummy version of KeyChain (no real signing) 50 | m_instance.reset(new app::RealApp(ndn::StackHelper::getKeyChain())); 51 | m_instance->run(); // can be omitted 52 | } 53 | 54 | virtual void 55 | StopApplication() 56 | { 57 | // Stop and destroy the instance of the app 58 | m_instance.reset(); 59 | } 60 | 61 | private: 62 | std::unique_ptr m_instance; 63 | }; 64 | 65 | } // namespace ns3 66 | 67 | #endif // NDNSIM_EXAMPLES_NDN_CXX_SIMPLE_REAL_APP_STARTER_HPP 68 | -------------------------------------------------------------------------------- /examples/topologies/topo-load-balancer.txt: -------------------------------------------------------------------------------- 1 | # topo-load-balancer.txt 2 | 3 | # 4 | # /-----\ 5 | # | CSU | 6 | # +-----> | HUB | <----+ 7 | # | \-----/ | 8 | # | | 1Mbps/10ms delay 9 | # v v 10 | # /------\ /----------\ 11 | # | UCLA | | Consumer | 12 | # | HUB | | CSU-1 | 13 | # +-----> \------/ <-----+ \----------/ 14 | # | | 15 | # | | 16 | # v v 17 | # /----------\ /----------\ 18 | # | Producer | | Producer | 19 | # | UCLA-1 | | UCLA-2 | 20 | # \----------/ \----------/ 21 | # 22 | 23 | # any empty lines and lines starting with '#' symbol is ignored 24 | # 25 | # The file should contain exactly two sections: router and link, each starting with the corresponding keyword 26 | # 27 | # router section defines topology nodes and their relative positions (e.g., to use in visualizer) 28 | router 29 | 30 | # each line in this section represents one router and should have the following data 31 | # node comment yPos xPos 32 | CSU-1 NA 3 5 33 | CSU-HUB NA 5 3 34 | UCLA-HUB NA 3 1 35 | UCLA-1 NA 0 0 36 | UCLA-2 NA 0 2 37 | 38 | # Note that `node` can be any string. It is possible to access to the node by name using Names::Find, see examples. 39 | 40 | # link section defines point-to-point links between nodes and characteristics of these links 41 | link 42 | 43 | # Each line should be in the following format (only first two are required, the rest can be omitted) 44 | # srcNode dstNode bandwidth metric delay queue 45 | # bandwidth: link bandwidth 46 | # metric: routing metric 47 | # delay: link delay 48 | # queue: MaxPackets for transmission queue on the link (both directions) 49 | CSU-1 CSU-HUB 1Mbps 1 10ms 10 50 | CSU-HUB UCLA-HUB 1Mbps 1 10ms 10 51 | UCLA-HUB UCLA-1 1Mbps 1 10ms 10 52 | UCLA-HUB UCLA-2 1Mbps 1 10ms 10 53 | -------------------------------------------------------------------------------- /model/null-transport.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDN_NULL_TRANSPORT_HPP 21 | #define NDN_NULL_TRANSPORT_HPP 22 | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" 24 | #include "ns3/ndnSIM/NFD/daemon/face/transport.hpp" 25 | 26 | namespace ns3 { 27 | namespace ndn { 28 | 29 | /** 30 | * \ingroup ndn-face 31 | * \brief Null transport (does nothing, just fulfills requirements of the interface) 32 | */ 33 | class NullTransport : public nfd::face::Transport 34 | { 35 | public: 36 | NullTransport(const std::string& localUri, const std::string& remoteUri, 37 | ::ndn::nfd::FaceScope scope = ::ndn::nfd::FACE_SCOPE_NON_LOCAL, 38 | ::ndn::nfd::FacePersistency persistency = ::ndn::nfd::FACE_PERSISTENCY_PERSISTENT, 39 | ::ndn::nfd::LinkType linkType = ::ndn::nfd::LINK_TYPE_POINT_TO_POINT) 40 | { 41 | this->setLocalUri(FaceUri(localUri)); 42 | this->setRemoteUri(FaceUri(remoteUri)); 43 | this->setScope(scope); 44 | this->setPersistency(persistency); 45 | this->setLinkType(linkType); 46 | // this->setMtu(udp::computeMtu(m_socket.local_endpoint())); // not sure what should be here 47 | } 48 | 49 | private: 50 | void 51 | doClose() final 52 | { 53 | this->setState(nfd::face::TransportState::CLOSED); 54 | } 55 | 56 | void 57 | doSend(const Block& packet) final 58 | { 59 | } 60 | }; 61 | 62 | } // namespace ndn 63 | } // namespace ns3 64 | 65 | #endif // NDN_NULL_TRANSPORT_HPP 66 | -------------------------------------------------------------------------------- /utils/batches.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef _BATCHES_H_ 21 | #define _BATCHES_H_ 22 | 23 | #include "ns3/attribute.h" 24 | #include "ns3/attribute-helper.h" 25 | #include "ns3/nstime.h" 26 | #include 27 | #include 28 | 29 | namespace ns3 { 30 | 31 | /** 32 | * @ingroup ndn-apps 33 | * @brief Class representing sets of (time, number) tuples with support of reading writing to 34 | * streams 35 | */ 36 | class Batches : public std::list> { 37 | public: 38 | /** 39 | * @brief Default constructor 40 | */ 41 | Batches(){}; 42 | 43 | /** 44 | * @brief Add tuple 45 | * @param when time for the tuple 46 | * @param amount number for the tuple 47 | */ 48 | void 49 | Add(const Time& when, uint32_t amount) 50 | { 51 | push_back(std::make_tuple(when, amount)); 52 | } 53 | }; 54 | 55 | ATTRIBUTE_HELPER_HEADER(Batches); 56 | 57 | /** 58 | * @brief Output contents of the Batches to the std::ostream 59 | * @param os reference to std::ostream 60 | * @param batch constant reference to Batch object 61 | */ 62 | std::ostream& 63 | operator<<(std::ostream& os, const Batches& batch); 64 | 65 | /** 66 | * \brief Read components from input and add them to components. Will read input stream till eof 67 | * Substrings separated by slashes will become separate components 68 | */ 69 | std::istream& 70 | operator>>(std::istream& is, Batches& batch); 71 | 72 | } // namespace ns3 73 | 74 | #endif // _BATCHES_H_ 75 | -------------------------------------------------------------------------------- /utils/tracers/l2-tracer.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef L2_TRACER_H 21 | #define L2_TRACER_H 22 | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" 24 | 25 | #include "ns3/ptr.h" 26 | #include "ns3/simple-ref-count.h" 27 | #include "ns3/packet.h" 28 | 29 | namespace ns3 { 30 | 31 | class Node; 32 | 33 | /** 34 | * @ingroup ndn-tracers 35 | * @brief Link-layer tracer 36 | * 37 | * @todo Finish implementation 38 | */ 39 | class L2Tracer : public SimpleRefCount { 40 | public: 41 | L2Tracer(Ptr node); 42 | virtual ~L2Tracer(){}; 43 | 44 | void 45 | Connect(); 46 | 47 | virtual void 48 | PrintHeader(std::ostream& os) const = 0; 49 | 50 | virtual void 51 | Print(std::ostream& os) const = 0; 52 | 53 | virtual void 54 | Drop(Ptr) = 0; 55 | 56 | // Rx/Tx is NetDevice specific 57 | // please refer to pyviz.cc in order to extend this tracer 58 | 59 | protected: 60 | std::string m_node; 61 | Ptr m_nodePtr; 62 | 63 | struct Stats { 64 | void 65 | Reset() 66 | { 67 | m_in = 0; 68 | m_out = 0; 69 | m_drop = 0; 70 | } 71 | 72 | uint64_t m_in; 73 | uint64_t m_out; 74 | uint64_t m_drop; 75 | }; 76 | }; 77 | 78 | inline std::ostream& 79 | operator<<(std::ostream& os, const L2Tracer& tracer) 80 | { 81 | os << "# "; 82 | tracer.PrintHeader(os); 83 | os << "\n"; 84 | tracer.Print(os); 85 | return os; 86 | } 87 | 88 | } // namespace ns3 89 | 90 | #endif // L2_TRACER_H 91 | -------------------------------------------------------------------------------- /examples/ndn-custom-apps/custom-app.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | // custom-app.hpp 21 | 22 | #ifndef CUSTOM_APP_H_ 23 | #define CUSTOM_APP_H_ 24 | 25 | #include "ns3/ndnSIM/apps/ndn-app.hpp" 26 | 27 | namespace ns3 { 28 | 29 | /** 30 | * @brief A simple custom application 31 | * 32 | * This applications demonstrates how to send Interests and respond with Datas to incoming interests 33 | * 34 | * When application starts it "sets interest filter" (install FIB entry) for /prefix/sub, as well as 35 | * sends Interest for this prefix 36 | * 37 | * When an Interest is received, it is replied with a Data with 1024-byte fake payload 38 | */ 39 | class CustomApp : public ndn::App { 40 | public: 41 | // register NS-3 type "CustomApp" 42 | static TypeId 43 | GetTypeId(); 44 | 45 | // (overridden from ndn::App) Processing upon start of the application 46 | virtual void 47 | StartApplication(); 48 | 49 | // (overridden from ndn::App) Processing when application is stopped 50 | virtual void 51 | StopApplication(); 52 | 53 | // (overridden from ndn::App) Callback that will be called when Interest arrives 54 | virtual void 55 | OnInterest(std::shared_ptr interest); 56 | 57 | // (overridden from ndn::App) Callback that will be called when Data arrives 58 | virtual void 59 | OnData(std::shared_ptr contentObject); 60 | 61 | private: 62 | void 63 | SendInterest(); 64 | }; 65 | 66 | } // namespace ns3 67 | 68 | #endif // CUSTOM_APP_H_ 69 | -------------------------------------------------------------------------------- /examples/ndn-load-balancer/random-load-balancer-strategy.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2014, Regents of the University of California, 4 | * Arizona Board of Regents, 5 | * Colorado State University, 6 | * University Pierre & Marie Curie, Sorbonne University, 7 | * Washington University in St. Louis, 8 | * Beijing Institute of Technology, 9 | * The University of Memphis 10 | * 11 | * This file is part of NFD (Named Data Networking Forwarding Daemon). 12 | * See AUTHORS.md for complete list of NFD authors and contributors. 13 | * 14 | * NFD is free software: you can redistribute it and/or modify it under the terms 15 | * of the GNU General Public License as published by the Free Software Foundation, 16 | * either version 3 of the License, or (at your option) any later version. 17 | * 18 | * NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 19 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 20 | * PURPOSE. See the GNU General Public License for more details. 21 | * 22 | * You should have received a copy of the GNU General Public License along with 23 | * NFD, e.g., in COPYING.md file. If not, see . 24 | */ 25 | 26 | #ifndef NDNSIM_EXAMPLES_NDN_LOAD_BALANCER_RANDOM_LOAD_BALANCER_STRATEGY_HPP 27 | #define NDNSIM_EXAMPLES_NDN_LOAD_BALANCER_RANDOM_LOAD_BALANCER_STRATEGY_HPP 28 | 29 | #include 30 | #include "face/face.hpp" 31 | #include "fw/strategy.hpp" 32 | #include "fw/algorithm.hpp" 33 | 34 | namespace nfd { 35 | namespace fw { 36 | 37 | class RandomLoadBalancerStrategy : public Strategy { 38 | public: 39 | RandomLoadBalancerStrategy(Forwarder& forwarder, const Name& name = getStrategyName()); 40 | 41 | virtual 42 | ~RandomLoadBalancerStrategy() override; 43 | 44 | void 45 | afterReceiveInterest(const Interest& interest, const FaceEndpoint& ingress, 46 | const shared_ptr& pitEntry) override; 47 | 48 | static const Name& 49 | getStrategyName(); 50 | 51 | protected: 52 | boost::random::mt19937 m_randomGenerator; 53 | }; 54 | 55 | } // namespace fw 56 | } // namespace nfd 57 | 58 | #endif // NDNSIM_EXAMPLES_NDN_LOAD_BALANCER_RANDOM_LOAD_BALANCER_STRATEGY_HPP 59 | -------------------------------------------------------------------------------- /apps/ndn-producer.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDN_PRODUCER_H 21 | #define NDN_PRODUCER_H 22 | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" 24 | 25 | #include "ndn-app.hpp" 26 | #include "ns3/ndnSIM/model/ndn-common.hpp" 27 | 28 | #include "ns3/nstime.h" 29 | #include "ns3/ptr.h" 30 | 31 | namespace ns3 { 32 | namespace ndn { 33 | 34 | /** 35 | * @ingroup ndn-apps 36 | * @brief A simple Interest-sink applia simple Interest-sink application 37 | * 38 | * A simple Interest-sink applia simple Interest-sink application, 39 | * which replying every incoming Interest with Data packet with a specified 40 | * size and name same as in Interest.cation, which replying every incoming Interest 41 | * with Data packet with a specified size and name same as in Interest. 42 | */ 43 | class Producer : public App { 44 | public: 45 | static TypeId 46 | GetTypeId(void); 47 | 48 | Producer(); 49 | 50 | // inherited from NdnApp 51 | virtual void 52 | OnInterest(shared_ptr interest); 53 | 54 | protected: 55 | // inherited from Application base class. 56 | virtual void 57 | StartApplication(); // Called at time specified by Start 58 | 59 | virtual void 60 | StopApplication(); // Called at time specified by Stop 61 | 62 | private: 63 | Name m_prefix; 64 | Name m_postfix; 65 | uint32_t m_virtualPayloadSize; 66 | Time m_freshness; 67 | 68 | uint32_t m_signature; 69 | Name m_keyLocator; 70 | }; 71 | 72 | } // namespace ndn 73 | } // namespace ns3 74 | 75 | #endif // NDN_PRODUCER_H 76 | -------------------------------------------------------------------------------- /apps/ndn-consumer-cbr.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDN_CONSUMER_CBR_H 21 | #define NDN_CONSUMER_CBR_H 22 | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" 24 | 25 | #include "ndn-consumer.hpp" 26 | 27 | namespace ns3 { 28 | namespace ndn { 29 | 30 | /** 31 | * @ingroup ndn-apps 32 | * @brief Ndn application for sending out Interest packets at a "constant" rate (Poisson process) 33 | */ 34 | class ConsumerCbr : public Consumer { 35 | public: 36 | static TypeId 37 | GetTypeId(); 38 | 39 | /** 40 | * \brief Default constructor 41 | * Sets up randomizer function and packet sequence number 42 | */ 43 | ConsumerCbr(); 44 | virtual ~ConsumerCbr(); 45 | 46 | protected: 47 | /** 48 | * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN 49 | * protocol 50 | */ 51 | virtual void 52 | ScheduleNextPacket(); 53 | 54 | /** 55 | * @brief Set type of frequency randomization 56 | * @param value Either 'none', 'uniform', or 'exponential' 57 | */ 58 | void 59 | SetRandomize(const std::string& value); 60 | 61 | /** 62 | * @brief Get type of frequency randomization 63 | * @returns either 'none', 'uniform', or 'exponential' 64 | */ 65 | std::string 66 | GetRandomize() const; 67 | 68 | protected: 69 | double m_frequency; // Frequency of interest packets (in hertz) 70 | bool m_firstTime; 71 | Ptr m_random; 72 | std::string m_randomType; 73 | }; 74 | 75 | } // namespace ndn 76 | } // namespace ns3 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /docs/ns3_html_theme/layout.html: -------------------------------------------------------------------------------- 1 | {# 2 | ns-3/layout.html 3 | ~~~~~~~~~~~~~~~~~~~ 4 | 5 | Sphinx layout template for ns-3. 6 | 7 | :copyright: Copyright 2012 by ns-3, see AUTHORS. 8 | :license: GPL, see LICENSE for details. 9 | #} 10 | {% extends "basic/layout.html" %} 11 | 12 | {% set reldelim1 = ' ' %} 13 | {# set reldelim1 = ' @' #} 14 | 15 | {%- block extrahead %} 16 | {%- if theme_customstylesheet %} 17 | 19 | {%- endif %} 20 | 21 | {%- if theme_favicon %} 22 | 24 | {%- endif %} 25 | {% endblock %} 26 | 27 | {% block header %} 28 |
29 | 30 | 31 | 32 | 42 | 46 | 49 | 50 | 51 |
43 |
{{ theme_projectbrief }}
44 | {{ theme_projectnumber }} 45 |
47 | {{ docstitle }} 48 |
52 |
53 | 54 | {% endblock %} 55 | 56 | {% block rootrellink %} 57 |
  • {{ theme_projectname }} 
  • 58 |
  • {{ theme_apidocs }} 
  • 59 |
  •     
  • 60 |
  • Getting started 
  • 61 |
  • Research papers 
  • 62 | {# 63 | {{ super() }} 64 | #} 65 | {% endblock %} 66 | 67 | {% if theme_collapsiblesidebar|tobool %} 68 | {% set script_files = script_files + ['_static/sidebar.js'] %} 69 | {% endif %} 70 | -------------------------------------------------------------------------------- /helper/lfid/fib-nexthop.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2019 Klaus Schneider, The University of Arizona 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: Klaus Schneider 19 | */ 20 | 21 | #include "fib-nexthop.hpp" 22 | 23 | #include 24 | #include 25 | 26 | namespace ns3 { 27 | namespace ndn { 28 | 29 | constexpr int NODE_ID_LIMIT = 1000; 30 | 31 | FibNextHop::FibNextHop(int cost, int nhId, int costDelta, NextHopType type) 32 | { 33 | NS_ABORT_UNLESS(cost > 0 && cost <= MAX_COST); 34 | NS_ABORT_UNLESS(nhId >= 0 && nhId <= NODE_ID_LIMIT); 35 | 36 | this->m_nhId = nhId; 37 | this->m_cost = cost; 38 | this->m_type = type; 39 | this->m_costDelta = costDelta; 40 | } 41 | 42 | std::ostream& 43 | operator<<(std::ostream& os, const NextHopType& type) 44 | { 45 | switch (type) { 46 | case NextHopType::DOWNWARD: 47 | return os << "DOWNWARD"; 48 | case NextHopType::UPWARD: 49 | return os << "UPWARD"; 50 | case NextHopType::DISABLED: 51 | return os << "DISABLED"; 52 | } 53 | return os << static_cast(type); 54 | } 55 | 56 | std::ostream& 57 | operator<<(std::ostream& os, const FibNextHop& a) 58 | { 59 | return os << "Id: " << a.getNexthopId() << ", cost: " << a.m_cost << ", type: " << a.m_type; 60 | } 61 | 62 | } // namespace ndn 63 | } // namespace ns-3 64 | 65 | namespace std { 66 | 67 | using ns3::ndn::FibNextHop; 68 | 69 | template <> 70 | struct hash { 71 | size_t 72 | operator()(const FibNextHop& k) const 73 | { 74 | // Combine hash via boost library 75 | std::size_t seed = 0; 76 | boost::hash_combine(seed, k.getNexthopId()); 77 | boost::hash_combine(seed, k.getCost()); 78 | 79 | return seed; 80 | } 81 | }; 82 | 83 | } 84 | -------------------------------------------------------------------------------- /model/ndn-app-link-service.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDN_APP_LINK_SERVICE_HPP 21 | #define NDN_APP_LINK_SERVICE_HPP 22 | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" 24 | #include "ns3/ndnSIM/NFD/daemon/face/link-service.hpp" 25 | 26 | namespace ns3 { 27 | 28 | class Packet; 29 | class Node; 30 | 31 | namespace ndn { 32 | 33 | class App; 34 | 35 | /** 36 | * \ingroup ndn-face 37 | * \brief Implementation of LinkService for ndnSIM application 38 | * 39 | * \see NetDeviceLinkService 40 | */ 41 | class AppLinkService : public nfd::face::LinkService 42 | { 43 | public: 44 | /** 45 | * \brief Default constructor 46 | */ 47 | AppLinkService(Ptr app); 48 | 49 | virtual ~AppLinkService(); 50 | 51 | public: 52 | void 53 | onReceiveInterest(const Interest& interest); 54 | 55 | void 56 | onReceiveData(const Data& data); 57 | 58 | void 59 | onReceiveNack(const lp::Nack& nack); 60 | 61 | private: 62 | virtual void 63 | doSendInterest(const Interest& interest) override; 64 | 65 | virtual void 66 | doSendData(const Data& data) override; 67 | 68 | virtual void 69 | doSendNack(const lp::Nack& nack) override; 70 | 71 | virtual void 72 | doReceivePacket(const Block& packet, const nfd::EndpointId& endpoint) override 73 | { 74 | // does nothing (all operations for now handled by LinkService) 75 | BOOST_ASSERT(false); 76 | } 77 | 78 | private: 79 | Ptr m_node; 80 | Ptr m_app; 81 | }; 82 | 83 | } // namespace ndn 84 | } // namespace ns3 85 | 86 | #endif // NDN_APP_LINK_SERVICE_HPP 87 | -------------------------------------------------------------------------------- /examples/topologies/topo-tree-25-node.txt: -------------------------------------------------------------------------------- 1 | #Topology.Scenario3.txt 2 | 3 | router 4 | 5 | # node comment yPos xPos 6 | Rtr1 NA 3 9 7 | Rtr2 NA 9 9 8 | Rtr3 NA 15 9 9 | Rtr7 NA 9 15 10 | Rtr4 NA 3 21 11 | Rtr5 NA 9 21 12 | Rtr6 NA 15 21 13 | Src1 NA 1 3 14 | Src2 NA 3 3 15 | Src3 NA 5 3 16 | Src4 NA 7 3 17 | Src5 NA 9 3 18 | Src6 NA 11 3 19 | Src7 NA 13 3 20 | Src8 NA 15 3 21 | Src9 NA 17 3 22 | Dst1 NA 1 27 23 | Dst2 NA 3 27 24 | Dst3 NA 5 27 25 | Dst4 NA 7 27 26 | Dst5 NA 9 27 27 | Dst6 NA 11 27 28 | Dst7 NA 13 27 29 | Dst8 NA 15 27 30 | Dst9 NA 17 27 31 | 32 | link 33 | # srcNode dstNode bandwidth metric delay queue 34 | Src1 Rtr1 100Mbps 1 10ms 10 35 | Src2 Rtr1 100Mbps 1 10ms 10 36 | Src3 Rtr1 100Mbps 1 10ms 10 37 | Src4 Rtr2 100Mbps 1 10ms 10 38 | Src5 Rtr2 100Mbps 1 10ms 10 39 | Src6 Rtr2 100Mbps 1 10ms 10 40 | Src7 Rtr3 100Mbps 1 10ms 10 41 | Src8 Rtr3 100Mbps 1 10ms 10 42 | Src9 Rtr3 100Mbps 1 10ms 10 43 | Rtr1 Rtr7 10Mbps 1 10ms 10 44 | Rtr2 Rtr7 10Mbps 1 10ms 10 45 | Rtr3 Rtr7 10Mbps 1 10ms 10 46 | Rtr4 Rtr7 10Mbps 1 10ms 10 47 | Rtr5 Rtr7 10Mbps 1 10ms 10 48 | Rtr6 Rtr7 10Mbps 1 10ms 10 49 | Dst1 Rtr4 100Mbps 1 10ms 10 50 | Dst2 Rtr4 100Mbps 1 10ms 10 51 | Dst3 Rtr4 100Mbps 1 10ms 10 52 | Dst4 Rtr5 100Mbps 1 10ms 10 53 | Dst5 Rtr5 100Mbps 1 10ms 10 54 | Dst6 Rtr5 100Mbps 1 10ms 10 55 | Dst7 Rtr6 100Mbps 1 10ms 10 56 | Dst8 Rtr6 100Mbps 1 10ms 10 57 | Dst9 Rtr6 100Mbps 1 10ms 10 58 | 59 | -------------------------------------------------------------------------------- /model/ndn-global-router.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "ndn-global-router.hpp" 21 | 22 | #include "model/ndn-l3-protocol.hpp" 23 | 24 | #include "ns3/channel.h" 25 | 26 | namespace ns3 { 27 | namespace ndn { 28 | 29 | uint32_t GlobalRouter::m_idCounter = 0; 30 | 31 | NS_OBJECT_ENSURE_REGISTERED(GlobalRouter); 32 | 33 | TypeId 34 | GlobalRouter::GetTypeId() 35 | { 36 | static TypeId tid = TypeId("ns3::ndn::GlobalRouter").SetGroupName("Ndn").SetParent(); 37 | return tid; 38 | } 39 | 40 | GlobalRouter::GlobalRouter() 41 | { 42 | m_id = m_idCounter; 43 | m_idCounter++; 44 | } 45 | 46 | void 47 | GlobalRouter::NotifyNewAggregate() 48 | { 49 | if (m_ndn == 0) { 50 | m_ndn = GetObject(); 51 | } 52 | Object::NotifyNewAggregate(); 53 | } 54 | 55 | uint32_t 56 | GlobalRouter::GetId() const 57 | { 58 | return m_id; 59 | } 60 | 61 | Ptr 62 | GlobalRouter::GetL3Protocol() const 63 | { 64 | return m_ndn; 65 | } 66 | 67 | void 68 | GlobalRouter::AddLocalPrefix(shared_ptr prefix) 69 | { 70 | m_localPrefixes.push_back(prefix); 71 | } 72 | 73 | void 74 | GlobalRouter::AddIncidency(shared_ptr face, Ptr gr) 75 | { 76 | m_incidencies.push_back(std::make_tuple(this, face, gr)); 77 | } 78 | 79 | GlobalRouter::IncidencyList& 80 | GlobalRouter::GetIncidencies() 81 | { 82 | return m_incidencies; 83 | } 84 | 85 | const GlobalRouter::LocalPrefixList& 86 | GlobalRouter::GetLocalPrefixes() const 87 | { 88 | return m_localPrefixes; 89 | } 90 | 91 | void 92 | GlobalRouter::clear() 93 | { 94 | m_idCounter = 0; 95 | } 96 | 97 | } // namespace ndn 98 | } // namespace ns3 99 | -------------------------------------------------------------------------------- /model/ndn-common.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDNSIM_NDN_COMMON_H 21 | #define NDNSIM_NDN_COMMON_H 22 | 23 | #include "ns3/nstime.h" 24 | #include "ns3/simulator.h" 25 | #include "ns3/attribute.h" 26 | #include "ns3/attribute-helper.h" 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | 37 | #include "NFD/daemon/face/face.hpp" 38 | 39 | namespace nfd { 40 | } 41 | 42 | namespace ns3 { 43 | namespace ndn { 44 | 45 | using ::ndn::Name; 46 | namespace name = ::ndn::name; 47 | 48 | ATTRIBUTE_HELPER_HEADER(Name); 49 | 50 | namespace time { 51 | using namespace ::ndn::time; 52 | } 53 | 54 | namespace lp { 55 | using namespace ::ndn::lp; 56 | } 57 | 58 | using std::shared_ptr; 59 | using std::make_shared; 60 | 61 | using ::ndn::Interest; 62 | using ::ndn::Data; 63 | using ::ndn::KeyLocator; 64 | using ::ndn::SignatureInfo; 65 | using ::ndn::Block; 66 | using ::ndn::KeyChain; 67 | 68 | using ::nfd::Face; 69 | using ::ndn::FaceUri; 70 | 71 | #ifndef DOXYGEN 72 | // For python bindings 73 | namespace nfd = ::nfd; 74 | #endif // DOXYGEN 75 | 76 | using ::ndn::make_unique; 77 | 78 | } // namespace ndn 79 | } // namespace ns3 80 | 81 | namespace nfd { 82 | namespace face { 83 | 84 | inline std::ostream& 85 | operator<<(std::ostream& os, const Face& face) 86 | { 87 | os << face.getLocalUri(); 88 | return os; 89 | } 90 | 91 | } // namespace face 92 | } // namespace nfd 93 | 94 | #endif // NDNSIM_NDN_COMMON_H 95 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | version: ~> 1.0 2 | language: cpp 3 | os: linux 4 | dist: bionic 5 | arch: amd64 6 | 7 | env: 8 | - COMPILER=g++-7 9 | - COMPILER=g++-9 10 | - COMPILER=clang++-6.0 11 | - COMPILER=clang++-9 12 | 13 | jobs: 14 | include: 15 | # Linux 16 | - env: COMPILER=g++-8 17 | - env: COMPILER=clang++-5.0 18 | - env: COMPILER=clang++-7 19 | - env: COMPILER=clang++-8 20 | - env: COMPILER=clang++-10 21 | - env: COMPILER=clang++-11 22 | 23 | # macOS 24 | - os: osx 25 | osx_image: xcode11.4 26 | env: # default compiler 27 | 28 | allow_failures: 29 | - env: COMPILER=clang++-11 30 | 31 | fast_finish: true 32 | 33 | before_install: 34 | - | 35 | : Adding apt repositories 36 | case ${COMPILER} in 37 | g++-9) 38 | # https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test/+packages 39 | travis_retry sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test 40 | travis_retry sudo apt-get -qq update 41 | ;; 42 | clang++-1?) 43 | # https://apt.llvm.org/ 44 | LLVM_REPO=${COMPILER/clang++/llvm-toolchain-${TRAVIS_DIST}} 45 | travis_retry wget -nv -O - "https://apt.llvm.org/llvm-snapshot.gpg.key" | sudo apt-key add - 46 | travis_retry sudo add-apt-repository -y "deb http://apt.llvm.org/${TRAVIS_DIST}/ ${LLVM_REPO%-11} main" 47 | travis_retry sudo apt-get -qq update 48 | ;; 49 | esac 50 | 51 | install: 52 | - | 53 | : Installing C++ compiler 54 | if [[ -n ${COMPILER} ]]; then 55 | travis_retry sudo apt-get -qy install ${COMPILER/clang++/clang} 56 | fi 57 | 58 | before_script: 59 | - | 60 | : Setting environment variables 61 | if [[ -n ${COMPILER} ]]; then 62 | export CXX=${COMPILER} 63 | fi 64 | case ${TRAVIS_OS_NAME} in 65 | linux) export NODE_LABELS="Linux Ubuntu Ubuntu-18.04" ;; 66 | osx) export NODE_LABELS="OSX OSX-$(sw_vers -productVersion | cut -d . -f -2)" ;; 67 | esac 68 | export JOB_NAME=limited-build 69 | export WAF_JOBS=2 70 | - | 71 | : Enabling workarounds 72 | case "${TRAVIS_CPU_ARCH},${COMPILER}" in 73 | arm64,g++*) 74 | # Avoid exceeding the per-job time limit 75 | export DISABLE_HEADERS_CHECK=yes 76 | ;; 77 | ppc64le,g++-7) 78 | # AddressSanitizer does not seem to be working 79 | export DISABLE_ASAN=yes 80 | ;; 81 | *,clang++-8) 82 | # https://bugs.llvm.org/show_bug.cgi?id=40808 83 | export DISABLE_ASAN=yes 84 | ;; 85 | esac 86 | - ${CXX:-c++} --version 87 | 88 | script: 89 | - ./.jenkins 90 | -------------------------------------------------------------------------------- /utils/ndn-rtt-mean-deviation.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | // 3 | // Copyright (c) 2006 Georgia Tech Research Corporation 4 | // (c) 2013 University of Arizona 5 | // (c) 2013 University of California, Los Angeles 6 | // 7 | // This program is free software; you can redistribute it and/or modify 8 | // it under the terms of the GNU General Public License version 2 as 9 | // published by the Free Software Foundation; 10 | // 11 | // This program is distributed in the hope that it will be useful, 12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | // GNU General Public License for more details. 15 | // 16 | // You should have received a copy of the GNU General Public License 17 | // along with this program; if not, write to the Free Software 18 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | // 20 | // Author: Rajib Bhattacharjea 21 | // Cheng Yi 22 | // Alexander Afanasyev 23 | // 24 | 25 | // Georgia Tech Network Simulator - Round Trip Time Estimation Class 26 | // George F. Riley. Georgia Tech, Spring 2002 27 | 28 | #ifndef NDN_RTT_MEAN_DEVIATION_H 29 | #define NDN_RTT_MEAN_DEVIATION_H 30 | 31 | #include "ndn-rtt-estimator.hpp" 32 | 33 | namespace ns3 { 34 | namespace ndn { 35 | 36 | /** 37 | * \ingroup ndn-apps 38 | * 39 | * \brief The modified version of "Mean--Deviation" RTT estimator, as discussed by Van Jacobson that 40 | *better suits NDN communication model 41 | * 42 | * This class implements the "Mean--Deviation" RTT estimator, as discussed 43 | * by Van Jacobson and Michael J. Karels, in 44 | * "Congestion Avoidance and Control", SIGCOMM 88, Appendix A 45 | * 46 | */ 47 | class RttMeanDeviation : public RttEstimator { 48 | public: 49 | static TypeId 50 | GetTypeId(void); 51 | 52 | RttMeanDeviation(); 53 | RttMeanDeviation(const RttMeanDeviation&); 54 | 55 | virtual TypeId 56 | GetInstanceTypeId(void) const; 57 | 58 | void 59 | SentSeq(SequenceNumber32 seq, uint32_t size); 60 | Time 61 | AckSeq(SequenceNumber32 ackSeq); 62 | void 63 | Measurement(Time measure); 64 | Time 65 | RetransmitTimeout(); 66 | Ptr 67 | Copy() const; 68 | void 69 | Reset(); 70 | void 71 | Gain(double g); 72 | 73 | private: 74 | double m_gain; // Filter gain 75 | double m_gain2; // Filter gain 76 | Time m_variance; // Current variance 77 | }; 78 | 79 | } // namespace ndn 80 | } // namespace ns3 81 | 82 | #endif // NDN_RTT_MEAN_DEVIATION 83 | -------------------------------------------------------------------------------- /helper/ndn-network-region-table-helper.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2016 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDNSIM_HELPER_NDN_NETWORK_REGION_TABLE_HELPER_HPP 21 | #define NDNSIM_HELPER_NDN_NETWORK_REGION_TABLE_HELPER_HPP 22 | 23 | #include "ns3/node-container.h" 24 | 25 | #include "ns3/ndnSIM/model/ndn-common.hpp" 26 | 27 | namespace ns3 { 28 | namespace ndn { 29 | 30 | /** 31 | * @ingroup ndn-helpers 32 | * @brief Network Region Table Helper 33 | * 34 | * The NRT Helper interacts directly with Network Region Table by using set-like API 35 | * in order to add/remove a prefix to/from the table or empty it in one node or 36 | * a node container 37 | */ 38 | class NetworkRegionTableHelper 39 | { 40 | public: 41 | static void 42 | AddRegionName(Ptr node, const Name& regionName); 43 | 44 | static void 45 | AddRegionName(NodeContainer& c, const Name& regionName); 46 | 47 | static void 48 | AddRegionName(Ptr node, std::initializer_list regionNames); 49 | 50 | static void 51 | AddRegionName(const NodeContainer& c, std::initializer_list regionNames); 52 | 53 | static void 54 | RemoveRegionName(Ptr node, const Name& regionName); 55 | 56 | static void 57 | RemoveRegionName(const NodeContainer& c, const Name& regionName); 58 | 59 | static void 60 | RemoveRegionName(Ptr node, std::initializer_list regionNames); 61 | 62 | static void 63 | RemoveRegionName(const NodeContainer& c, std::initializer_list regionNames); 64 | 65 | static void 66 | EmptyNetworkRegionTable(Ptr node); 67 | 68 | static void 69 | EmptyNetworkRegionTable(const NodeContainer& c); 70 | }; 71 | 72 | } // namespace ndn 73 | } // namespace ns3 74 | 75 | #endif // NDNSIM_HELPER_NDN_NETWORK_REGION_TABLE_HELPER_HPP 76 | -------------------------------------------------------------------------------- /examples/topologies/topo-grid-3x3.txt: -------------------------------------------------------------------------------- 1 | # topo-grid-3x3.txt 2 | 3 | # /--------\ /-\ /-\ 4 | # |Consumer|<---->| |<------->| | 5 | # \--------/ \-/ \-/ 6 | # ^ ^ ^ 7 | # | | | 1Mbps/10ms delay 8 | # v v v 9 | # /-\ /-\ /-\ 10 | # | |<-------->| |<------->| | 11 | # \-/ \-/ \-/ 12 | # ^ ^ ^ 13 | # | | | 14 | # v v v 15 | # /-\ /-\ /--------\ 16 | # | |<-------->| |<---->|Producer| 17 | # \-/ \-/ \--------/ 18 | 19 | # any empty lines and lines starting with '#' symbol is ignored 20 | # 21 | # The file should contain exactly two sections: router and link, each starting with the corresponding keyword 22 | # 23 | # router section defines topology nodes and their relative positions (e.g., to use in visualizer) 24 | router 25 | 26 | # each line in this section represents one router and should have the following data 27 | # node comment yPos xPos 28 | Node0 NA 3 1 29 | Node1 NA 3 2 30 | Node2 NA 3 3 31 | Node3 NA 2 1 32 | Node4 NA 2 2 33 | Node5 NA 2 3 34 | Node6 NA 1 1 35 | Node7 NA 1 2 36 | Node8 NA 1 3 37 | # Note that `node` can be any string. It is possible to access to the node by name using Names::Find, see examples. 38 | 39 | # link section defines point-to-point links between nodes and characteristics of these links 40 | link 41 | 42 | # Each line should be in the following format (only first two are required, the rest can be omitted) 43 | # srcNode dstNode bandwidth metric delay queue 44 | # bandwidth: link bandwidth 45 | # metric: routing metric 46 | # delay: link delay 47 | # queue: MaxPackets for transmission queue on the link (both directions) 48 | Node0 Node1 1Mbps 1 10ms 10 49 | Node0 Node3 1Mbps 1 10ms 10 50 | Node1 Node2 1Mbps 1 10ms 10 51 | Node1 Node4 1Mbps 1 10ms 10 52 | Node2 Node5 1Mbps 1 10ms 10 53 | Node3 Node4 1Mbps 1 10ms 10 54 | Node3 Node6 1Mbps 1 10ms 10 55 | Node4 Node5 1Mbps 1 10ms 10 56 | Node4 Node7 1Mbps 1 10ms 10 57 | Node5 Node8 1Mbps 1 10ms 10 58 | Node6 Node7 1Mbps 1 10ms 10 59 | Node7 Node8 1Mbps 1 10ms 10 60 | 61 | -------------------------------------------------------------------------------- /model/ndn-app-link-service.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "ndn-app-link-service.hpp" 21 | 22 | #include "ns3/log.h" 23 | #include "ns3/packet.h" 24 | #include "ns3/node.h" 25 | #include "ns3/assert.h" 26 | #include "ns3/simulator.h" 27 | 28 | #include "apps/ndn-app.hpp" 29 | 30 | NS_LOG_COMPONENT_DEFINE("ndn.AppLinkService"); 31 | 32 | namespace ns3 { 33 | namespace ndn { 34 | 35 | AppLinkService::AppLinkService(Ptr app) 36 | : m_node(app->GetNode()) 37 | , m_app(app) 38 | { 39 | NS_LOG_FUNCTION(this << app); 40 | 41 | NS_ASSERT(m_app != 0); 42 | } 43 | 44 | AppLinkService::~AppLinkService() 45 | { 46 | NS_LOG_FUNCTION_NOARGS(); 47 | } 48 | 49 | void 50 | AppLinkService::doSendInterest(const Interest& interest) 51 | { 52 | NS_LOG_FUNCTION(this << &interest); 53 | 54 | // to decouple callbacks 55 | Simulator::ScheduleNow(&App::OnInterest, m_app, interest.shared_from_this()); 56 | } 57 | 58 | void 59 | AppLinkService::doSendData(const Data& data) 60 | { 61 | NS_LOG_FUNCTION(this << &data); 62 | 63 | // to decouple callbacks 64 | Simulator::ScheduleNow(&App::OnData, m_app, data.shared_from_this()); 65 | } 66 | 67 | void 68 | AppLinkService::doSendNack(const lp::Nack& nack) 69 | { 70 | NS_LOG_FUNCTION(this << &nack); 71 | 72 | // to decouple callbacks 73 | Simulator::ScheduleNow(&App::OnNack, m_app, make_shared(nack)); 74 | } 75 | 76 | // 77 | 78 | void 79 | AppLinkService::onReceiveInterest(const Interest& interest) 80 | { 81 | this->receiveInterest(interest, 0); 82 | } 83 | 84 | void 85 | AppLinkService::onReceiveData(const Data& data) 86 | { 87 | this->receiveData(data, 0); 88 | } 89 | 90 | void 91 | AppLinkService::onReceiveNack(const lp::Nack& nack) 92 | { 93 | this->receiveNack(nack, 0); 94 | } 95 | 96 | } // namespace ndn 97 | } // namespace ns3 98 | -------------------------------------------------------------------------------- /utils/tracers/ndn-l3-tracer.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "ndn-l3-tracer.hpp" 21 | #include "ns3/node.h" 22 | #include "ns3/packet.h" 23 | #include "ns3/config.h" 24 | #include "ns3/names.h" 25 | #include "ns3/callback.h" 26 | 27 | #include 28 | 29 | #include "ns3/ndnSIM/model/ndn-l3-protocol.hpp" 30 | 31 | namespace ns3 { 32 | namespace ndn { 33 | 34 | L3Tracer::L3Tracer(Ptr node) 35 | : m_nodePtr(node) 36 | { 37 | m_node = boost::lexical_cast(m_nodePtr->GetId()); 38 | 39 | Connect(); 40 | 41 | std::string name = Names::FindName(node); 42 | if (!name.empty()) { 43 | m_node = name; 44 | } 45 | } 46 | 47 | L3Tracer::L3Tracer(const std::string& node) 48 | : m_node(node) 49 | { 50 | Connect(); 51 | } 52 | 53 | L3Tracer::~L3Tracer(){}; 54 | 55 | void 56 | L3Tracer::Connect() 57 | { 58 | Ptr l3 = m_nodePtr->GetObject(); 59 | 60 | l3->TraceConnectWithoutContext("OutInterests", MakeCallback(&L3Tracer::OutInterests, this)); 61 | l3->TraceConnectWithoutContext("InInterests", MakeCallback(&L3Tracer::InInterests, this)); 62 | l3->TraceConnectWithoutContext("OutData", MakeCallback(&L3Tracer::OutData, this)); 63 | l3->TraceConnectWithoutContext("InData", MakeCallback(&L3Tracer::InData, this)); 64 | l3->TraceConnectWithoutContext("OutNack", MakeCallback(&L3Tracer::OutNack, this)); 65 | l3->TraceConnectWithoutContext("InNack", MakeCallback(&L3Tracer::InNack, this)); 66 | 67 | // satisfied/timed out PIs 68 | l3->TraceConnectWithoutContext("SatisfiedInterests", 69 | MakeCallback(&L3Tracer::SatisfiedInterests, this)); 70 | 71 | l3->TraceConnectWithoutContext("TimedOutInterests", 72 | MakeCallback(&L3Tracer::TimedOutInterests, this)); 73 | } 74 | 75 | } // namespace ndn 76 | } // namespace ns3 77 | -------------------------------------------------------------------------------- /AUTHORS.rst: -------------------------------------------------------------------------------- 1 | ndnSIM Authors 2 | -------------- 3 | 4 | The following lists maintainers, primary developers, and all much-appreciated contributors to ndnSIM in alphabetic order. 5 | The specific contributions of individual authors can be obtained from the git history of the `official ndnSIM repository `__. 6 | If you would like to become a contributor to the official repository, please follow the recommendations in the `contribution guide `__. 7 | 8 | * Jerald Paul Abraham 9 | * ***(Maintainer)*** Alexander Afanasyev 10 | * Syed Obaid Amin 11 | * Hila Ben Abraham 12 | * Chaoyi Bian 13 | * Tai-Lin Chu 14 | * Chengyu Fan 15 | * Yuanzhi Gao 16 | * Chavoosh Ghasemi 17 | * Giulio Grassi 18 | * Mohammad Hovaidi Ardestani 19 | * Yi Huang 20 | * Xiaoke Jiang 21 | * Zhaoning Kong 22 | * Christian Kreuzberger 23 | * Vince Lehman 24 | * Xinyu Ma 25 | * ***(Former Maintainer)*** Spyridon Mastorakis 26 | * ***(Former Maintainer)*** Ilya Moiseenko 27 | * Saeid Montazeri 28 | * Eric Newberry 29 | * Davide Pesavento 30 | * José Quevedo 31 | * Felix Rabe 32 | * Mohammad Sabet 33 | * Matteo Sammarco 34 | * Klaus Schneider 35 | * Wentao Shang 36 | * Junxiao Shi 37 | * Michael Sweatt 38 | * Saran Tarnoi 39 | * Xuxiang Tian 40 | * Jiangzhe (Lucas) Wang 41 | * Cheng Yi 42 | * Yingdi Yu 43 | * Haowei Yuan 44 | * Hang Zhang 45 | * Yu Zhang 46 | * Zongyi Zhao 47 | 48 | Technical Advisors 49 | ^^^^^^^^^^^^^^^^^^ 50 | 51 | * Lixia Zhang 52 | -------------------------------------------------------------------------------- /examples/topologies/topo-grid-3x3-loss.txt: -------------------------------------------------------------------------------- 1 | # topo-grid-3x3.txt 2 | 3 | # /--------\ /-\ /-\ 4 | # |Consumer|<---->| |<------->| | 5 | # \--------/ \-/ \-/ 6 | # ^ ^ ^ 7 | # | | | 1Mbps/10ms delay 8 | # v v v 9 | # /-\ /-\ /-\ 10 | # | |<-------->| |<------->| | 11 | # \-/ \-/ \-/ 12 | # ^ ^ ^ 13 | # | | | 14 | # v v v 15 | # /-\ /-\ /--------\ 16 | # | |<-------->| |<---->|Producer| 17 | # \-/ \-/ \--------/ 18 | 19 | # any empty lines and lines starting with '#' symbol is ignored 20 | # 21 | # The file should contain exactly two sections: router and link, each starting with the corresponding keyword 22 | # 23 | # router section defines topology nodes and their relative positions (e.g., to use in visualizer) 24 | router 25 | 26 | # each line in this section represents one router and should have the following data 27 | # node comment yPos xPos 28 | Node0 NA 3 1 29 | Node1 NA 3 2 30 | Node2 NA 3 3 31 | Node3 NA 2 1 32 | Node4 NA 2 2 33 | Node5 NA 2 3 34 | Node6 NA 1 1 35 | Node7 NA 1 2 36 | Node8 NA 1 3 37 | # Note that `node` can be any string. It is possible to access to the node by name using Names::Find, see examples. 38 | 39 | # link section defines point-to-point links between nodes and characteristics of these links 40 | link 41 | 42 | # Each line should be in the following format (only first two are required, the rest can be omitted) 43 | # srcNode dstNode bandwidth metric delay queue 44 | # bandwidth: link bandwidth 45 | # metric: routing metric 46 | # delay: link delay 47 | # queue: MaxPackets for transmission queue on the link (both directions) 48 | # error: comma-separated list, specifying class for ErrorModel and necessary attributes 49 | Node0 Node1 1Mbps 1 10ms 10 ns3::RateErrorModel,ErrorUnit=ERROR_UNIT_PACKET,ErrorRate=0.9 50 | Node0 Node3 1Mbps 1 10ms 10 51 | Node1 Node2 1Mbps 1 10ms 10 52 | Node1 Node4 1Mbps 1 10ms 10 53 | Node2 Node5 1Mbps 1 10ms 10 54 | Node3 Node4 1Mbps 1 10ms 10 55 | Node3 Node6 1Mbps 1 10ms 10 56 | Node4 Node5 1Mbps 1 10ms 10 57 | Node4 Node7 1Mbps 1 10ms 10 58 | Node5 Node8 1Mbps 1 10ms 10 59 | Node6 Node7 1Mbps 1 10ms 10 60 | Node7 Node8 1Mbps 1 10ms 10 61 | -------------------------------------------------------------------------------- /docs/redmine_issue.py: -------------------------------------------------------------------------------- 1 | # -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | # Based on http://doughellmann.com/2010/05/09/defining-custom-roles-in-sphinx.html 3 | 4 | """Integration of Sphinx with Redmine. 5 | """ 6 | 7 | from docutils import nodes, utils 8 | from docutils.parsers.rst.roles import set_classes 9 | 10 | def redmine_role(name, rawtext, text, lineno, inliner, options={}, content=[]): 11 | """Link to a Redmine issue. 12 | 13 | Returns 2 part tuple containing list of nodes to insert into the 14 | document and a list of system messages. Both are allowed to be 15 | empty. 16 | 17 | :param name: The role name used in the document. 18 | :param rawtext: The entire markup snippet, with role. 19 | :param text: The text marked with the role. 20 | :param lineno: The line number where rawtext appears in the input. 21 | :param inliner: The inliner instance that called us. 22 | :param options: Directive options for customization. 23 | :param content: The directive content for customization. 24 | """ 25 | try: 26 | issue_num = int(text) 27 | if issue_num <= 0: 28 | raise ValueError 29 | except ValueError: 30 | msg = inliner.reporter.error( 31 | 'Redmine issue number must be a number greater than or equal to 1; ' 32 | '"%s" is invalid.' % text, line=lineno) 33 | prb = inliner.problematic(rawtext, rawtext, msg) 34 | return [prb], [msg] 35 | app = inliner.document.settings.env.app 36 | node = make_link_node(rawtext, app, 'issues', str(issue_num), options) 37 | return [node], [] 38 | 39 | def make_link_node(rawtext, app, type, slug, options): 40 | """Create a link to a Redmine resource. 41 | 42 | :param rawtext: Text being replaced with link node. 43 | :param app: Sphinx application context 44 | :param type: Link type (issue, changeset, etc.) 45 | :param slug: ID of the thing to link to 46 | :param options: Options dictionary passed to role func. 47 | """ 48 | # 49 | try: 50 | base = app.config.redmine_project_url 51 | if not base: 52 | raise AttributeError 53 | except AttributeError as err: 54 | raise ValueError('redmine_project_url configuration value is not set (%s)' % str(err)) 55 | # 56 | slash = '/' if base[-1] != '/' else '' 57 | ref = base + slash + type + '/' + slug + '/' 58 | set_classes(options) 59 | node = nodes.reference(rawtext, 'Issue #' + utils.unescape(slug), refuri=ref, 60 | **options) 61 | return node 62 | 63 | def setup(app): 64 | """Install the plugin. 65 | 66 | :param app: Sphinx application context. 67 | """ 68 | app.add_role('issue', redmine_role) 69 | app.add_config_value('redmine_project_url', None, 'env') 70 | return 71 | -------------------------------------------------------------------------------- /tests/unit-tests/helper/ndn-stack-helper.t.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2016 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "helper/ndn-stack-helper.hpp" 21 | #include "../tests-common.hpp" 22 | 23 | #include "ns3/point-to-point-module.h" 24 | 25 | namespace ns3 { 26 | namespace ndn { 27 | 28 | BOOST_FIXTURE_TEST_SUITE(HelperStackHelper, CleanupFixture) 29 | 30 | BOOST_AUTO_TEST_CASE(TestNfdContentStorePolicy) 31 | { 32 | // setting default parameters for PointToPoint links and channels 33 | Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("10Mbps")); 34 | Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("10ms")); 35 | Config::SetDefault("ns3::DropTailQueue::MaxSize", StringValue("20p")); 36 | 37 | // Creating nodes 38 | NodeContainer nodes; 39 | nodes.Create(2); 40 | 41 | // Connecting nodes using two links 42 | PointToPointHelper p2p; 43 | p2p.Install(nodes.Get(0), nodes.Get(1)); 44 | 45 | // Install NDN stack on all nodes 46 | ndn::StackHelper ndnHelper; 47 | ndnHelper.SetDefaultRoutes(true); 48 | ndnHelper.setPolicy("nfd::cs::lru"); 49 | ndnHelper.Install(nodes.Get(0)); 50 | 51 | // test which CS policy has be selected for node 0 52 | Ptr protoNode0 = L3Protocol::getL3Protocol(nodes.Get(0)); 53 | BOOST_CHECK_EQUAL(protoNode0->getForwarder()->getCs().getPolicy()->getName(), "lru"); 54 | 55 | ndnHelper.setPolicy("nfd::cs::priority_fifo"); 56 | ndnHelper.Install(nodes.Get(1)); 57 | 58 | Ptr protoNode1 = L3Protocol::getL3Protocol(nodes.Get(1)); 59 | // test that the CS policy for node 0 did not change 60 | BOOST_CHECK_EQUAL(protoNode0->getForwarder()->getCs().getPolicy()->getName(), "lru"); 61 | // test which CS policy has be selected for node 1 62 | BOOST_CHECK_EQUAL(protoNode1->getForwarder()->getCs().getPolicy()->getName(), "priority_fifo"); 63 | } 64 | 65 | BOOST_AUTO_TEST_SUITE_END() 66 | 67 | } // namespace ndn 68 | } // namespace ns3 69 | -------------------------------------------------------------------------------- /model/ndn-net-device-transport.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2011-2018 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDN_NET_DEVICE_TRANSPORT_HPP 21 | #define NDN_NET_DEVICE_TRANSPORT_HPP 22 | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" 24 | #include "ns3/ndnSIM/NFD/daemon/face/transport.hpp" 25 | 26 | #include "ns3/net-device.h" 27 | #include "ns3/log.h" 28 | #include "ns3/packet.h" 29 | #include "ns3/node.h" 30 | #include "ns3/pointer.h" 31 | 32 | #include "ns3/point-to-point-net-device.h" 33 | #include "ns3/channel.h" 34 | 35 | namespace ns3 { 36 | namespace ndn { 37 | 38 | /** 39 | * \ingroup ndn-face 40 | * \brief ndnSIM-specific transport 41 | */ 42 | class NetDeviceTransport : public nfd::face::Transport 43 | { 44 | public: 45 | NetDeviceTransport(Ptr node, const Ptr& netDevice, 46 | const std::string& localUri, 47 | const std::string& remoteUri, 48 | ::ndn::nfd::FaceScope scope = ::ndn::nfd::FACE_SCOPE_NON_LOCAL, 49 | ::ndn::nfd::FacePersistency persistency = ::ndn::nfd::FACE_PERSISTENCY_PERSISTENT, 50 | ::ndn::nfd::LinkType linkType = ::ndn::nfd::LINK_TYPE_POINT_TO_POINT); 51 | 52 | ~NetDeviceTransport(); 53 | 54 | Ptr 55 | GetNetDevice() const; 56 | 57 | virtual ssize_t 58 | getSendQueueLength() final; 59 | 60 | private: 61 | virtual void 62 | doClose() override; 63 | 64 | virtual void 65 | doSend(const Block& packet) override; 66 | 67 | void 68 | receiveFromNetDevice(Ptr device, 69 | Ptr p, 70 | uint16_t protocol, 71 | const Address& from, const Address& to, 72 | NetDevice::PacketType packetType); 73 | 74 | Ptr m_netDevice; ///< \brief Smart pointer to NetDevice 75 | Ptr m_node; 76 | }; 77 | 78 | } // namespace ndn 79 | } // namespace ns3 80 | 81 | #endif // NDN_NULL_TRANSPORT_HPP 82 | -------------------------------------------------------------------------------- /helper/ndn-strategy-choice-helper.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "ndn-strategy-choice-helper.hpp" 21 | 22 | #include "ns3/log.h" 23 | 24 | #include "ndn-stack-helper.hpp" 25 | 26 | namespace ns3 { 27 | namespace ndn { 28 | 29 | NS_LOG_COMPONENT_DEFINE("ndn.StrategyChoiceHelper"); 30 | 31 | void 32 | StrategyChoiceHelper::sendCommand(const ControlParameters& parameters, Ptr node) 33 | { 34 | NS_LOG_DEBUG("Strategy choice command was initialized"); 35 | Block encodedParameters(parameters.wireEncode()); 36 | 37 | Name commandName("/localhost/nfd/strategy-choice"); 38 | commandName.append("set"); 39 | commandName.append(encodedParameters); 40 | 41 | shared_ptr command(make_shared(commandName)); 42 | command->setCanBePrefix(false); 43 | StackHelper::getKeyChain().sign(*command); 44 | 45 | Ptr l3protocol = node->GetObject(); 46 | l3protocol->injectInterest(*command); 47 | } 48 | 49 | void 50 | StrategyChoiceHelper::Install(const NodeContainer& c, const Name& namePrefix, const Name& strategy) 51 | { 52 | for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) { 53 | Install(*i, namePrefix, strategy); 54 | } 55 | } 56 | 57 | void 58 | StrategyChoiceHelper::Install(Ptr node, const Name& namePrefix, const Name& strategy) 59 | { 60 | ControlParameters parameters; 61 | parameters.setName(namePrefix); 62 | NS_LOG_DEBUG("Node ID: " << node->GetId() << " with forwarding strategy " << strategy); 63 | parameters.setStrategy(strategy); 64 | 65 | Simulator::ScheduleWithContext(node->GetId(), Seconds(0), 66 | &StrategyChoiceHelper::sendCommand, parameters, node); 67 | StackHelper::ProcessWarmupEvents(); 68 | } 69 | 70 | void 71 | StrategyChoiceHelper::InstallAll(const Name& namePrefix, const Name& strategy) 72 | { 73 | Install(NodeContainer::GetGlobal(), namePrefix, strategy); 74 | } 75 | 76 | } // namespace ndn 77 | 78 | } // namespace ns 79 | -------------------------------------------------------------------------------- /docs/ns3_html_theme/README.rst: -------------------------------------------------------------------------------- 1 | .. ns3-theme documentation master file, created by 2 | sphinx-quickstart on Fri Jun 15 12:53:37 2012. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | 7 | The files in this directory customize the Doxygen and Sphinx 8 | layout and rendering to give a common look. 9 | 10 | 11 | Design 12 | ------ 13 | 14 | The basic color scheme is taken from the ns3 homepage, http://www.nsnam.org/ 15 | 16 | Since Sphinx provides more flexible layout and configuration control, 17 | the Doxygen layout and images are used as the basis. 18 | 19 | The top bar design is derived from Doxygen's default when a logo, 20 | project name and description are given in the Doxygen configuration file. 21 | The files ``layout.html`` and ``ns3_doxy_header.html`` should kept in sync. 22 | 23 | 24 | Sphinx Files 25 | ------------ 26 | 27 | ``layout.html`` (:ref:`static filename `) 28 | Augments the default page layout, including the top bar. 29 | 30 | ``theme.conf`` (:ref:`static filename `) 31 | Configuration parameters for ``layout.html`` and ``default.css_t``. 32 | 33 | ``static/bc_s.png`` 34 | Angle bracket in Sphinx relbar, taken from the Doxygen html output. 35 | 36 | ``static/default.css_t`` (:ref:`static filename `) 37 | Default Sphinx CSS template, copied from the default theme. 38 | 39 | ``static/nav_f.png`` 40 | Background image for headings, taken from the Doxygen html output. 41 | 42 | ``static/sidebar.js`` (:ref:`static filename `) 43 | Sidebar script, copied from the default theme. 44 | 45 | ``static/tab_b.png`` 46 | Background image for the Sphinx relbar, taken from the Doxygen html output. 47 | 48 | .. _sphinx-static-filenames: 49 | .. note:: **Static Filenames** 50 | 51 | Sphinx uses hard-coded file names (and the ``static`` directory name). 52 | The files referenced above can't be renamed. 53 | 54 | 55 | Doxygen Files 56 | ------------- 57 | 58 | ``ns3_doxy_footer.html`` 59 | Defines the page footer. 60 | 61 | ``ns3_doxy_header.html`` 62 | Defines the page header, including the top bar. 63 | 64 | ``static/doxygen.css`` 65 | Default Doxygen CSS file, obtained by the ``doxygen -w html ...`` 66 | command. 67 | 68 | Shared Files 69 | ------------ 70 | 71 | ``README.rst`` 72 | This file, not used by Doxygen or Sphinx. 73 | 74 | ``static/bar-top.png`` 75 | Background image for the top bar, resized from the ns-3 homepage. 76 | 77 | ``static/favicon.ico`` 78 | Browser location bar favicon, referenced in ``layout.html`` and 79 | ``ns3_doxy_header.html``, taken from the ns-3 homepage. 80 | 81 | ``static/ns-3-inverted-notext-small.png`` 82 | Logo used in the top bar, taken from the ns-3 media kit. 83 | 84 | ``static/ns3_stylesheet.css`` 85 | Style customizations for both Doxygen and Sphinx. 86 | -------------------------------------------------------------------------------- /examples/topologies/topo-11-node-two-bottlenecks.txt: -------------------------------------------------------------------------------- 1 | # topo-11-node-two-bottlenecks.txt 2 | 3 | # /------\ 0 0 /------\ 4 | # | c1 |<-----+ +----->| p1 | 5 | # \------/ \ / \------/ 6 | # \ /-----\ / 7 | # /------\ 0 \ +==>| r12 |<==+ / 0 /------\ 8 | # | c2 |<--+ \ / \-----/ \ / +-->| p2 | 9 | # \------/ \ \ | | / / \------/ 10 | # \ | | 1Mbps links | | / 11 | # \ 1 v0 v5 1v 2v 3 / 12 | # +->/------\ /------\<-+ 13 | # 2| r1 |<===============>| r2 |4 14 | # +->\------/4 0\------/<-+ 15 | # / 3^ ^5 \ 16 | # / | | \ 17 | # /------\ 0 / / \ \ 0 /------\ 18 | # | c3 |<--+ / \ +-->| p3 | 19 | # \------/ / \ \------/ 20 | # / "All consumer-router and" \ 21 | # /------\ 0 / "router-producer links are" \ 0 /------\ 22 | # | c4 |<-----+ "10Mbps" +---->| p4 | 23 | # \------/ \------/ 24 | # 25 | # "Numbers near nodes denote face IDs. Face ID is assigned based on the order of link" 26 | # "definitions in the topology file" 27 | 28 | router 29 | 30 | #name city latitude longitude 31 | c1 NA 50 30 32 | c2 NA 30 30 33 | c3 NA 10 30 34 | c4 NA 10 40 35 | n1 NA 40 40 36 | n12 NA 30 60 37 | n2 NA 40 80 38 | p1 NA 50 90 39 | p2 NA 30 90 40 | p3 NA 10 90 41 | p4 NA 10 80 42 | 43 | link 44 | 45 | #x y capacity(kbps) OSPF Delay MaxPackets 46 | c1 n1 10Mbps 1 50ms 200 47 | c2 n1 10Mbps 1 10ms 200 48 | c3 n1 10Mbps 1 100ms 200 49 | c4 n1 10Mbps 1 1ms 200 50 | n1 n2 1Mbps 1176 20ms 20 51 | n1 n12 1Mbps 587 1ms 20 52 | n12 n2 1Mbps 846 1ms 20 53 | n2 p1 10Mbps 260 1ms 200 54 | n2 p2 10Mbps 700 1ms 200 55 | n2 p3 10Mbps 1 1ms 200 56 | n2 p4 10Mbps 1 1ms 200 57 | -------------------------------------------------------------------------------- /examples/ndn-cxx-simple/real-app.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDNSIM_EXAMPLES_NDN_CXX_SIMPLE_REAL_APP_HPP 21 | #define NDNSIM_EXAMPLES_NDN_CXX_SIMPLE_REAL_APP_HPP 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | 30 | namespace app { 31 | 32 | class RealApp 33 | { 34 | public: 35 | RealApp(ndn::KeyChain& keyChain) 36 | : m_keyChain(keyChain) 37 | , m_faceProducer(m_faceConsumer.getIoService()) 38 | , m_scheduler(m_faceConsumer.getIoService()) 39 | { 40 | // register prefix and set interest filter on producer face 41 | m_faceProducer.setInterestFilter("/hello", std::bind(&RealApp::respondToAnyInterest, this, _2), 42 | std::bind([]{}), std::bind([]{})); 43 | 44 | // use scheduler to send interest later on consumer face 45 | m_scheduler.schedule(ndn::time::seconds(2), [this] { 46 | m_faceConsumer.expressInterest(ndn::Interest("/hello/world"), 47 | std::bind([] { std::cout << "Hello!" << std::endl; }), 48 | std::bind([] { std::cout << "NACK!" << std::endl; }), 49 | std::bind([] { std::cout << "Bye!.." << std::endl; })); 50 | }); 51 | } 52 | 53 | void 54 | run() 55 | { 56 | m_faceConsumer.processEvents(); // ok (will not block and do nothing) 57 | // m_faceConsumer.getIoService().run(); // will crash 58 | } 59 | 60 | private: 61 | void 62 | respondToAnyInterest(const ndn::Interest& interest) 63 | { 64 | auto data = std::make_shared(interest.getName()); 65 | m_keyChain.sign(*data); 66 | m_faceProducer.put(*data); 67 | } 68 | 69 | private: 70 | ndn::KeyChain& m_keyChain; 71 | ndn::Face m_faceConsumer; 72 | ndn::Face m_faceProducer; 73 | ndn::Scheduler m_scheduler; 74 | }; 75 | 76 | } // namespace app 77 | 78 | #endif // NDNSIM_EXAMPLES_NDN_CXX_SIMPLE_REAL_APP_HPP 79 | -------------------------------------------------------------------------------- /.waf-tools/sphinx_build.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | 4 | # inspired by code by Hans-Martin von Gaudecker, 2012 5 | 6 | import os 7 | from waflib import Node, Task, TaskGen, Errors, Logs, Build, Utils 8 | 9 | class sphinx_build(Task.Task): 10 | color = 'BLUE' 11 | run_str = '${SPHINX_BUILD} -D ${VERSION} -D ${RELEASE} -q -b ${BUILDERNAME} -d ${DOCTREEDIR} ${SRCDIR} ${OUTDIR}' 12 | 13 | def __str__(self): 14 | env = self.env 15 | src_str = ' '.join([a.path_from(a.ctx.launch_node()) for a in self.inputs]) 16 | tgt_str = ' '.join([a.path_from(a.ctx.launch_node()) for a in self.outputs]) 17 | if self.outputs: sep = ' -> ' 18 | else: sep = '' 19 | return'%s [%s]: %s%s%s\n'%(self.__class__.__name__.replace('_task',''), 20 | self.env['BUILDERNAME'], src_str, sep, tgt_str) 21 | 22 | @TaskGen.extension('.py', '.rst') 23 | def sig_hook(self, node): 24 | node.sig=Utils.h_file(node.abspath()) 25 | 26 | @TaskGen.feature("sphinx") 27 | @TaskGen.before_method("process_source") 28 | def apply_sphinx(self): 29 | """Set up the task generator with a Sphinx instance and create a task.""" 30 | 31 | inputs = [] 32 | for i in Utils.to_list(self.source): 33 | if not isinstance(i, Node.Node): 34 | node = self.path.find_node(node) 35 | else: 36 | node = i 37 | if not node: 38 | raise ValueError('[%s] file not found' % i) 39 | inputs.append(node) 40 | 41 | task = self.create_task('sphinx_build', inputs) 42 | 43 | conf = self.path.find_node(self.config) 44 | task.inputs.append(conf) 45 | 46 | confdir = conf.parent.abspath() 47 | buildername = getattr(self, "builder", "html") 48 | srcdir = getattr(self, "srcdir", confdir) 49 | outdir = self.path.find_or_declare(getattr(self, "outdir", buildername)).get_bld() 50 | doctreedir = getattr(self, "doctreedir", os.path.join(outdir.abspath(), ".doctrees")) 51 | 52 | task.env['BUILDERNAME'] = buildername 53 | task.env['SRCDIR'] = srcdir 54 | task.env['DOCTREEDIR'] = doctreedir 55 | task.env['OUTDIR'] = outdir.abspath() 56 | task.env['VERSION'] = "version=%s" % self.VERSION 57 | task.env['RELEASE'] = "release=%s" % self.VERSION 58 | 59 | import imp 60 | confData = imp.load_source('sphinx_conf', conf.abspath()) 61 | 62 | if buildername == "man": 63 | for i in confData.man_pages: 64 | target = outdir.find_or_declare('%s.%d' % (i[1], i[4])) 65 | task.outputs.append(target) 66 | 67 | if self.install_path: 68 | self.bld.install_files("%s/man%d/" % (self.install_path, i[4]), target) 69 | else: 70 | task.outputs.append(outdir) 71 | 72 | def configure(conf): 73 | conf.find_program('sphinx-build', var='SPHINX_BUILD', mandatory=False) 74 | 75 | # sphinx docs 76 | from waflib.Build import BuildContext 77 | class sphinx(BuildContext): 78 | cmd = "sphinx" 79 | fun = "sphinx" 80 | -------------------------------------------------------------------------------- /docs/ns3_html_theme/static/ns3_stylesheet.css: -------------------------------------------------------------------------------- 1 | /* ns-3 changes to the default CSS from Doxygen and Sphinx */ 2 | 3 | body { 4 | font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif; 5 | font-size: 11pt; 6 | color: black; 7 | } 8 | 9 | table, div, p, dl { 10 | } 11 | 12 | a { 13 | color: #91A501; 14 | font-weight: bold; 15 | } 16 | 17 | a:visited { 18 | color: #91A501; 19 | font-weight: bold; 20 | } 21 | 22 | /* Sphinx headings */ 23 | div.body h1, 24 | div.body h2, 25 | div.body h3, 26 | div.body h4, 27 | div.body h5, 28 | div.body h6 { 29 | background-image: url('nav_f.png'); 30 | } 31 | 32 | /* Doxygen side bar */ 33 | #nav-tree { 34 | font-size: 10pt; 35 | } 36 | 37 | #nav-tree a { 38 | font-weight: normal; 39 | } 40 | 41 | /* Sphinx nav links bar (relbar) */ 42 | div.related { 43 | background-image:url('tab_b.png') 44 | } 45 | 46 | div.related h3 { 47 | display: none; 48 | } 49 | 50 | div.related a { 51 | color: #91A501; 52 | font-size: 13pt; 53 | font-weight: bold; 54 | } 55 | 56 | div.related li { 57 | background-image: url('bc_s.png'); 58 | background-position: 100% 40%; 59 | background-repeat: no-repeat; 60 | padding-left: 10px; 61 | padding-right: 15px; 62 | } 63 | 64 | div.related li.right { 65 | background-image: none; 66 | padding-left: 0px; 67 | padding-right: 0px; 68 | } 69 | 70 | /* Sphinx side bar */ 71 | div.sphinxsidebar { 72 | font-size: 10pt; 73 | } 74 | 75 | div.sphinxsidebar a { 76 | font-weight: normal; 77 | } 78 | 79 | 80 | /* Title bar elements */ 81 | 82 | #titlearea 83 | { 84 | background-image:url('bar-top.png'); 85 | background-repeat:repeat; 86 | border-bottom: 1px solid #5B5B5B; 87 | color: white; 88 | } 89 | 90 | #projectlogo 91 | { 92 | text-align: center; 93 | margin: 10px; 94 | vertical-align: middle; 95 | width: 220px; 96 | color: white; 97 | } 98 | 99 | #projecttext 100 | { 101 | align: left; 102 | padding-left: 2em; 103 | font-color:white; 104 | } 105 | 106 | #projectbrief 107 | { 108 | font: 120% Tahoma, Arial,sans-serif; 109 | margin: 0px; 110 | padding: 0px; 111 | color: white; 112 | } 113 | 114 | #projectnumber 115 | { 116 | font: 100% Tahoma, Arial,sans-serif; 117 | margin: 0px; 118 | padding: 0px; 119 | color: white; 120 | } 121 | 122 | #projectsection 123 | { 124 | text-align: right; 125 | font: 24pt Aldo, Tahoma, Arial,sans-serif; 126 | margin: 10px; 127 | margin-right: 10px; 128 | vertical-align: middle; 129 | color: white; 130 | } 131 | 132 | .highlight .hll { 133 | background-color: #FFFF88; 134 | } 135 | 136 | .highlighttable { 137 | font-size: 9pt; 138 | } 139 | 140 | .red { 141 | color: red; 142 | font-weight: bold; 143 | } 144 | 145 | table.contentstable h2 { 146 | margin: 0; 147 | background-image: none; 148 | } 149 | 150 | table.contentstable td .tile { 151 | padding: 0 10px 0 10px; 152 | } 153 | -------------------------------------------------------------------------------- /examples/topologies/topo-grid-3x3-red-queues.txt: -------------------------------------------------------------------------------- 1 | # topo-grid-3x3.txt 2 | 3 | # /--------\ /-\ /-\ 4 | # |Consumer|<---->| |<------->| | 5 | # \--------/ \-/ \-/ 6 | # ^ ^ ^ 7 | # | | | 1Mbps/10ms delay 8 | # v v v 9 | # /-\ /-\ /-\ 10 | # | |<-------->| |<------->| | 11 | # \-/ \-/ \-/ 12 | # ^ ^ ^ 13 | # | | | 14 | # v v v 15 | # /-\ /-\ /--------\ 16 | # | |<-------->| |<---->|Producer| 17 | # \-/ \-/ \--------/ 18 | 19 | # any empty lines and lines starting with '#' symbol is ignored 20 | # 21 | # The file should contain exactly two sections: router and link, each starting with the corresponding keyword 22 | # 23 | # router section defines topology nodes and their relative positions (e.g., to use in visualizer) 24 | router 25 | 26 | # each line in this section represents one router and should have the following data 27 | # node comment yPos xPos 28 | Node0 NA 3 1 29 | Node1 NA 3 2 30 | Node2 NA 3 3 31 | Node3 NA 2 1 32 | Node4 NA 2 2 33 | Node5 NA 2 3 34 | Node6 NA 1 1 35 | Node7 NA 1 2 36 | Node8 NA 1 3 37 | # Note that `node` can be any string. It is possible to access to the node by name using Names::Find, see examples. 38 | 39 | # link section defines point-to-point links between nodes and characteristics of these links 40 | link 41 | 42 | # Each line should be in the following format (only first two are required, the rest can be omitted) 43 | # srcNode dstNode bandwidth metric delay queue 44 | # bandwidth: link bandwidth 45 | # metric: routing metric 46 | # delay: link delay 47 | # queue: comma-separated list, specifying class for Queue (on both sides of the link) and necessary attributes 48 | # error: comma-separated list, specifying class for ErrorModel and necessary attributes 49 | Node0 Node1 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100 50 | Node0 Node3 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100 51 | Node1 Node2 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100 52 | Node1 Node4 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100 53 | Node2 Node5 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100 54 | Node3 Node4 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100 55 | Node3 Node6 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100 56 | Node4 Node5 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100 57 | Node4 Node7 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100 58 | Node5 Node8 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100 59 | Node6 Node7 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100 60 | Node7 Node8 1Mbps 1 10ms ns3::RedQueue,MeanPktSize=100 61 | 62 | -------------------------------------------------------------------------------- /apps/ndn-consumer-window.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2011-2018 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDN_CONSUMER_WINDOW_H 21 | #define NDN_CONSUMER_WINDOW_H 22 | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" 24 | 25 | #include "ndn-consumer.hpp" 26 | #include "ns3/traced-value.h" 27 | 28 | namespace ns3 { 29 | namespace ndn { 30 | 31 | /** 32 | * @ingroup ndn-apps 33 | * \brief Ndn application for sending out Interest packets (window-based) 34 | * 35 | * !!! ATTENTION !!! This is highly experimental and relies on experimental features of the 36 | * simulator. 37 | * Behavior may be unpredictable if used incorrectly. 38 | */ 39 | class ConsumerWindow : public Consumer { 40 | public: 41 | static TypeId 42 | GetTypeId(); 43 | 44 | /** 45 | * \brief Default constructor 46 | */ 47 | ConsumerWindow(); 48 | 49 | // From App 50 | virtual void 51 | OnData(shared_ptr contentObject); 52 | 53 | virtual void 54 | OnTimeout(uint32_t sequenceNumber); 55 | 56 | virtual void 57 | WillSendOutInterest(uint32_t sequenceNumber); 58 | 59 | public: 60 | typedef std::function WindowTraceCallback; 61 | 62 | protected: 63 | /** 64 | * \brief Constructs the Interest packet and sends it using a callback to the underlying NDN 65 | * protocol 66 | */ 67 | virtual void 68 | ScheduleNextPacket(); 69 | 70 | private: 71 | virtual void 72 | SetWindow(uint32_t window); 73 | 74 | uint32_t 75 | GetWindow() const; 76 | 77 | virtual void 78 | SetPayloadSize(uint32_t payload); 79 | 80 | uint32_t 81 | GetPayloadSize() const; 82 | 83 | double 84 | GetMaxSize() const; 85 | 86 | void 87 | SetMaxSize(double size); 88 | 89 | uint32_t 90 | GetSeqMax() const; 91 | 92 | void 93 | SetSeqMax(uint32_t seqMax); 94 | 95 | protected: 96 | uint32_t m_payloadSize; // expected payload size 97 | double m_maxSize; // max size to request 98 | 99 | uint32_t m_initialWindow; 100 | bool m_setInitialWindowOnTimeout; 101 | 102 | TracedValue m_window; 103 | TracedValue m_inFlight; 104 | }; 105 | 106 | } // namespace ndn 107 | } // namespace ns3 108 | 109 | #endif // NDN_CONSUMER_WINDOW_H 110 | -------------------------------------------------------------------------------- /apps/ndn-consumer-zipf-mandelbrot.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Tsinghua University, P.R.China. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | * 19 | * @author Xiaoke Jiang 20 | **/ 21 | 22 | #ifndef NDN_CONSUMER_ZIPF_MANDELBROT_H_ 23 | #define NDN_CONSUMER_ZIPF_MANDELBROT_H_ 24 | 25 | #include "ns3/ndnSIM/model/ndn-common.hpp" 26 | 27 | #include "ndn-consumer.hpp" 28 | #include "ndn-consumer-cbr.hpp" 29 | 30 | #include "ns3/ptr.h" 31 | #include "ns3/log.h" 32 | #include "ns3/simulator.h" 33 | #include "ns3/packet.h" 34 | #include "ns3/callback.h" 35 | #include "ns3/string.h" 36 | #include "ns3/uinteger.h" 37 | #include "ns3/double.h" 38 | #include "ns3/random-variable-stream.h" 39 | 40 | namespace ns3 { 41 | namespace ndn { 42 | 43 | /** 44 | * @ingroup ndn-apps 45 | * @brief NDN app requesting contents following Zipf-Mandelbrot Distbituion 46 | * 47 | * The class implements an app which requests contents following Zipf-Mandelbrot Distribution 48 | * Here is the explaination of Zipf-Mandelbrot Distribution: 49 | *http://en.wikipedia.org/wiki/Zipf%E2%80%93Mandelbrot_law 50 | */ 51 | class ConsumerZipfMandelbrot : public ConsumerCbr { 52 | public: 53 | static TypeId 54 | GetTypeId(); 55 | 56 | /** 57 | * \brief Default constructor 58 | * Sets up randomized Number Generator (RNG) 59 | * Note: m_seq of its parent class ConsumerCbr here is used to record the interest number 60 | */ 61 | ConsumerZipfMandelbrot(); 62 | virtual ~ConsumerZipfMandelbrot(); 63 | 64 | virtual void 65 | SendPacket(); 66 | 67 | uint32_t 68 | GetNextSeq(); 69 | 70 | protected: 71 | virtual void 72 | ScheduleNextPacket(); 73 | 74 | private: 75 | void 76 | SetNumberOfContents(uint32_t numOfContents); 77 | 78 | uint32_t 79 | GetNumberOfContents() const; 80 | 81 | void 82 | SetQ(double q); 83 | 84 | double 85 | GetQ() const; 86 | 87 | void 88 | SetS(double s); 89 | 90 | double 91 | GetS() const; 92 | 93 | private: 94 | uint32_t m_N; // number of the contents 95 | double m_q; // q in (k+q)^s 96 | double m_s; // s in (k+q)^s 97 | std::vector m_Pcum; // cumulative probability 98 | 99 | Ptr m_seqRng; // RNG 100 | }; 101 | 102 | } /* namespace ndn */ 103 | } /* namespace ns3 */ 104 | #endif /* NDN_CONSUMER_ZIPF_MANDELBROT_H_ */ 105 | -------------------------------------------------------------------------------- /utils/tracers/l2-rate-tracer.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef L2_RATE_TRACER_H 21 | #define L2_RATE_TRACER_H 22 | 23 | #include "l2-tracer.hpp" 24 | 25 | #include "ns3/nstime.h" 26 | #include "ns3/event-id.h" 27 | 28 | #include 29 | #include 30 | 31 | namespace ns3 { 32 | 33 | /** 34 | * @ingroup ndn-tracers 35 | * @brief Tracer to collect link-layer rate information about links 36 | * 37 | * @todo Finish implementation 38 | */ 39 | class L2RateTracer : public L2Tracer { 40 | public: 41 | /** 42 | * @brief Network layer tracer constructor 43 | */ 44 | L2RateTracer(std::shared_ptr os, Ptr node); 45 | virtual ~L2RateTracer(); 46 | 47 | /** 48 | * @brief Helper method to install tracers on all simulation nodes 49 | * 50 | * @param file File to which traces will be written 51 | * @param averagingPeriod Defines averaging period for the rate calculation, 52 | * as well as how often data will be written into the trace file (default, every half 53 | *second) 54 | * 55 | * @returns a tuple of reference to output stream and list of tracers. !!! Attention !!! This 56 | *tuple needs to be preserved 57 | * for the lifetime of simulation, otherwise SEGFAULTs are inevitable 58 | * 59 | */ 60 | static void 61 | InstallAll(const std::string& file, Time averagingPeriod = Seconds(0.5)); 62 | 63 | /** 64 | * @brief Explicit request to remove all statically created tracers 65 | * 66 | * This method can be helpful if simulation scenario contains several independent run, 67 | * or if it is desired to do a postprocessing of the resulting data 68 | */ 69 | static void 70 | Destroy(); 71 | 72 | void 73 | SetAveragingPeriod(const Time& period); 74 | 75 | virtual void 76 | PrintHeader(std::ostream& os) const; 77 | 78 | virtual void 79 | Print(std::ostream& os) const; 80 | 81 | virtual void 82 | Drop(Ptr); 83 | 84 | private: 85 | void 86 | PeriodicPrinter(); 87 | 88 | void 89 | Reset(); 90 | 91 | private: 92 | std::shared_ptr m_os; 93 | Time m_period; 94 | EventId m_printEvent; 95 | 96 | mutable std::tuple m_stats; 97 | }; 98 | 99 | } // namespace ns3 100 | 101 | #endif // L2_RATE_TRACER_H 102 | -------------------------------------------------------------------------------- /apps/ndn-consumer-batches.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "ndn-consumer-batches.hpp" 21 | #include "ns3/ptr.h" 22 | #include "ns3/log.h" 23 | #include "ns3/simulator.h" 24 | #include "ns3/packet.h" 25 | #include "ns3/callback.h" 26 | #include "ns3/string.h" 27 | #include "ns3/uinteger.h" 28 | #include "ns3/double.h" 29 | 30 | #include "utils/batches.hpp" 31 | 32 | NS_LOG_COMPONENT_DEFINE("ndn.ConsumerBatches"); 33 | 34 | namespace ns3 { 35 | namespace ndn { 36 | 37 | NS_OBJECT_ENSURE_REGISTERED(ConsumerBatches); 38 | 39 | TypeId 40 | ConsumerBatches::GetTypeId(void) 41 | { 42 | static TypeId tid = 43 | TypeId("ns3::ndn::ConsumerBatches") 44 | .SetGroupName("Ndn") 45 | .SetParent() 46 | .AddConstructor() 47 | 48 | .AddAttribute("Batches", 49 | "Batches to schedule. Should be vector, containing pairs of time and amount", 50 | // TypeId::ATTR_SET, 51 | StringValue(""), MakeBatchesAccessor(&ConsumerBatches::m_batches), 52 | MakeBatchesChecker()); 53 | 54 | return tid; 55 | } 56 | 57 | ConsumerBatches::ConsumerBatches() 58 | : m_initial(true) 59 | { 60 | } 61 | 62 | void 63 | ConsumerBatches::StartApplication() 64 | { 65 | Consumer::StartApplication(); 66 | 67 | // std::cout << "Batches: " << batches << "\n"; 68 | for (Batches::const_iterator i = m_batches.begin(); i != m_batches.end(); i++) { 69 | Simulator::ScheduleWithContext(GetNode()->GetId(), std::get<0>(*i), &ConsumerBatches::AddBatch, 70 | this, std::get<1>(*i)); 71 | } 72 | } 73 | 74 | void 75 | ConsumerBatches::AddBatch(uint32_t amount) 76 | { 77 | // std::cout << Simulator::Now () << " adding batch of " << amount << "\n"; 78 | m_seqMax += amount; 79 | m_rtt->ClearSent(); // this is important, otherwise RTT estimation for the new batch will be 80 | // affected by previous batch history 81 | m_initial = true; 82 | ScheduleNextPacket(); 83 | } 84 | 85 | void 86 | ConsumerBatches::ScheduleNextPacket() 87 | { 88 | if (!m_sendEvent.IsRunning()) { 89 | Time delay = Seconds(0); 90 | if (!m_initial) 91 | delay = m_rtt->RetransmitTimeout(); 92 | 93 | m_initial = false; 94 | m_sendEvent = Simulator::Schedule(delay, &Consumer::SendPacket, this); 95 | } 96 | } 97 | 98 | } // namespace ndn 99 | } // namespace ns3 100 | -------------------------------------------------------------------------------- /utils/mem-usage.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef MEM_USAGE_H 21 | #define MEM_USAGE_H 22 | 23 | #ifdef __linux__ 24 | // #include 25 | // #include 26 | // // #include 27 | #include 28 | #endif 29 | 30 | #ifdef __APPLE__ 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #endif 39 | 40 | /** 41 | * @ingroup ndn-helpers 42 | * @brief Utility class to evaluate current usage of RAM 43 | */ 44 | class MemUsage { 45 | public: 46 | /** 47 | * @brief Get memory utilization in bytes 48 | */ 49 | static inline int64_t 50 | Get() 51 | { 52 | #if defined(__linux__) 53 | /* 54 | /proc/[pid]/statm 55 | Provides information about memory usage, measured in pages. The 56 | columns are: 57 | 58 | size (1) total program size 59 | (same as VmSize in /proc/[pid]/status) 60 | resident (2) resident set size 61 | (same as VmRSS in /proc/[pid]/status) 62 | share (3) shared pages (i.e., backed by a file) 63 | text (4) text (code) 64 | lib (5) library (unused in Linux 2.6) 65 | data (6) data + stack 66 | dt (7) dirty pages (unused in Linux 2.6) 67 | 68 | Reference: http://man7.org/linux/man-pages/man5/proc.5.html 69 | */ 70 | std::ifstream is("/proc/self/statm"); 71 | if (!is.bad() && !is.eof()) { 72 | unsigned long vm; 73 | unsigned long rss; 74 | is >> vm // the first number: virtual memory 75 | >> rss; // the second number: resident set size 76 | 77 | return rss * getpagesize(); 78 | } 79 | else { 80 | return -1; 81 | } 82 | 83 | #elif defined(__APPLE__) 84 | struct task_basic_info t_info; 85 | mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT; 86 | 87 | if (KERN_SUCCESS 88 | != task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&t_info, &t_info_count)) { 89 | return -1; // something is wrong 90 | } 91 | 92 | return t_info.resident_size; 93 | #endif 94 | // other systems are not yet supported 95 | return -1; 96 | } 97 | }; 98 | 99 | #endif // MEM_USAGE_H 100 | -------------------------------------------------------------------------------- /docs/source/cs.rst: -------------------------------------------------------------------------------- 1 | .. _content store: 2 | 3 | NFD's Content Store 4 | ++++++++++++++++++++ 5 | 6 | The Contest Store (CS) is implemented as a set of :ndnsim:`CS entries `), 7 | ordered by the full data name including the implicit digest. To manage entries, CS adopts a cache policy interface (:ndnsim:`nfd::cs::Policy`), invoked any time a CS entry is added, removed, updated, or used. 8 | 9 | The supported cache replacement policies are the following: 10 | 11 | +----------------------------------------------+----------------------------------------------------------+ 12 | | **NFD's Content Store Policies** | 13 | +----------------------------------------------+----------------------------------------------------------+ 14 | | ``nfd::cs::lru`` | Last Recently Used (LRU) | 15 | +----------------------------------------------+----------------------------------------------------------+ 16 | | ``nfd::cs::priority_fifo`` | Priority-Based First-In-First-Out (FIFO) | 17 | +----------------------------------------------+----------------------------------------------------------+ 18 | 19 | For more detailed specification refer to the `NFD Developer's Guide 20 | `_, section 3.3. 21 | 22 | 23 | To control the maximum size and the policy of NFD's Content Store use ``StackHelper::setCsSize()`` and 24 | ``StackHelper::setPolicy()`` methods: 25 | 26 | .. code-block:: c++ 27 | 28 | ndnHelper.setCsSize(); 29 | ndnHelper.setPolicy(); 30 | ... 31 | ndnHelper.Install(nodes); 32 | 33 | Examples: 34 | 35 | - To set CS size 100 on node1, size 1000 on node2, and size 2000 on all other nodes. 36 | LRU replacement policy for node 1, priority FIFO for the rest: 37 | 38 | .. code-block:: c++ 39 | 40 | ndnHelper.setCsSize(100); 41 | ndnHelper.setPolicy("nfd::cs::lru"); 42 | ndnHelper.Install(node1); 43 | 44 | ndnHelper.setCsSize(1000); 45 | ndnHelper.setPolicy("nfd::cs::priority_fifo"); 46 | ndnHelper.Install(node2); 47 | 48 | NodeContainer allOtherNodes; 49 | for (NodeList::Iterator i = NodeList::Begin(); i != NodeList::End(); ++i) { 50 | if (*i != node1 && *i != node2) { 51 | allOtherNodes.Add(*i); 52 | } 53 | } 54 | ndnHelper.Install(allOtherNodes); 55 | 56 | - To effectively disable NFD content store an all nodes 57 | 58 | Minimum allowed value for NFD content store maximum size is 1. 59 | 60 | .. code-block:: c++ 61 | 62 | ndnHelper.setCsSize(1); 63 | ... 64 | ndnHelper.Install(nodes); 65 | 66 | 67 | CS entry 68 | ~~~~~~~~ 69 | 70 | The Data packet, along with other necessary fields, are stored in a CS entry. Each entry 71 | contains: 72 | 73 | - the Data packet 74 | - flag indicating whether the Data packet is unsolicited 75 | - the timestamp at which the cached Data becomes stale 76 | 77 | Misc 78 | ~~~~ 79 | 80 | - Get aggregate statistics of CS hit/miss ratio (works with any policy) 81 | 82 | The simplest way tro track CS hit/miss statistics is to use :ndnsim:`CsTracer`, in more 83 | details described in :ref:`Metrics Section `. 84 | 85 | .. code-block:: c++ 86 | 87 | CsTracer::InstallAll("cs-trace.txt", Seconds(1)); 88 | -------------------------------------------------------------------------------- /apps/ndn-consumer-pcon.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2011-2018 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDN_CONSUMER_PCON_H 21 | #define NDN_CONSUMER_PCON_H 22 | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" 24 | 25 | #include "ndn-consumer-window.hpp" 26 | 27 | namespace ns3 { 28 | namespace ndn { 29 | 30 | enum CcAlgorithm { 31 | AIMD, 32 | BIC, 33 | CUBIC 34 | }; 35 | 36 | /** 37 | * @ingroup ndn-apps 38 | * \brief NDN consumer application with more advanced congestion control options 39 | * 40 | * This app uses the algorithms from "A Practical Congestion Control Scheme for Named 41 | * Data Networking" (https://dl.acm.org/citation.cfm?id=2984369). 42 | * 43 | * It implements slow start, conservative window adaptation (RFC 6675), 44 | * and 3 different TCP algorithms: AIMD, BIC, and CUBIC (RFC 8312). 45 | */ 46 | class ConsumerPcon : public ConsumerWindow { 47 | public: 48 | static TypeId 49 | GetTypeId(); 50 | 51 | ConsumerPcon(); 52 | 53 | virtual void 54 | OnData(shared_ptr data) override; 55 | 56 | virtual void 57 | OnTimeout(uint32_t sequenceNum) override; 58 | 59 | private: 60 | void 61 | WindowIncrease(); 62 | 63 | void 64 | WindowDecrease(); 65 | 66 | void 67 | CubicIncrease(); 68 | 69 | void 70 | CubicDecrease(); 71 | 72 | void 73 | BicIncrease(); 74 | 75 | void 76 | BicDecrease(); 77 | 78 | private: 79 | CcAlgorithm m_ccAlgorithm; 80 | double m_beta; 81 | double m_addRttSuppress; 82 | bool m_reactToCongestionMarks; 83 | bool m_useCwa; 84 | 85 | double m_ssthresh; 86 | uint32_t m_highData; 87 | double m_recPoint; 88 | 89 | // TCP CUBIC Parameters // 90 | static constexpr double CUBIC_C = 0.4; 91 | bool m_useCubicFastConv; 92 | double m_cubicBeta; 93 | 94 | double m_cubicWmax; 95 | double m_cubicLastWmax; 96 | time::steady_clock::TimePoint m_cubicLastDecrease; 97 | 98 | // TCP BIC Parameters // 99 | //! Regular TCP behavior (including slow start) until this window size 100 | static constexpr uint32_t BIC_LOW_WINDOW = 14; 101 | 102 | //! Sets the maximum (linear) increase of TCP BIC. Should be between 8 and 64. 103 | static constexpr uint32_t BIC_MAX_INCREMENT = 16; 104 | 105 | // BIC variables: 106 | double m_bicMinWin; //!< last minimum cwnd 107 | double m_bicMaxWin; //!< last maximum cwnd 108 | double m_bicTargetWin; 109 | double m_bicSsCwnd; 110 | double m_bicSsTarget; 111 | bool m_isBicSs; //!< whether we are currently in the BIC slow start phase 112 | }; 113 | 114 | } // namespace ndn 115 | } // namespace ns3 116 | 117 | #endif // NDN_CONSUMER_PCON_H 118 | -------------------------------------------------------------------------------- /examples/ndn-simple.py: -------------------------------------------------------------------------------- 1 | ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- 2 | # 3 | # Copyright (c) 2011-2015 Regents of the University of California. 4 | # 5 | # This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | # contributors. 7 | # 8 | # ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | # of the GNU General Public License as published by the Free Software Foundation, 10 | # either version 3 of the License, or (at your option) any later version. 11 | # 12 | # ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | # PURPOSE. See the GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License along with 17 | # ndnSIM, e.g., in COPYING.md file. If not, see . 18 | # 19 | 20 | # ndn-simple.py 21 | 22 | from ns.core import * 23 | from ns.network import * 24 | from ns.point_to_point import * 25 | from ns.ndnSIM import * 26 | 27 | # 28 | # This scenario simulates a very simple network topology: 29 | # 30 | # 31 | # +----------+ 1Mbps +--------+ 1Mbps +----------+ 32 | # | consumer | <------------> | router | <------------> | producer | 33 | # +----------+ 10ms +--------+ 10ms +----------+ 34 | # 35 | # 36 | # Consumer requests data from producer with frequency 10 interests per second 37 | # (interests contain constantly increasing sequence number). 38 | # 39 | # For every received interest, producer replies with a data packet, containing 40 | # 1024 bytes of virtual payload. 41 | # 42 | # To run scenario and see what is happening, use the following command: 43 | # 44 | # NS_LOG=ndn.Consumer:ndn.Producer ./waf --pyrun=src/ndnSIM/examples/ndn-simple.py 45 | # 46 | 47 | # Set default parameters for PointToPoint links and channels 48 | Config.SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("10Mbps")) 49 | Config.SetDefault("ns3::PointToPointChannel::Delay", StringValue("10ms")) 50 | Config.SetDefault("ns3::DropTailQueue::MaxSize", StringValue("20p")) 51 | 52 | # Read optional command-line parameters (e.g., enable visualizer with ./waf --pyrun=<> --visualize 53 | import sys; cmd = CommandLine(); cmd.Parse(sys.argv); 54 | 55 | # Creating nodes 56 | nodes = NodeContainer() 57 | nodes.Create(3) 58 | 59 | # Connecting nodes using two links 60 | p2p = PointToPointHelper() 61 | p2p.Install(nodes.Get(0), nodes.Get(1)) 62 | p2p.Install(nodes.Get(1), nodes.Get(2)) 63 | 64 | # Install NDN stack on all nodes 65 | ndnHelper = ndn.StackHelper() 66 | ndnHelper.SetDefaultRoutes(True) 67 | ndnHelper.InstallAll() 68 | 69 | # Choosing forwarding strategy 70 | ndn.StrategyChoiceHelper.InstallAll("/prefix", "/localhost/nfd/strategy/multicast") 71 | 72 | # Installing applications 73 | 74 | # Consumer 75 | consumerHelper = ndn.AppHelper("ns3::ndn::ConsumerCbr") 76 | # Consumer will request /prefix/0, /prefix/1, ... 77 | consumerHelper.SetPrefix("/prefix") 78 | consumerHelper.SetAttribute("Frequency", StringValue("10")) # 10 interests a second 79 | consumerHelper.Install(nodes.Get(0)) # first node 80 | 81 | # Producer 82 | producerHelper = ndn.AppHelper("ns3::ndn::Producer") 83 | # Producer will reply to all requests starting with /prefix 84 | producerHelper.SetPrefix("/prefix") 85 | producerHelper.SetAttribute("PayloadSize", StringValue("1024")) 86 | producerHelper.Install(nodes.Get(2)) # last node 87 | 88 | Simulator.Stop(Seconds(20.0)) 89 | 90 | Simulator.Run() 91 | Simulator.Destroy() 92 | -------------------------------------------------------------------------------- /tests/unit-tests/helper/ndn-fib-helper.t.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "helper/ndn-fib-helper.hpp" 21 | 22 | #include "../tests-common.hpp" 23 | 24 | namespace ns3 { 25 | namespace ndn { 26 | 27 | BOOST_AUTO_TEST_SUITE(HelperNdnFibHelper) 28 | 29 | class AddRouteFixture : public ScenarioHelperWithCleanupFixture 30 | { 31 | public: 32 | AddRouteFixture() 33 | { 34 | createTopology({ 35 | {"1", "2"} 36 | }); 37 | 38 | addApps({ 39 | {"1", "ns3::ndn::ConsumerCbr", 40 | {{"Prefix", "/prefix"}, {"Frequency", "1"}}, 41 | "0s", "10.5s"}, 42 | {"2", "ns3::ndn::Producer", 43 | {{"Prefix", "/prefix"}, {"PayloadSize", "1024"}}, 44 | "0s", "100s"} 45 | }); 46 | } 47 | 48 | ~AddRouteFixture() 49 | { 50 | Simulator::Stop(Seconds(20.101)); 51 | Simulator::Run(); 52 | 53 | BOOST_CHECK_EQUAL(getFace("1", "2")->getCounters().nOutInterests, 10); 54 | BOOST_CHECK_EQUAL(getFace("1", "2")->getCounters().nInData, 10); 55 | 56 | BOOST_CHECK_EQUAL(getFace("2", "1")->getCounters().nInInterests, 10); 57 | BOOST_CHECK_EQUAL(getFace("2", "1")->getCounters().nOutData, 10); 58 | } 59 | }; 60 | 61 | BOOST_FIXTURE_TEST_SUITE(AddRoute, AddRouteFixture) 62 | 63 | // static void 64 | // AddRoute(Ptr node, const Name& prefix, shared_ptr face, int32_t metric); 65 | BOOST_AUTO_TEST_CASE(Base) 66 | { 67 | FibHelper::AddRoute(getNode("1"), Name("/prefix"), getFace("1", "2"), 1); 68 | } 69 | 70 | 71 | // static void 72 | // AddRoute(const std::string& nodeName, const Name& prefix, uint32_t faceId, int32_t metric); 73 | BOOST_AUTO_TEST_CASE(Helper1) 74 | { 75 | FibHelper::AddRoute("1", Name("/prefix"), getFace("1", "2")->getId(), 10); 76 | } 77 | 78 | // static void 79 | // AddRoute(Ptr node, const Name& prefix, uint32_t faceId, int32_t metric); 80 | BOOST_AUTO_TEST_CASE(Helper2) 81 | { 82 | FibHelper::AddRoute(getNode("1"), Name("/prefix"), getFace("1", "2")->getId(), 10); 83 | } 84 | 85 | // static void 86 | // AddRoute(const std::string& nodeName, const Name& prefix, const std::string& otherNodeName, 87 | // int32_t metric); 88 | BOOST_AUTO_TEST_CASE(Helper3) 89 | { 90 | FibHelper::AddRoute("1", "/prefix", "2", 1); 91 | } 92 | 93 | // static void 94 | // AddRoute(Ptr node, const Name& prefix, Ptr otherNode, int32_t metric); 95 | BOOST_AUTO_TEST_CASE(Helper4) 96 | { 97 | FibHelper::AddRoute(getNode("1"), Name("/prefix"), getNode("2"), 10); 98 | } 99 | 100 | BOOST_AUTO_TEST_SUITE_END() // AddRoute 101 | 102 | BOOST_AUTO_TEST_SUITE_END() // HelperNdnFibHelper 103 | 104 | } // namespace ndn 105 | } // namespace ns3 106 | -------------------------------------------------------------------------------- /helper/ndn-link-control-helper.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #ifndef NDN_LINK_CONTROL_HELPER_H 21 | #define NDN_LINK_CONTROL_HELPER_H 22 | 23 | #include "ns3/ndnSIM/model/ndn-common.hpp" 24 | 25 | #include "ns3/ptr.h" 26 | #include "ns3/node.h" 27 | 28 | namespace ns3 { 29 | namespace ndn { 30 | 31 | /** 32 | * @ingroup ndn-helpers 33 | * @brief Helper class to control the up or down statuss of an NDN link connecting two specific 34 | * nodes 35 | */ 36 | class LinkControlHelper { 37 | public: 38 | /** 39 | * @brief Fail NDN link between two nodes 40 | * 41 | * The helper will attempt to find NDN link between node1 and 42 | * node2 and set NDN face to DOWN state 43 | * 44 | * Note that only PointToPointChannels are supported by this helper method 45 | * 46 | * @param node1 one node 47 | * @param node2 another node 48 | */ 49 | static void 50 | FailLink(Ptr node1, Ptr node2); 51 | 52 | /** 53 | * @brief Fail NDN link between two nodes 54 | * 55 | * The helper will attempt to find NDN link between node1 and 56 | * node2 and set NDN face to DOWN state 57 | * 58 | * Note that only PointToPointChannels are supported by this helper method 59 | * 60 | * This variant uses node names registered by Names class 61 | * 62 | * @param node1 one node's name 63 | * @param node2 another node's name 64 | */ 65 | static void 66 | FailLinkByName(const std::string& node1, const std::string& node2); 67 | 68 | /** 69 | * @brief Re-enable NDN link between two nodes 70 | * 71 | * The helper will attempt to find NDN link between node1 and 72 | * node2 and set NDN face to UP state 73 | * 74 | * Note that only PointToPointChannels are supported by this helper method 75 | * 76 | * @param node1 one node 77 | * @param node2 another node 78 | */ 79 | static void 80 | UpLink(Ptr node1, Ptr node2); 81 | 82 | /** 83 | * @brief Re-enable NDN link between two nodes 84 | * 85 | * The helper will attempt to find NDN link between node1 and 86 | * node2 and set NDN face to UP state 87 | * 88 | * Note that only PointToPointChannels are supported by this helper method 89 | * 90 | * This variant uses node names registered by Names class 91 | * 92 | * @param node1 one node's name 93 | * @param node2 another node's name 94 | */ 95 | static void 96 | UpLinkByName(const std::string& node1, const std::string& node2); 97 | 98 | private: 99 | static void 100 | setErrorRate(Ptr node1, Ptr node2, double errorRate); 101 | }; // LinkControlHelper 102 | 103 | } // ndn 104 | } // ns3 105 | 106 | #endif // NDN_LINK_CONTROL_HELPER_H 107 | -------------------------------------------------------------------------------- /examples/ndn-simple-with-content-freshness/one-interest-requester.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | // dumb-requester.cpp 21 | 22 | #include "one-interest-requester.hpp" 23 | 24 | #include "ns3/ptr.h" 25 | #include "ns3/log.h" 26 | #include "ns3/simulator.h" 27 | #include "ns3/packet.h" 28 | #include "ns3/random-variable-stream.h" 29 | #include "ns3/string.h" 30 | 31 | NS_LOG_COMPONENT_DEFINE("OneInterestRequester"); 32 | 33 | namespace ns3 { 34 | 35 | NS_OBJECT_ENSURE_REGISTERED(OneInterestRequester); 36 | 37 | // register NS-3 type 38 | TypeId 39 | OneInterestRequester::GetTypeId() 40 | { 41 | static TypeId tid = 42 | TypeId("OneInterestRequester") 43 | .SetParent() 44 | .AddConstructor() 45 | 46 | .AddAttribute("Prefix", "Requested name", StringValue("/dumb-interest"), 47 | ndn::MakeNameAccessor(&OneInterestRequester::m_name), ndn::MakeNameChecker()); 48 | return tid; 49 | } 50 | 51 | OneInterestRequester::OneInterestRequester() 52 | : m_isRunning(false) 53 | { 54 | } 55 | 56 | // Processing upon start of the application 57 | void 58 | OneInterestRequester::StartApplication() 59 | { 60 | // initialize ndn::App 61 | ndn::App::StartApplication(); 62 | 63 | m_isRunning = true; 64 | Simulator::ScheduleNow(&OneInterestRequester::SendInterest, this); 65 | } 66 | 67 | // Processing when application is stopped 68 | void 69 | OneInterestRequester::StopApplication() 70 | { 71 | m_isRunning = false; 72 | // cleanup ndn::App 73 | ndn::App::StopApplication(); 74 | } 75 | 76 | void 77 | OneInterestRequester::SendInterest() 78 | { 79 | if (!m_isRunning) 80 | return; 81 | 82 | ///////////////////////////////////// 83 | // Sending one Interest packet out // 84 | ///////////////////////////////////// 85 | 86 | // Create and configure ndn::Interest 87 | auto interest = std::make_shared(m_name); 88 | Ptr rand = CreateObject(); 89 | interest->setNonce(rand->GetValue(0, std::numeric_limits::max())); 90 | interest->setInterestLifetime(ndn::time::seconds(1)); 91 | interest->setMustBeFresh(true); 92 | 93 | NS_LOG_DEBUG("Sending Interest packet for " << m_name); 94 | 95 | // Call trace (for logging purposes) 96 | m_transmittedInterests(interest, this, m_face); 97 | 98 | NS_LOG_DEBUG(">> I: " << m_name); 99 | 100 | // Forward packet to lower (network) layer 101 | m_appLink->onReceiveInterest(*interest); 102 | } 103 | 104 | void 105 | OneInterestRequester::OnData(std::shared_ptr data) 106 | { 107 | App::OnData(data); 108 | NS_LOG_DEBUG("<< D: " << data->getName()); 109 | } 110 | 111 | } // namespace ns3 112 | -------------------------------------------------------------------------------- /examples/ndn-simple-for-nrt-helper/requester-app.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2016 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "ns3/core-module.h" 21 | #include "ns3/ndnSIM/helper/ndn-stack-helper.hpp" 22 | #include "ns3/ndnSIM/apps/ndn-app.hpp" 23 | #include "ns3/ndnSIM/ndn-cxx/link.hpp" 24 | #include "ns3/ndnSIM/ndn-cxx/interest.hpp" 25 | 26 | NS_LOG_COMPONENT_DEFINE("RequesterApp"); 27 | 28 | namespace ns3 { 29 | namespace ndn { 30 | 31 | class RequesterApp : public App 32 | { 33 | public: 34 | static TypeId 35 | GetTypeId() 36 | { 37 | static TypeId tid = TypeId("RequesterApp") 38 | .SetParent() 39 | .AddConstructor() 40 | .AddAttribute("Name", "Name of data to request", 41 | StringValue("/data/name"), 42 | MakeNameAccessor(&RequesterApp::m_name), MakeNameChecker()) 43 | .AddAttribute("Delegation", "Delegation name to attach to Interest", 44 | StringValue("/"), 45 | MakeNameAccessor(&RequesterApp::getDelegation, &RequesterApp::setDelegation), MakeNameChecker()) 46 | ; 47 | 48 | return tid; 49 | } 50 | 51 | protected: 52 | virtual void 53 | StartApplication() override 54 | { 55 | App::StartApplication(); 56 | 57 | Simulator::Schedule(Seconds(1.0), &RequesterApp::sendInterest, this); 58 | } 59 | 60 | virtual void 61 | StopApplication() override 62 | { 63 | // do cleanup 64 | App::StopApplication(); 65 | m_face->close(); 66 | } 67 | 68 | private: 69 | void 70 | setDelegation(const Name& delegation) 71 | { 72 | m_delegation = delegation; 73 | 74 | m_link = ::ndn::Link(Name(m_name).append("/LINK")); 75 | m_link.addDelegation(m_delegation); 76 | ndn::StackHelper::getKeyChain().sign(m_link, ::ndn::security::SigningInfo(::ndn::security::SigningInfo::SIGNER_TYPE_SHA256)); 77 | 78 | NS_LOG_DEBUG("Created Link Object "<< m_link); 79 | } 80 | 81 | Name 82 | getDelegation() const 83 | { 84 | return m_delegation; 85 | } 86 | 87 | void 88 | sendInterest() 89 | { 90 | auto interest = make_shared(m_name); 91 | interest->setInterestLifetime(time::seconds(1)); 92 | if (m_delegation.size() > 0) { 93 | interest->setForwardingHint({m_link.getDelegationList().begin(), m_link.getDelegationList().end()}); 94 | } 95 | 96 | NS_LOG_DEBUG("Sending an Interest for "<< *interest); 97 | 98 | m_transmittedInterests(interest, this, m_face); 99 | m_appLink->onReceiveInterest(*interest); 100 | } 101 | 102 | private: 103 | Name m_name; 104 | Name m_delegation; 105 | ::ndn::Link m_link; 106 | }; 107 | 108 | NS_OBJECT_ENSURE_REGISTERED(RequesterApp); 109 | 110 | } // namespace ndn 111 | } // namespace ns3 112 | -------------------------------------------------------------------------------- /tests/unit-tests/NFD/ncc.t.cpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | #include "helper/ndn-strategy-choice-helper.hpp" 21 | 22 | #include "ns3/ndnSIM/NFD/daemon/fw/strategy.hpp" 23 | 24 | #include "../tests-common.hpp" 25 | 26 | namespace ns3 { 27 | namespace ndn { 28 | 29 | class NccFixture : public ScenarioHelperWithCleanupFixture 30 | { 31 | public: 32 | NccFixture() 33 | { 34 | Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("10Mbps")); 35 | Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("1ms")); 36 | Config::SetDefault("ns3::DropTailQueue::MaxSize", StringValue("500p")); 37 | 38 | // Creating a 3 node topology // 39 | // // 40 | // // 41 | // +----+ +----+ +----+ // 42 | // | | | | | | // 43 | // | A1 | <---> | A2 | <---> | A3 | // 44 | // | | | | | | // 45 | // +----+ +----+ +----+ // 46 | // // 47 | // // 48 | // // 49 | 50 | createTopology({ 51 | {"A1", "A2"}, 52 | {"A2", "A3"} 53 | }); 54 | 55 | addRoutes({ 56 | {"A1", "A2", "/prefix", 100}, 57 | {"A2", "A3", "/prefix", 100}, 58 | }); 59 | 60 | addApps({ 61 | {"A1", "ns3::ndn::ConsumerCbr", 62 | {{"Prefix", "/prefix"}, {"Frequency", "1000"}}, 63 | "0.1s", "1.1s"}, 64 | {"A3", "ns3::ndn::Producer", 65 | {{"Prefix", "/prefix"}, {"PayloadSize", "1024"}}, 66 | "0s", "10s"}, 67 | }); 68 | } 69 | }; 70 | 71 | BOOST_FIXTURE_TEST_SUITE(TestNccStrategy, NccFixture) 72 | 73 | BOOST_AUTO_TEST_CASE(DetachedPitEntries) 74 | { 75 | StrategyChoiceHelper::Install(getNode("A1"), "/prefix", "/localhost/nfd/strategy/ncc"); 76 | StrategyChoiceHelper::Install(getNode("A2"), "/prefix", "/localhost/nfd/strategy/ncc"); 77 | StrategyChoiceHelper::Install(getNode("A3"), "/prefix", "/localhost/nfd/strategy/ncc"); 78 | 79 | Simulator::Stop(Seconds(5.2)); 80 | BOOST_CHECK_NO_THROW(Simulator::Run()); 81 | 82 | BOOST_CHECK_EQUAL(getFace("A1", "A2")->getCounters().nOutInterests, 1000); 83 | BOOST_CHECK_EQUAL(getFace("A2", "A3")->getCounters().nOutInterests, 1000); 84 | 85 | BOOST_CHECK_EQUAL(getFace("A3", "A2")->getCounters().nOutData, 1000); 86 | BOOST_CHECK_EQUAL(getFace("A2", "A1")->getCounters().nOutData, 1000); 87 | } 88 | 89 | BOOST_AUTO_TEST_SUITE_END() 90 | 91 | } // namespace ndn 92 | } // namespace ns3 93 | -------------------------------------------------------------------------------- /utils/topology/rocketfuel-weights-reader.hpp: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /** 3 | * Copyright (c) 2011-2015 Regents of the University of California. 4 | * 5 | * This file is part of ndnSIM. See AUTHORS for complete list of ndnSIM authors and 6 | * contributors. 7 | * 8 | * ndnSIM is free software: you can redistribute it and/or modify it under the terms 9 | * of the GNU General Public License as published by the Free Software Foundation, 10 | * either version 3 of the License, or (at your option) any later version. 11 | * 12 | * ndnSIM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 13 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | * PURPOSE. See the GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along with 17 | * ndnSIM, e.g., in COPYING.md file. If not, see . 18 | **/ 19 | 20 | // Based on the code by Hajime Tazaki 21 | 22 | #ifndef ROCKETFUEL_TOPOLOGY_WEIGHTS_READER_H 23 | #define ROCKETFUEL_TOPOLOGY_WEIGHTS_READER_H 24 | 25 | #include "ns3/ndnSIM/utils/topology/annotated-topology-reader.hpp" 26 | #include "ns3/net-device-container.h" 27 | 28 | namespace ns3 { 29 | 30 | // ------------------------------------------------------------ 31 | // -------------------------------------------- 32 | /** 33 | * \brief Topology file reader (extension of Rocketfuel-format type). 34 | * 35 | * http://www.cs.washington.edu/research/networking/rocketfuel/ 36 | * 37 | * Only weights and latencies file is supported 38 | */ 39 | class RocketfuelWeightsReader : public AnnotatedTopologyReader { 40 | public: 41 | RocketfuelWeightsReader(const std::string& path = "", double scale = 1.0); 42 | virtual ~RocketfuelWeightsReader(); 43 | 44 | void 45 | SetFileType(uint8_t inputType); 46 | 47 | /** 48 | * \brief Main topology reading function. 49 | * 50 | * This method opens an input stream and reads the Rocketfuel-format file. 51 | * Every row represents a topology link (the ids of a couple of nodes), 52 | * so the input file is read line by line to figure out how many links 53 | * and nodes are in the topology. 54 | * 55 | * \return the container of the nodes created (or empty container if there was an error) 56 | */ 57 | virtual NodeContainer 58 | Read(void); 59 | 60 | void 61 | Commit(); 62 | 63 | enum { LINKS, WEIGHTS, LATENCIES, POSITIONS }; 64 | 65 | inline void 66 | SetDefaultBandwidth(const std::string& bw); 67 | 68 | inline std::string 69 | GetDefaultBandwidth() const; 70 | 71 | inline void 72 | SetDefaultQueue(const std::string& queue); 73 | 74 | inline std::string 75 | GetDefaultQueue() const; 76 | 77 | private: 78 | RocketfuelWeightsReader(const RocketfuelWeightsReader&); 79 | RocketfuelWeightsReader& 80 | operator=(const RocketfuelWeightsReader&); 81 | 82 | private: 83 | uint8_t m_inputType; 84 | std::string m_defaultBandwidth; // since the topology files don't provide bandwidth parameter 85 | std::string m_queue; 86 | 87 | }; // end class RocketfuelWeightsReader 88 | 89 | inline void 90 | RocketfuelWeightsReader::SetDefaultBandwidth(const std::string& bw) 91 | { 92 | m_defaultBandwidth = bw; 93 | } 94 | 95 | inline std::string 96 | RocketfuelWeightsReader::GetDefaultBandwidth() const 97 | { 98 | return m_defaultBandwidth; 99 | } 100 | 101 | inline void 102 | RocketfuelWeightsReader::SetDefaultQueue(const std::string& queue) 103 | { 104 | m_queue = queue; 105 | } 106 | 107 | inline std::string 108 | RocketfuelWeightsReader::GetDefaultQueue() const 109 | { 110 | return m_queue; 111 | } 112 | 113 | } // end namespace ns3 114 | 115 | #endif /* ROCKETFUEL_TOPOLOGY_WEIGHTS_READER_H */ 116 | --------------------------------------------------------------------------------