Add Tree Topology
authorRichard Whitehouse <github@richardwhiuk.com>
Tue, 3 May 2011 09:50:10 +0000 (10:50 +0100)
committerRichard Whitehouse <github@richardwhiuk.com>
Tue, 3 May 2011 09:50:10 +0000 (10:50 +0100)
src/simulation/generator.cc
src/topology/helper/tree.cc [new file with mode: 0644]
src/topology/helper/tree.h [new file with mode: 0644]
src/topology/wscript

index b52b92e14347c10c6f02a7ac497875f87f11ad4f..d9091996540878f7b596a742b018f196f145077a 100644 (file)
@@ -39,7 +39,7 @@ try {
 
        CommandLine cmd;                        // Allow CommandLine args
        cmd.AddValue("file", "Output file", file);
-       cmd.AddValue("type", "Network Topology (cube|mesh|torus)", type);
+       cmd.AddValue("type", "Network Topology (cube|mesh|tree|torus)", type);
        cmd.AddValue("size", "Network size", size);
        cmd.AddValue("hosts", "Hosts per switch", hosts);
        cmd.Parse (argc, argv);
@@ -60,6 +60,8 @@ try {
                t = MeshTopologyHelper::Create(hosts, size);
        } else if(type == "torus"){
                t = TorusTopologyHelper::Create(hosts, size);
+       } else if(type == "tree"){
+               t = TreeTopologyHelper::Create(hosts, size);
        } else {
                throw new std::runtime_error("Unknown network topology type");
        } 
diff --git a/src/topology/helper/tree.cc b/src/topology/helper/tree.cc
new file mode 100644 (file)
index 0000000..87d065c
--- /dev/null
@@ -0,0 +1,54 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008,2009 IITP RAS
+ *
+ * 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: Richard Whitehouse <ns3@richardwhiuk.com>
+ */
+
+#include "tree.h"
+#include "ns3/log.h"
+
+NS_LOG_COMPONENT_DEFINE ("TreeTopologyHelper");
+
+namespace ns3 {
+
+Topology TreeTopologyHelper::Create(long hosts, long size){
+
+       Topology t;
+
+       t.bridges = size + 1;
+
+       t.hosts = size * hosts;
+
+       long i; long j; long k;
+
+       for(i = 0; i < size; ++i){
+               for(j = 0; j < hosts; ++j){
+                       t.hostLinks[(i*hosts) + j] = i + 1;
+               }
+       }
+
+       for(i = 0; i < size; ++i){
+               t.bridgeLinks.insert(std::make_pair<long,long>(0,i+1));
+       }
+
+       return t;
+
+}
+
+
+}
+
diff --git a/src/topology/helper/tree.h b/src/topology/helper/tree.h
new file mode 100644 (file)
index 0000000..4726ce3
--- /dev/null
@@ -0,0 +1,39 @@
+/* -*-  Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
+/*
+ * Copyright (c) 2008,2009 IITP RAS
+ *
+ * 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: Richard Whitehouse <ns3@richardwhiuk.com>
+ */
+
+#ifndef TOPOLOGY_TREE_H
+#define TOPOLOGY_TREE_H
+
+#include "ns3/topology.h"
+
+namespace ns3 {
+
+class TreeTopologyHelper {
+       
+public:
+
+       Topology static Create(long hosts, long size);  
+
+};
+
+}
+
+#endif
+
index 63c65de1be2c4397d9e0e1ce8891db8ef3c51997..1aee31dc09bc52bfe5e0728100fa49ecd3b56a4a 100644 (file)
@@ -6,6 +6,7 @@ def build(bld):
        'model/topology.cc',
        'helper/cube.cc',
        'helper/torus.cc',
+       'helper/tree.cc',
        'helper/mesh.cc'
         ]
     headers = bld.new_task_gen('ns3header')
@@ -14,6 +15,7 @@ def build(bld):
        'model/topology.h',
        'helper/cube.h',
        'helper/torus.h',
+       'helper/tree.h',
        'helper/mesh.h'
         ]