From 72e521e160d811dbf1acf3349134a26cc237ce20 Mon Sep 17 00:00:00 2001 From: Richard Whitehouse Date: Mon, 14 Mar 2011 15:00:13 +0000 Subject: [PATCH] Added mesh topology --- code/src/topology/helper/mesh.cc | 56 ++++++++++++++++++++++++++++++++ code/src/topology/helper/mesh.h | 39 ++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 code/src/topology/helper/mesh.cc create mode 100644 code/src/topology/helper/mesh.h diff --git a/code/src/topology/helper/mesh.cc b/code/src/topology/helper/mesh.cc new file mode 100644 index 0000000..0162947 --- /dev/null +++ b/code/src/topology/helper/mesh.cc @@ -0,0 +1,56 @@ +/* -*- 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 + */ + +#include "mesh.h" +#include "ns3/log.h" + +NS_LOG_COMPONENT_DEFINE ("Mesh_Topology_Helper"); + +namespace ns3 { + +Topology Mesh_Topology_Helper::Create(long hosts, long size){ + + Topology t; + + t.bridges = 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 = i + 1; j < size; ++j){ + t.bridgeLinks.insert(std::make_pair(i,j)); + } + } + + return t; + +} + + +} + diff --git a/code/src/topology/helper/mesh.h b/code/src/topology/helper/mesh.h new file mode 100644 index 0000000..c318929 --- /dev/null +++ b/code/src/topology/helper/mesh.h @@ -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 + */ + +#ifndef TOPOLOGY_MESH_H +#define TOPOLOGY_MESH_H + +#include "ns3/topology.h" + +namespace ns3 { + +class Mesh_Topology_Helper { + +public: + + Topology Create(long hosts, long size); + +}; + +} + +#endif + -- 2.34.1