initial import for dce submodule draft default tip
authorHajime Tazaki <tazaki@nict.go.jp>
Tue, 12 Mar 2013 12:03:42 +0900
changeset 0 2661206e024b
initial import for dce submodule
.hgignore
doc/Makefile
doc/source/conf.py
doc/source/index.rst
example/dce-submod-simple.cc
example/examples-to-run.py
helper/dce-submod-helper.cc
helper/dce-submod-helper.h
test/dce-submod-test.cc
waf
wscript
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Tue Mar 12 12:03:42 2013 +0900
@@ -0,0 +1,14 @@
+\.rej$
+\.orig$
+\.o$
+~$
+^build
+^objdir
+^elf-cache
+^files-
+^.waf-
+^.lock-
+pcap
+^doc/build
+testpy-output
+\.pyc$
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/Makefile	Tue Mar 12 12:03:42 2013 +0900
@@ -0,0 +1,153 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = build
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html       to make standalone HTML files"
+	@echo "  dirhtml    to make HTML files named index.html in directories"
+	@echo "  singlehtml to make a single large HTML file"
+	@echo "  pickle     to make pickle files"
+	@echo "  json       to make JSON files"
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
+	@echo "  qthelp     to make HTML files and a qthelp project"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+	@echo "  text       to make text files"
+	@echo "  man        to make manual pages"
+	@echo "  texinfo    to make Texinfo files"
+	@echo "  info       to make Texinfo files and run them through makeinfo"
+	@echo "  gettext    to make PO message catalogs"
+	@echo "  changes    to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck  to check all external links for integrity"
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	-rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/DCEsubmodule.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/DCEsubmodule.qhc"
+
+devhelp:
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/DCEsubmodule"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/DCEsubmodule"
+	@echo "# devhelp"
+
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+	@echo "Run \`make' in that directory to run these through makeinfo" \
+	      "(use \`make info' here to do that automatically)."
+
+info:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo "Running Texinfo files through makeinfo..."
+	make -C $(BUILDDIR)/texinfo info
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/source/conf.py	Tue Mar 12 12:03:42 2013 +0900
@@ -0,0 +1,242 @@
+# -*- coding: utf-8 -*-
+#
+# DCE submodule documentation build configuration file, created by
+# sphinx-quickstart on Tue Mar 12 11:59:39 2013.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = []
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'DCE submodule'
+copyright = u'2013, Hajime Tazaki'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '1.0'
+# The full version, including alpha/beta/rc tags.
+release = '1.0'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = []
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+html_theme = 'sphinxdoc'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'DCEsubmoduledoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'DCEsubmodule.tex', u'DCE submodule Documentation',
+   u'Hajime Tazaki', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('index', 'dcesubmodule', u'DCE submodule Documentation',
+     [u'Hajime Tazaki'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  ('index', 'DCEsubmodule', u'DCE submodule Documentation',
+   u'Hajime Tazaki', 'DCEsubmodule', 'One line description of project.',
+   'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/source/index.rst	Tue Mar 12 12:03:42 2013 +0900
@@ -0,0 +1,22 @@
+.. DCE submodule documentation master file, created by
+   sphinx-quickstart on Tue Mar 12 11:59:39 2013.
+   You can adapt this file completely to your liking, but it should at least
+   contain the root `toctree` directive.
+
+Welcome to DCE submodule's documentation!
+=========================================
+
+Contents:
+
+.. toctree::
+   :maxdepth: 2
+
+
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/dce-submod-simple.cc	Tue Mar 12 12:03:42 2013 +0900
@@ -0,0 +1,31 @@
+#include "ns3/network-module.h"
+#include "ns3/core-module.h"
+#include "ns3/internet-module.h"
+#include "ns3/dce-module.h"
+#include "ns3/dce-submod-module.h"
+
+using namespace ns3;
+
+int main (int argc, char *argv[])
+{
+  CommandLine cmd;
+  cmd.Parse (argc, argv);
+
+  NodeContainer nodes;
+  nodes.Create (1);
+
+  InternetStackHelper stack;
+  stack.Install (nodes);
+
+  DceManagerHelper dceManager;
+  dceManager.Install (nodes);
+
+  DceSubModuleHelper sub;
+  sub.Install (nodes.Get (0));
+
+  Simulator::Stop (Seconds (100.0));
+  Simulator::Run ();
+  Simulator::Destroy ();
+
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example/examples-to-run.py	Tue Mar 12 12:03:42 2013 +0900
@@ -0,0 +1,20 @@
+#! /usr/bin/env python
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+# A list of C++ examples to run in order to ensure that they remain
+# buildable and runnable over time.  Each tuple in the list contains
+#
+#     (example_name, do_run, do_valgrind_run).
+#
+# See test.py for more information.
+cpp_examples = [
+    ("some-your-example", "True", "True"),
+]
+
+# A list of Python examples to run in order to ensure that they remain
+# runnable over time.  Each tuple in the list contains
+#
+#     (example_name, do_run).
+#
+# See test.py for more information.
+python_examples = []
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/helper/dce-submod-helper.cc	Tue Mar 12 12:03:42 2013 +0900
@@ -0,0 +1,177 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2013 Hajime Tazaki, NICT
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Hajime Tazaki <tazaki@nict.go.jp>
+ */
+
+#include "ns3/object-factory.h"
+#include "ns3/names.h"
+#include "ns3/log.h"
+#include "dce-submod-helper.h"
+#include <sys/stat.h>
+#include <fstream>
+
+NS_LOG_COMPONENT_DEFINE ("DceSubModuleHelper");
+
+namespace ns3 {
+
+class DceSubModuleConfig : public Object
+{
+private:
+  static int index;
+  std::string router_id;
+  std::map<std::string, uint32_t> *networks;
+public:
+  DceSubModuleConfig ()
+  {
+  }
+  ~DceSubModuleConfig ()
+  {
+  }
+
+  static TypeId
+  GetTypeId (void)
+  {
+    static TypeId tid = TypeId ("ns3::DceSubModuleConfig")
+      .SetParent<Object> ()
+      .AddConstructor<DceSubModuleConfig> ()
+    ;
+    return tid;
+  }
+  TypeId
+  GetInstanceTypeId (void) const
+  {
+    return GetTypeId ();
+  }
+
+  void
+  SetFilename (const std::string &filename)
+  {
+    m_filename = filename;
+  }
+
+  std::string
+  GetFilename () const
+  {
+    return m_filename;
+  }
+
+  std::string m_filename;
+
+  virtual void
+  Print (std::ostream& os) const
+  {
+    os << "hostname localhost" << std::endl
+       << "password deadbeaf" << std::endl
+       << "log stdout" << std::endl;
+  }
+};
+std::ostream& operator << (std::ostream& os, DceSubModuleConfig const& config)
+{
+  config.Print (os);
+  return os;
+}
+
+
+DceSubModuleHelper::DceSubModuleHelper ()
+{
+}
+
+void
+DceSubModuleHelper::SetAttribute (std::string name, const AttributeValue &value)
+{
+}
+
+
+void
+DceSubModuleHelper::GenerateConfig (Ptr<Node> node)
+{
+  Ptr<DceSubModuleConfig> conf = node->GetObject<DceSubModuleConfig> ();
+
+  // config generation
+  std::stringstream conf_dir, conf_file;
+  // FIXME XXX
+  conf_dir << "files-" << node->GetId () << "";
+  ::mkdir (conf_dir.str ().c_str (), S_IRWXU | S_IRWXG);
+  conf_dir << "/usr/";
+  ::mkdir (conf_dir.str ().c_str (), S_IRWXU | S_IRWXG);
+  conf_dir << "/local/";
+  ::mkdir (conf_dir.str ().c_str (), S_IRWXU | S_IRWXG);
+  conf_dir << "/etc/";
+  ::mkdir (conf_dir.str ().c_str (), S_IRWXU | S_IRWXG);
+
+  conf_file << conf_dir.str () << "/sample_app.conf";
+  conf->SetFilename ("/usr/local/etc/sample_app.conf");
+
+  std::ofstream conff;
+  conff.open (conf_file.str ().c_str ());
+  conff << *conf;
+
+  conff << "additional config 1: True" << std::endl;
+
+  conff.close ();
+}
+
+ApplicationContainer
+DceSubModuleHelper::Install (Ptr<Node> node)
+{
+  return ApplicationContainer (InstallPriv (node));
+}
+
+ApplicationContainer
+DceSubModuleHelper::Install (std::string nodeName)
+{
+  Ptr<Node> node = Names::Find<Node> (nodeName);
+  return ApplicationContainer (InstallPriv (node));
+}
+
+ApplicationContainer
+DceSubModuleHelper::Install (NodeContainer c)
+{
+  ApplicationContainer apps;
+  for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
+    {
+      apps.Add (InstallPriv (*i));
+    }
+
+  return apps;
+}
+
+ApplicationContainer
+DceSubModuleHelper::InstallPriv (Ptr<Node> node)
+{
+  DceApplicationHelper process;
+  ApplicationContainer apps;
+
+  Ptr<DceSubModuleConfig> conf = node->GetObject<DceSubModuleConfig> ();
+  if (!conf)
+    {
+      conf = new DceSubModuleConfig ();
+      node->AggregateObject (conf);
+    }
+  GenerateConfig (node);
+  process.SetBinary ("sample_app");
+  process.AddArguments ("-f", conf->GetFilename ());
+  process.SetStackSize (1 << 16);
+  apps.Add (process.Install (node));
+  apps.Get (0)->SetStartTime (Seconds (1.0 + 0.01 * node->GetId ()));
+  node->AddApplication (apps.Get (0));
+
+  return apps;
+}
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/helper/dce-submod-helper.h	Tue Mar 12 12:03:42 2013 +0900
@@ -0,0 +1,94 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2013 Hajime Tazaki, NICT
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Hajime Tazaki <tazaki@sfc.wide.ad.jp>
+ */
+#ifndef QUAGGA_HELPER_H
+#define QUAGGA_HELPER_H
+
+#include "ns3/dce-manager-helper.h"
+#include "ns3/dce-application-helper.h"
+
+namespace ns3 {
+
+/**
+ * \brief create a sample application daemon as an application and associate it to a node
+ *
+ * This class creates one or multiple instances of ns3::SampleApplication and associates
+ * it/them to one/multiple node(s).
+ */
+class DceSubModuleHelper
+{
+public:
+  /**
+   * Create a DceSubModuleHelper which is used to make life easier for people wanting
+   * to use quagga Applications.
+   *
+   */
+  DceSubModuleHelper ();
+
+  /**
+   * Install a quagga application on each Node in the provided NodeContainer.
+   *
+   * \param nodes The NodeContainer containing all of the nodes to get a quagga
+   *              application via ProcessManager.
+   *
+   * \returns A list of quagga applications, one for each input node
+   */
+  ApplicationContainer Install (NodeContainer nodes);
+
+  /**
+   * Install a quagga application on the provided Node.  The Node is specified
+   * directly by a Ptr<Node>
+   *
+   * \param node The node to install the DceSubModuleApplication on.
+   *
+   * \returns An ApplicationContainer holding the quagga application created.
+   */
+  ApplicationContainer Install (Ptr<Node> node);
+
+  /**
+   * Install a quagga application on the provided Node.  The Node is specified
+   * by a string that must have previosly been associated with a Node using the
+   * Object Name Service.
+   *
+   * \param nodeName The node to install the ProcessApplication on.
+   *
+   * \returns An ApplicationContainer holding the quagga application created.
+   */
+  ApplicationContainer Install (std::string nodeName);
+
+  /**
+   * \brief Configure ping applications attribute
+   *
+   * \param name   attribute's name
+   * \param value  attribute's value
+   */
+  void SetAttribute (std::string name, const AttributeValue &value);
+
+
+private:
+  /**
+   * \internal
+   */
+  ApplicationContainer InstallPriv (Ptr<Node> node);
+  void GenerateConfig (Ptr<Node> node);
+};
+
+} // namespace ns3
+
+#endif /* QUAGGA_HELPER_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/dce-submod-test.cc	Tue Mar 12 12:03:42 2013 +0900
@@ -0,0 +1,310 @@
+/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2013 Hajime Tazaki, NICT
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Hajime Tazaki <tazaki@nict.go.jp>
+ */
+
+#include "ns3/network-module.h"
+#include "ns3/core-module.h"
+#include "ns3/internet-module.h"
+#include "ns3/dce-module.h"
+#include "ns3/dce-submod-helper.h"
+#include "ns3/csma-helper.h"
+#include "ns3/v4ping.h"
+#include "ns3/ping6.h"
+#include "ns3/ethernet-header.h"
+#include "ns3/icmpv4.h"
+
+#define OUTPUT(x)                                                       \
+  {                                                                     \
+    std::ostringstream oss;                                             \
+    oss << "file=" << __FILE__ << " line=" << __LINE__ << " "           \
+        << x << std::endl;                                              \
+    std::string s = oss.str ();                                         \
+    std::cerr << s.c_str ();                                            \
+  }
+
+
+static std::string g_testError;
+
+extern "C" void dce_manager_test_store_test_error (const char *s)
+{
+  g_testError = s;
+}
+
+using namespace ns3;
+namespace ns3 {
+
+static void RunIp (Ptr<Node> node, Time at, std::string str)
+{
+  DceApplicationHelper process;
+  ApplicationContainer apps;
+  process.SetBinary ("ip");
+  process.SetStackSize (1 << 16);
+  process.ResetArguments ();
+  process.ParseArguments (str.c_str ());
+  apps = process.Install (node);
+  apps.Start (at);
+}
+
+static void AddAddress (Ptr<Node> node, Time at, const char *name, const char *address)
+{
+  std::ostringstream oss;
+  oss << "-f inet6 addr add " << address << " dev " << name;
+  RunIp (node, at, oss.str ());
+}
+
+class DceDceSubModuleTestCase : public TestCase
+{
+public:
+  DceDceSubModuleTestCase (std::string testname, Time maxDuration, bool useK, bool skip);
+  void CsmaRxCallback (std::string context, Ptr<const Packet> packet);
+private:
+  virtual void DoRun (void);
+  static void Finished (int *pstatus, uint16_t pid, int status);
+
+  std::string m_testname;
+  Time m_maxDuration;
+  bool m_useKernel;
+  bool m_pingStatus;
+  bool m_debug;
+  bool m_skip;
+};
+
+void
+DceDceSubModuleTestCase::CsmaRxCallback (std::string context, Ptr<const Packet> originalPacket)
+{
+  if (m_pingStatus)
+    {
+      return;
+    }
+  uint16_t protocol;
+  Ptr<Packet> packet = originalPacket->Copy ();
+  EthernetHeader header (false);
+  packet->RemoveHeader (header);
+  protocol = header.GetLengthType ();
+  Ipv4Header v4hdr;
+  Icmpv4Header icmphdr;
+  Ipv6Header v6hdr;
+  Icmpv6Header icmp6hdr;
+  switch (protocol)
+    {
+    case 0x0800:   //IPv4
+      packet->RemoveHeader (v4hdr);
+      packet->RemoveHeader (icmphdr);
+      if (icmphdr.GetType () == Icmpv4Header::ECHO_REPLY)
+        {
+          m_pingStatus = true;
+        }
+      break;
+    case 0x86DD:   //IPv6
+      packet->RemoveHeader (v6hdr);
+      packet->RemoveHeader (icmp6hdr);
+      if (icmp6hdr.GetType () == Icmpv6Header::ICMPV6_ECHO_REPLY)
+        {
+          m_pingStatus = true;
+        }
+      break;
+    default:
+      break;
+    }
+
+  //  std::cout << context << " " << packet << " protocol " << protocol << std::endl;
+}
+
+DceDceSubModuleTestCase::DceDceSubModuleTestCase (std::string testname, Time maxDuration, bool useK, bool skip)
+  : TestCase (skip ? "(SKIP) " + testname + (useK ? " (kernel)" : " (ns3)") : "" "Check that process \"" + testname
+              + (useK ? " (kernel)" : " (ns3)") + "\" completes correctly."),
+    m_testname (testname),
+    m_maxDuration (maxDuration),
+    m_useKernel (useK),
+    m_pingStatus (false),
+    m_debug (false),
+    m_skip (skip)
+{
+}
+void
+DceDceSubModuleTestCase::Finished (int *pstatus, uint16_t pid, int status)
+{
+  *pstatus = status;
+}
+void
+DceDceSubModuleTestCase::DoRun (void)
+{
+  if (m_skip)
+    {
+      return;
+    }
+
+  //
+  //  Step 1
+  //  Node Basic Configuration
+  //
+  std::string routerPort;
+
+  NodeContainer nodes;
+  nodes.Create (2);
+
+  CsmaHelper csma;
+
+  NetDeviceContainer devices, dev1, dev2;
+  devices = csma.Install (nodes);
+  dev1 = csma.Install (nodes.Get (0));
+  dev2 = csma.Install (nodes.Get (1));
+  DceManagerHelper processManager;
+
+  //  processManager.SetLoader ("ns3::DlmLoaderFactory");
+  processManager.SetTaskManagerAttribute ("FiberManagerType",
+                                          EnumValue (0));
+  //
+  // Step 2
+  // Address Configuration
+  //
+  //
+  if (m_useKernel == false)
+    {
+      Ipv4AddressHelper ipv4AddrHelper;
+      Ipv6AddressHelper ipv6AddrHelper;
+      // Internet stack install
+      InternetStackHelper stack;    // IPv4 is required for GlobalRouteMan
+      Ipv4DceRoutingHelper ipv4RoutingHelper;
+      stack.SetRoutingHelper (ipv4RoutingHelper);
+      stack.Install (nodes);
+
+      ipv4AddrHelper.SetBase ("10.0.0.0", "255.255.255.0");
+      ipv4AddrHelper.Assign (devices);
+      ipv6AddrHelper.NewNetwork ("2001:db8:0:1::", Ipv6Prefix (64));
+      ipv6AddrHelper.Assign (devices);
+
+      ipv4AddrHelper.SetBase ("11.0.0.0", "255.255.255.0");
+      ipv4AddrHelper.Assign (dev1);
+      ipv6AddrHelper.NewNetwork ("2001:db8:0:2::", Ipv6Prefix (64));
+      ipv6AddrHelper.Assign (dev1);
+
+      ipv4AddrHelper.SetBase ("12.0.0.0", "255.255.255.0");
+      ipv4AddrHelper.Assign (dev2);
+      ipv6AddrHelper.NewNetwork ("2001:db8:0:3::", Ipv6Prefix (64));
+      ipv6AddrHelper.Assign (dev2);
+
+      processManager.SetNetworkStack ("ns3::Ns3SocketFdFactory");
+      processManager.Install (nodes);
+
+      routerPort = "ns3-device0";
+      if (m_debug)
+        {
+          Ptr<OutputStreamWrapper> routingStream = Create<OutputStreamWrapper> ("routes-" + m_testname + ".log", std::ios::out);
+          ipv4RoutingHelper.PrintRoutingTableAllEvery (Seconds (10), routingStream);
+        }
+    }
+  else if (m_useKernel == true)
+    {
+      processManager.SetNetworkStack ("ns3::LinuxSocketFdFactory",
+                                      "Library", StringValue ("liblinux.so"));
+      processManager.Install (nodes);
+
+      // IP address configuration
+      AddAddress (nodes.Get (0), Seconds (0.1), "sim0", "2001:db8:0:1::1/64");
+      AddAddress (nodes.Get (0), Seconds (0.1), "sim1", "2001:db8:0:2::1/64");
+      RunIp (nodes.Get (0), Seconds (0.11), "-f inet addr add 10.0.0.1/24 dev sim0");
+      RunIp (nodes.Get (0), Seconds (0.11), "-f inet addr add 11.0.0.1/24 dev sim1");
+      RunIp (nodes.Get (0), Seconds (0.11), "link set lo up");
+      RunIp (nodes.Get (0), Seconds (0.11), "link set sim0 up");
+      RunIp (nodes.Get (0), Seconds (0.11), "link set sim1 up");
+
+      AddAddress (nodes.Get (1), Seconds (0.1), "sim0", "2001:db8:0:1::2/64");
+      AddAddress (nodes.Get (1), Seconds (0.1), "sim1", "2001:db8:0:3::2/64");
+      RunIp (nodes.Get (1), Seconds (0.11), "-f inet addr add 10.0.0.2/24 dev sim0");
+      RunIp (nodes.Get (1), Seconds (0.11), "-f inet addr add 12.0.0.1/24 dev sim1");
+      RunIp (nodes.Get (1), Seconds (0.11), "link set lo up");
+      RunIp (nodes.Get (1), Seconds (0.11), "link set sim0 up");
+      RunIp (nodes.Get (1), Seconds (0.11), "link set sim1 up");
+      if (m_debug)
+        {
+          RunIp (nodes.Get (0), Seconds (0.2), "link show");
+          RunIp (nodes.Get (0), Seconds (60.3), "route show table all");
+          RunIp (nodes.Get (1), Seconds (60.3), "route show table all");
+          RunIp (nodes.Get (0), Seconds (0.4), "addr list");
+        }
+
+      routerPort = "sim0";
+    }
+  DceSubModuleHelper submod;
+  submod.Install (nodes);
+
+  if (m_debug)
+    {
+      csma.EnablePcapAll ("dce-submodule-test-" + m_testname + "-" + (m_useKernel ? "kern" : "ns3"));
+    }
+
+  //
+  // Step 3
+  // Set up test application if you have
+  //
+
+  //
+  // Step 4
+  // Now It's ready to GO!
+  //
+  if (m_maxDuration.IsStrictlyPositive ())
+    {
+      Simulator::Stop (m_maxDuration);
+    }
+  Simulator::Run ();
+  Simulator::Destroy ();
+
+
+  //
+  // Step 5
+  // Vetify the test
+  //
+  NS_TEST_ASSERT_MSG_EQ (m_pingStatus, true, "DceSubModule test " << m_testname  << " with " <<
+                         (m_useKernel ? "kernel" : "ns3") << " did not return successfully: " << g_testError);
+}
+
+static class DceDceSubModuleTestSuite : public TestSuite
+{
+public:
+  DceDceSubModuleTestSuite ();
+private:
+} g_processTests;
+//
+
+
+DceDceSubModuleTestSuite::DceDceSubModuleTestSuite ()
+  : TestSuite ("dce-submodule", UNIT)
+{
+  typedef struct
+  {
+    const char *name;
+    int duration;
+    bool useKernel;
+  } testPair;
+
+  const testPair tests[] = {
+    { "test1", 120, false},
+    { "test2", 120, false},
+  };
+ 
+  for (unsigned int i = 0; i < sizeof(tests) / sizeof(testPair); i++)
+    {
+      AddTestCase (new DceDceSubModuleTestCase (std::string (tests[i].name),
+                                                Seconds (tests[i].duration), tests[i].useKernel,
+                                                tests[i].useKernel));
+    }
+}
+
+} // namespace ns3
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/waf	Tue Mar 12 12:03:42 2013 +0900
@@ -0,0 +1,2 @@
+exec "`dirname "$0"`"/../../waf "$@"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/wscript	Tue Mar 12 12:03:42 2013 +0900
@@ -0,0 +1,66 @@
+## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
+
+import os
+import Options
+import os.path
+import ns3waf
+import sys
+# local modules
+
+
+def options(opt):
+    opt.tool_options('compiler_cc') 
+    ns3waf.options(opt)
+
+def configure(conf):
+    ns3waf.check_modules(conf, ['core', 'network', 'internet'], mandatory = True)
+    ns3waf.check_modules(conf, ['point-to-point', 'tap-bridge', 'netanim'], mandatory = False)
+    ns3waf.check_modules(conf, ['wifi', 'point-to-point', 'csma', 'mobility'], mandatory = False)
+    ns3waf.check_modules(conf, ['point-to-point-layout'], mandatory = False)
+    ns3waf.check_modules(conf, ['topology-read', 'applications', 'visualizer'], mandatory = False)
+    conf.check_tool('compiler_cc')
+
+    conf.env.append_value('CXXFLAGS', '-I/usr/include/python2.6')
+    conf.env.append_value('LINKFLAGS', '-pthread')
+    conf.check (lib='dl', mandatory = True)
+
+    conf.env['ENABLE_PYTHON_BINDINGS'] = True
+    conf.env['NS3_ENABLED_MODULES'] = []
+    ns3waf.print_feature_summary(conf)
+
+
+
+def build_dce_tests(module, bld):
+    module.add_runner_test(needed=['core', 'dce-submod', 'internet', 'csma'],
+                           source=['test/dce-submod-test.cc'])
+
+def build_dce_examples(module):
+    dce_examples = [
+                   ]
+    for name,lib in dce_examples:
+        module.add_example(**dce_kw(target = 'bin/' + name, 
+                                    source = ['example/' + name + '.cc'],
+                                    lib = lib))
+
+    module.add_example(needed = ['core', 'internet', 'dce-submod', 'point-to-point'],
+                       target='bin/dce-submod-simple',
+                       source=['example/dce-submod-simple.cc'])
+
+def build(bld):
+    module_source = [
+        'helper/dce-submod-helper.cc',
+        ]
+    module_headers = [
+        'helper/dce-submod-helper.h',
+        ]
+    module_source = module_source
+    module_headers = module_headers
+    uselib = ns3waf.modules_uselib(bld, ['core', 'network', 'internet', 'netlink', 'dce'])
+    module = ns3waf.create_module(bld, name='dce-submod',
+                                  source=module_source,
+                                  headers=module_headers,
+                                  use=uselib,
+                                  lib=['dl'])
+
+    build_dce_tests(module,bld)
+    build_dce_examples(module)