examples/matrix-topology/matrix-topology.cc
author Ovidiu Poncea <ovidiu.poncea@cs.pub.ro>
Mon, 31 Aug 2015 10:41:05 -0700
changeset 11619 0b8c6e883208
parent 9270 58b23c49c456
permissions -rw-r--r--
bug 2158: Fix flooding of packets on input port, for packets received on in!=0 When you have the action OFPP_FLOOD on a flow, and the received packet is not coming into the switch through port 0, then the packet will be flooded on all ports, including the receiving port! This is especially bad if you have broadcasts as packets will get replicated indefinitely (ARP req for e.g.). This is caused by missing ntohs() that fails to convert port numbers to their correct values. The switch works correctly for broadcast packets received on port zero. Example: The ReceivePacketOut() gets 0 if the input port is 0 and it works. But will get 512 if the input port is 1 and since 512 is not our real input port the check will fail and the packet will also be replicated on the input port.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
     2
/*
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
     3
 * Copyright (c) 2010 Egemen K. Cetinkaya, Justin P. Rohrer, and Amit Dandekar
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
     4
 *
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
     7
 * published by the Free Software Foundation;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
     8
 *
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    12
 * GNU General Public License for more details.
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    13
 *
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    17
 *
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    18
 * Author: Egemen K. Cetinkaya <ekc@ittc.ku.edu>
6629
b4d07d7badad Fix comments on matrix-topology example
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents: 6628
diff changeset
    19
 * Author: Justin P. Rohrer    <rohrej@ittc.ku.edu>
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    20
 * Author: Amit Dandekar       <dandekar@ittc.ku.edu>
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    21
 *
6629
b4d07d7badad Fix comments on matrix-topology example
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents: 6628
diff changeset
    22
 * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
b4d07d7badad Fix comments on matrix-topology example
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents: 6628
diff changeset
    23
 * ResiliNets Research Group  http://wiki.ittc.ku.edu/resilinets
b4d07d7badad Fix comments on matrix-topology example
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents: 6628
diff changeset
    24
 * Information and Telecommunication Technology Center 
b4d07d7badad Fix comments on matrix-topology example
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents: 6628
diff changeset
    25
 * and
b4d07d7badad Fix comments on matrix-topology example
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents: 6628
diff changeset
    26
 * Department of Electrical Engineering and Computer Science
b4d07d7badad Fix comments on matrix-topology example
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents: 6628
diff changeset
    27
 * The University of Kansas
b4d07d7badad Fix comments on matrix-topology example
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents: 6628
diff changeset
    28
 * Lawrence, KS  USA
b4d07d7badad Fix comments on matrix-topology example
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents: 6628
diff changeset
    29
 *
b4d07d7badad Fix comments on matrix-topology example
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents: 6628
diff changeset
    30
 * Work supported in part by NSF FIND (Future Internet Design) Program
b4d07d7badad Fix comments on matrix-topology example
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents: 6628
diff changeset
    31
 * under grant CNS-0626918 (Postmodern Internet Architecture) and 
b4d07d7badad Fix comments on matrix-topology example
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents: 6628
diff changeset
    32
 * by NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI)
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    33
 *
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    34
 * This program reads an upper triangular adjacency matrix (e.g. adjacency_matrix.txt) and
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    35
 * node coordinates file (e.g. node_coordinates.txt). The program also set-ups a
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    36
 * wired network topology with P2P links according to the adjacency matrix with
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    37
 * nx(n-1) CBR traffic flows, in which n is the number of nodes in the adjacency matrix.
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    38
 */
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    39
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    40
// ---------- Header Includes -------------------------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    41
#include <iostream>
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    42
#include <fstream>
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    43
#include <sstream>
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    44
#include <string>
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    45
#include <vector>
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    46
#include <cstdlib>
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    47
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    48
#include "ns3/core-module.h"
6823
a27f86fb4e55 Merge node and common modules into new network module
Tom Henderson <tomh@tomh.org>
parents: 6821
diff changeset
    49
#include "ns3/network-module.h"
6848
1f453ad50ef3 Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6847
diff changeset
    50
#include "ns3/internet-module.h"
1f453ad50ef3 Converts csma, emu, tap-bridge, point-to-point, wifi and wimax modules into modular format
Lalith Suresh <suresh.lalith@gmail.com>
parents: 6847
diff changeset
    51
#include "ns3/point-to-point-module.h"
6847
138f00c56381 Move applications to a single module
Mitch Watrous <watrous@u.washington.edu>
parents: 6845
diff changeset
    52
#include "ns3/applications-module.h"
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    53
#include "ns3/global-route-manager.h"
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    54
#include "ns3/mobility-module.h"
7066
948694386867 Print modules built list at end of waf build
Mitch Watrous <watrous@u.washington.edu>
parents: 6865
diff changeset
    55
#include "ns3/netanim-module.h"
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    56
#include "ns3/assert.h"
6649
f5413d463948 Missing ipv4-global-routing-helper.h include
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents: 6629
diff changeset
    57
#include "ns3/ipv4-global-routing-helper.h"
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    58
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    59
using namespace std;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    60
using namespace ns3;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    61
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    62
// ---------- Prototypes ------------------------------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    63
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    64
vector<vector<bool> > readNxNMatrix (std::string adj_mat_file_name);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    65
vector<vector<double> > readCordinatesFile (std::string node_coordinates_file_name);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    66
void printCoordinateArray (const char* description, vector<vector<double> > coord_array);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    67
void printMatrix (const char* description, vector<vector<bool> > array);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    68
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    69
NS_LOG_COMPONENT_DEFINE ("GenericTopologyCreation");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    70
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    71
int main (int argc, char *argv[])
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    72
{
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    73
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    74
  // ---------- Simulation Variables ------------------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    75
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    76
  // Change the variables and file names only in this block!
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    77
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    78
  double SimTime        = 3.00;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    79
  double SinkStartTime  = 1.0001;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    80
  double SinkStopTime   = 2.90001;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    81
  double AppStartTime   = 2.0001;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    82
  double AppStopTime    = 2.80001;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    83
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    84
  std::string AppPacketRate ("40Kbps");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    85
  Config::SetDefault  ("ns3::OnOffApplication::PacketSize",StringValue ("1000"));
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    86
  Config::SetDefault ("ns3::OnOffApplication::DataRate",  StringValue (AppPacketRate));
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    87
  std::string LinkRate ("10Mbps");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    88
  std::string LinkDelay ("2ms");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    89
  //  DropTailQueue::MaxPackets affects the # of dropped packets, default value:100
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    90
  //  Config::SetDefault ("ns3::DropTailQueue::MaxPackets", UintegerValue (1000));
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    91
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    92
  srand ( (unsigned)time ( NULL ) );   // generate different seed each time
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    93
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    94
  std::string tr_name ("n-node-ppp.tr");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    95
  std::string pcap_name ("n-node-ppp");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    96
  std::string flow_name ("n-node-ppp.xml");
7806
4c63c0278258 NetAnim: add configure start/stop time, update examples
John Abraham <john.abraham@gatech.edu>
parents: 7196
diff changeset
    97
  std::string anim_name ("n-node-ppp.anim.xml");
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    98
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
    99
  std::string adj_mat_file_name ("examples/matrix-topology/adjacency_matrix.txt");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   100
  std::string node_coordinates_file_name ("examples/matrix-topology/node_coordinates.txt");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   101
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   102
  // ---------- End of Simulation Variables ----------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   103
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   104
  // ---------- Read Adjacency Matrix ----------------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   105
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   106
  vector<vector<bool> > Adj_Matrix;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   107
  Adj_Matrix = readNxNMatrix (adj_mat_file_name);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   108
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   109
  // Optionally display 2-dimensional adjacency matrix (Adj_Matrix) array
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   110
  // printMatrix (adj_mat_file_name.c_str (),Adj_Matrix);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   111
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   112
  // ---------- End of Read Adjacency Matrix ---------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   113
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   114
  // ---------- Read Node Coordinates File -----------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   115
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   116
  vector<vector<double> > coord_array;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   117
  coord_array = readCordinatesFile (node_coordinates_file_name);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   118
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   119
  // Optionally display node co-ordinates file
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   120
  // printCoordinateArray (node_coordinates_file_name.c_str (),coord_array);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   121
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   122
  int n_nodes = coord_array.size ();
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   123
  int matrixDimension = Adj_Matrix.size ();
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   124
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   125
  if (matrixDimension != n_nodes)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   126
    {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   127
      NS_FATAL_ERROR ("The number of lines in coordinate file is: " << n_nodes << " not equal to the number of nodes in adjacency matrix size " << matrixDimension);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   128
    }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   129
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   130
  // ---------- End of Read Node Coordinates File ----------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   131
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   132
  // ---------- Network Setup ------------------------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   133
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   134
  NS_LOG_INFO ("Create Nodes.");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   135
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   136
  NodeContainer nodes;   // Declare nodes objects
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   137
  nodes.Create (n_nodes);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   138
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   139
  NS_LOG_INFO ("Create P2P Link Attributes.");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   140
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   141
  PointToPointHelper p2p;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   142
  p2p.SetDeviceAttribute ("DataRate", StringValue (LinkRate));
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   143
  p2p.SetChannelAttribute ("Delay", StringValue (LinkDelay));
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   144
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   145
  NS_LOG_INFO ("Install Internet Stack to Nodes.");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   146
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   147
  InternetStackHelper internet;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   148
  internet.Install (NodeContainer::GetGlobal ());
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   149
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   150
  NS_LOG_INFO ("Assign Addresses to Nodes.");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   151
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   152
  Ipv4AddressHelper ipv4_n;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   153
  ipv4_n.SetBase ("10.0.0.0", "255.255.255.252");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   154
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   155
  NS_LOG_INFO ("Create Links Between Nodes.");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   156
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   157
  uint32_t linkCount = 0;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   158
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   159
  for (size_t i = 0; i < Adj_Matrix.size (); i++)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   160
    {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   161
      for (size_t j = 0; j < Adj_Matrix[i].size (); j++)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   162
        {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   163
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   164
          if (Adj_Matrix[i][j] == 1)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   165
            {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   166
              NodeContainer n_links = NodeContainer (nodes.Get (i), nodes.Get (j));
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   167
              NetDeviceContainer n_devs = p2p.Install (n_links);
6659
f2e0d07fea48 remove unneeded array
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents: 6649
diff changeset
   168
              ipv4_n.Assign (n_devs);
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   169
              ipv4_n.NewNetwork ();
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   170
              linkCount++;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   171
              NS_LOG_INFO ("matrix element [" << i << "][" << j << "] is 1");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   172
            }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   173
          else
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   174
            {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   175
              NS_LOG_INFO ("matrix element [" << i << "][" << j << "] is 0");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   176
            }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   177
        }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   178
    }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   179
  NS_LOG_INFO ("Number of links in the adjacency matrix is: " << linkCount);
6628
0586bc1a18ce fix optimized build
Tom Henderson <tomh@tomh.org>
parents: 6627
diff changeset
   180
  NS_LOG_INFO ("Number of all nodes is: " << nodes.GetN ());
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   181
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   182
  NS_LOG_INFO ("Initialize Global Routing.");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   183
  Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   184
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   185
  // ---------- End of Network Set-up ----------------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   186
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   187
  // ---------- Allocate Node Positions --------------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   188
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   189
  NS_LOG_INFO ("Allocate Positions to Nodes.");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   190
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   191
  MobilityHelper mobility_n;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   192
  Ptr<ListPositionAllocator> positionAlloc_n = CreateObject<ListPositionAllocator> ();
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   193
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   194
  for (size_t m = 0; m < coord_array.size (); m++)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   195
    {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   196
      positionAlloc_n->Add (Vector (coord_array[m][0], coord_array[m][1], 0));
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   197
      Ptr<Node> n0 = nodes.Get (m);
7081
9e2c7d8d842f Bug 1106: Remove CanvasLocation dependencies
John Abraham <john.abraham@gatech.edu>
parents: 7066
diff changeset
   198
      Ptr<ConstantPositionMobilityModel> nLoc =  n0->GetObject<ConstantPositionMobilityModel> ();
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   199
      if (nLoc == 0)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   200
        {
7081
9e2c7d8d842f Bug 1106: Remove CanvasLocation dependencies
John Abraham <john.abraham@gatech.edu>
parents: 7066
diff changeset
   201
          nLoc = CreateObject<ConstantPositionMobilityModel> ();
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   202
          n0->AggregateObject (nLoc);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   203
        }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   204
      // y-coordinates are negated for correct display in NetAnim
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   205
      // NetAnim's (0,0) reference coordinates are located on upper left corner
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   206
      // by negating the y coordinates, we declare the reference (0,0) coordinate
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   207
      // to the bottom left corner
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   208
      Vector nVec (coord_array[m][0], -coord_array[m][1], 0);
7081
9e2c7d8d842f Bug 1106: Remove CanvasLocation dependencies
John Abraham <john.abraham@gatech.edu>
parents: 7066
diff changeset
   209
      nLoc->SetPosition (nVec);
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   210
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   211
    }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   212
  mobility_n.SetPositionAllocator (positionAlloc_n);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   213
  mobility_n.Install (nodes);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   214
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   215
  // ---------- End of Allocate Node Positions -------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   216
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   217
  // ---------- Create n*(n-1) CBR Flows -------------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   218
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   219
  NS_LOG_INFO ("Setup Packet Sinks.");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   220
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   221
  uint16_t port = 9;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   222
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   223
  for (int i = 0; i < n_nodes; i++)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   224
    {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   225
      PacketSinkHelper sink ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), port));
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   226
      ApplicationContainer apps_sink = sink.Install (nodes.Get (i));   // sink is installed on all nodes
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   227
      apps_sink.Start (Seconds (SinkStartTime));
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   228
      apps_sink.Stop (Seconds (SinkStopTime));
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   229
    }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   230
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   231
  NS_LOG_INFO ("Setup CBR Traffic Sources.");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   232
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   233
  for (int i = 0; i < n_nodes; i++)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   234
    {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   235
      for (int j = 0; j < n_nodes; j++)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   236
        {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   237
          if (i != j)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   238
            {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   239
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   240
              // We needed to generate a random number (rn) to be used to eliminate
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   241
              // the artificial congestion caused by sending the packets at the
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   242
              // same time. This rn is added to AppStartTime to have the sources
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   243
              // start at different time, however they will still send at the same rate.
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   244
8996
d0e0a162a990 Replace various instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7806
diff changeset
   245
              Ptr<UniformRandomVariable> x = CreateObject<UniformRandomVariable> ();
d0e0a162a990 Replace various instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7806
diff changeset
   246
              x->SetAttribute ("Min", DoubleValue (0));
d0e0a162a990 Replace various instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7806
diff changeset
   247
              x->SetAttribute ("Max", DoubleValue (1));
d0e0a162a990 Replace various instances of RandomVariable with RandomVariableStream
Mitch Watrous
parents: 7806
diff changeset
   248
              double rn = x->GetValue ();
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   249
              Ptr<Node> n = nodes.Get (j);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   250
              Ptr<Ipv4> ipv4 = n->GetObject<Ipv4> ();
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   251
              Ipv4InterfaceAddress ipv4_int_addr = ipv4->GetAddress (1, 0);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   252
              Ipv4Address ip_addr = ipv4_int_addr.GetLocal ();
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   253
              OnOffHelper onoff ("ns3::UdpSocketFactory", InetSocketAddress (ip_addr, port)); // traffic flows from node[i] to node[j]
9000
3ec20a64fd08 Add a constant rate setting function to the on-off helper
Mitch Watrous
parents: 8996
diff changeset
   254
              onoff.SetConstantRate (DataRate (AppPacketRate));
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   255
              ApplicationContainer apps = onoff.Install (nodes.Get (i));  // traffic sources are installed on all nodes
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   256
              apps.Start (Seconds (AppStartTime + rn));
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   257
              apps.Stop (Seconds (AppStopTime));
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   258
            }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   259
        }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   260
    }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   261
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   262
  // ---------- End of Create n*(n-1) CBR Flows ------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   263
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   264
  // ---------- Simulation Monitoring ----------------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   265
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   266
  NS_LOG_INFO ("Configure Tracing.");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   267
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   268
  AsciiTraceHelper ascii;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   269
  p2p.EnableAsciiAll (ascii.CreateFileStream (tr_name.c_str ()));
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   270
  // p2p.EnablePcapAll (pcap_name.c_str());
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   271
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   272
  // Ptr<FlowMonitor> flowmon;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   273
  // FlowMonitorHelper flowmonHelper;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   274
  // flowmon = flowmonHelper.InstallAll ();
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   275
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   276
  // Configure animator with default settings
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   277
7806
4c63c0278258 NetAnim: add configure start/stop time, update examples
John Abraham <john.abraham@gatech.edu>
parents: 7196
diff changeset
   278
  AnimationInterface anim (anim_name.c_str ());
6627
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   279
  NS_LOG_INFO ("Run Simulation.");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   280
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   281
  Simulator::Stop (Seconds (SimTime));
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   282
  Simulator::Run ();
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   283
  // flowmon->SerializeToXmlFile (flow_name.c_str(), true, true);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   284
  Simulator::Destroy ();
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   285
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   286
  // ---------- End of Simulation Monitoring ---------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   287
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   288
  return 0;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   289
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   290
}
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   291
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   292
// ---------- Function Definitions -------------------------------------------
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   293
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   294
vector<vector<bool> > readNxNMatrix (std::string adj_mat_file_name)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   295
{
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   296
  ifstream adj_mat_file;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   297
  adj_mat_file.open (adj_mat_file_name.c_str (), ios::in);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   298
  if (adj_mat_file.fail ())
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   299
    {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   300
      NS_FATAL_ERROR ("File " << adj_mat_file_name.c_str () << " not found");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   301
    }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   302
  vector<vector<bool> > array;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   303
  int i = 0;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   304
  int n_nodes = 0;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   305
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   306
  while (!adj_mat_file.eof ())
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   307
    {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   308
      string line;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   309
      getline (adj_mat_file, line);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   310
      if (line == "")
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   311
        {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   312
          NS_LOG_WARN ("WARNING: Ignoring blank row in the array: " << i);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   313
          break;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   314
        }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   315
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   316
      istringstream iss (line);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   317
      bool element;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   318
      vector<bool> row;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   319
      int j = 0;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   320
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   321
      while (iss >> element)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   322
        {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   323
          row.push_back (element);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   324
          j++;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   325
        }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   326
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   327
      if (i == 0)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   328
        {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   329
          n_nodes = j;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   330
        }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   331
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   332
      if (j != n_nodes )
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   333
        {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   334
          NS_LOG_ERROR ("ERROR: Number of elements in line " << i << ": " << j << " not equal to number of elements in line 0: " << n_nodes);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   335
          NS_FATAL_ERROR ("ERROR: The number of rows is not equal to the number of columns! in the adjacency matrix");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   336
        }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   337
      else
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   338
        {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   339
          array.push_back (row);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   340
        }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   341
      i++;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   342
    }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   343
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   344
  if (i != n_nodes)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   345
    {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   346
      NS_LOG_ERROR ("There are " << i << " rows and " << n_nodes << " columns.");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   347
      NS_FATAL_ERROR ("ERROR: The number of rows is not equal to the number of columns! in the adjacency matrix");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   348
    }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   349
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   350
  adj_mat_file.close ();
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   351
  return array;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   352
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   353
}
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   354
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   355
vector<vector<double> > readCordinatesFile (std::string node_coordinates_file_name)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   356
{
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   357
  ifstream node_coordinates_file;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   358
  node_coordinates_file.open (node_coordinates_file_name.c_str (), ios::in);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   359
  if (node_coordinates_file.fail ())
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   360
    {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   361
      NS_FATAL_ERROR ("File " << node_coordinates_file_name.c_str () << " not found");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   362
    }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   363
  vector<vector<double> > coord_array;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   364
  int m = 0;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   365
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   366
  while (!node_coordinates_file.eof ())
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   367
    {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   368
      string line;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   369
      getline (node_coordinates_file, line);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   370
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   371
      if (line == "")
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   372
        {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   373
          NS_LOG_WARN ("WARNING: Ignoring blank row: " << m);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   374
          break;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   375
        }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   376
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   377
      istringstream iss (line);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   378
      double coordinate;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   379
      vector<double> row;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   380
      int n = 0;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   381
      while (iss >> coordinate)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   382
        {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   383
          row.push_back (coordinate);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   384
          n++;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   385
        }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   386
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   387
      if (n != 2)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   388
        {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   389
          NS_LOG_ERROR ("ERROR: Number of elements at line#" << m << " is "  << n << " which is not equal to 2 for node coordinates file");
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   390
          exit (1);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   391
        }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   392
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   393
      else
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   394
        {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   395
          coord_array.push_back (row);
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   396
        }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   397
      m++;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   398
    }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   399
  node_coordinates_file.close ();
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   400
  return coord_array;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   401
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   402
}
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   403
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   404
void printMatrix (const char* description, vector<vector<bool> > array)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   405
{
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   406
  cout << "**** Start " << description << "********" << endl;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   407
  for (size_t m = 0; m < array.size (); m++)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   408
    {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   409
      for (size_t n = 0; n < array[m].size (); n++)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   410
        {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   411
          cout << array[m][n] << ' ';
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   412
        }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   413
      cout << endl;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   414
    }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   415
  cout << "**** End " << description << "********" << endl;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   416
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   417
}
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   418
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   419
void printCoordinateArray (const char* description, vector<vector<double> > coord_array)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   420
{
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   421
  cout << "**** Start " << description << "********" << endl;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   422
  for (size_t m = 0; m < coord_array.size (); m++)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   423
    {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   424
      for (size_t n = 0; n < coord_array[m].size (); n++)
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   425
        {
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   426
          cout << coord_array[m][n] << ' ';
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   427
        }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   428
      cout << endl;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   429
    }
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   430
  cout << "**** End " << description << "********" << endl;
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   431
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   432
}
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   433
b6a64626353c Matrix topology example program
Egemen K. Cetinkaya <ekc@ittc.ku.edu>
parents:
diff changeset
   434
// ---------- End of Function Definitions ------------------------------------