Added cube topology
authorRichard Whitehouse <github@richardwhiuk.com>
Mon, 14 Mar 2011 14:23:51 +0000 (14:23 +0000)
committerRichard Whitehouse <github@richardwhiuk.com>
Mon, 14 Mar 2011 14:23:51 +0000 (14:23 +0000)
code/src/topology/helper/cube.cc [new file with mode: 0644]
code/src/topology/helper/cube.h [new file with mode: 0644]
code/src/topology/wscript

diff --git a/code/src/topology/helper/cube.cc b/code/src/topology/helper/cube.cc
new file mode 100644 (file)
index 0000000..58e5b4c
--- /dev/null
@@ -0,0 +1,74 @@
+/* -*-  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 "cube.h"
+#include "ns3/log.h"
+
+NS_LOG_COMPONENT_DEFINE ("Cube_Topology_Helper");
+
+namespace ns3 {
+
+Topology Cube_Topology_Helper::Create(long hosts, long size){
+
+       Topology t;
+
+       t.bridges = size * size * size;
+
+       t.hosts = t.bridges * hosts;
+
+       long i; long j; long k;
+
+       for(i = 0; i < t.bridges; ++i){
+               for(j = 0; j < hosts; ++j){
+                       t.hostLinks[(i*hosts) + j] = i;
+               }
+       }
+
+       for(i = 0; i < size; ++i){
+               for(j = 0; j < size; ++j){
+                       for(k = 0; k < size; ++k){
+                               // Three links  
+                               
+                               // number of node = (i * size * size) + (j * size) + k
+
+                               long me = (i * size * size) + (j * size) + k;
+
+                               if((k + 1) < size){
+                                       t.bridgeLinks.insert(std::make_pair<long,long>(me, ((i * size * size) + (j * size) + k + 1) ));
+                               }
+
+                               if((j + 1) < size){
+                                       t.bridgeLinks.insert(std::make_pair<long,long>(me, ((i * size * size) + ((j + 1) * size) + k) ));
+                               }
+
+                               if((i + 1) < size){
+                                       t.bridgeLinks.insert(std::make_pair<long,long>(me, (((i + 1) * size * size) + (j * size) + k) ));
+                               }
+                       }
+               }       
+       }
+
+       return t;
+
+}
+
+
+}
+
diff --git a/code/src/topology/helper/cube.h b/code/src/topology/helper/cube.h
new file mode 100644 (file)
index 0000000..aad371f
--- /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_CUBE_H
+#define TOPOLOGY_CUBE_H
+
+#include "ns3/topology.h"
+
+namespace ns3 {
+
+class Cube_Topology_Helper {
+       
+public:
+
+       Topology Create(long hosts, long size); 
+
+};
+
+}
+
+#endif
+
index 5ebd5a7647e5d27a6e33c5d914482a5c5f9da874..6ea3ee6c7964e9ff48d90c6c8ecc880e6aac41c5 100644 (file)
@@ -3,11 +3,13 @@
 def build(bld):
     obj = bld.create_ns3_module('topology', ['node'])
     obj.source = [
-       'model/topology.cc'
+       'model/topology.cc',
+       'helper/cube.cc'
         ]
     headers = bld.new_task_gen('ns3header')
     headers.module = 'topology'
     headers.source = [
-       'model/topology.h'
+       'model/topology.h',
+       'helper/cube.h'
         ]