src/csma-layout/model/csma-star-helper.h
author Mitch Watrous <watrous@u.washington.edu>
Wed, 18 May 2011 17:24:04 -0700
changeset 7241 0a7a16b599e8
parent 7234 0572de06ae29
permissions -rw-r--r--
Make some more modules show up on doxygen modules page
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7089
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     2
/*
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     3
 * This program is free software; you can redistribute it and/or modify
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     4
 * it under the terms of the GNU General Public License version 2 as
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     5
 * published by the Free Software Foundation;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     6
 *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     7
 * This program is distributed in the hope that it will be useful,
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
     9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    10
 * GNU General Public License for more details.
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    11
 *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    12
 * You should have received a copy of the GNU General Public License
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    13
 * along with this program; if not, write to the Free Software
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    14
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    15
 */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    16
7091
055f2819a1d4 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents: 7089
diff changeset
    17
// Define an object to create a star topology.
7089
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    18
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    19
#ifndef CSMA_STAR_HELPER_H
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    20
#define CSMA_STAR_HELPER_H
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    21
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    22
#include <string>
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    23
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    24
#include "csma-helper.h"
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    25
#include "ipv4-address-helper.h"
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    26
#include "internet-stack-helper.h"
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    27
#include "ipv4-interface-container.h"
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    28
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    29
namespace ns3 {
7133
db7061624ae6 csma-layout code-style changes
John Abraham<john.abraham@gatech.edu>
parents: 7091
diff changeset
    30
7089
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    31
/**
7241
0a7a16b599e8 Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 7234
diff changeset
    32
 * \defgroup csmalayout CSMA Layout Helpers
7234
0572de06ae29 Make some modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 7133
diff changeset
    33
 *
0572de06ae29 Make some modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 7133
diff changeset
    34
 */
0572de06ae29 Make some modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 7133
diff changeset
    35
0572de06ae29 Make some modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 7133
diff changeset
    36
/**
7241
0a7a16b599e8 Make some more modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 7234
diff changeset
    37
 * \ingroup csmalayout
7234
0572de06ae29 Make some modules show up on doxygen modules page
Mitch Watrous <watrous@u.washington.edu>
parents: 7133
diff changeset
    38
 *
7089
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    39
 * \brief A helper to make it easier to create a star topology
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    40
 * with Csma links
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    41
 */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    42
class CsmaStarHelper
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    43
{
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    44
public:
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    45
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    46
   * Create a CsmaStarHelper in order to easily create
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    47
   * star topologies using Csma links
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    48
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    49
   * \param numSpokes the number of links attached to 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    50
   *        the hub node, creating a total of 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    51
   *        numSpokes + 1 nodes
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    52
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    53
   * \param csmaHelper the link helper for Csma links, 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    54
   *        used to link nodes together
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    55
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    56
  CsmaStarHelper (uint32_t numSpokes, 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    57
                  CsmaHelper csmaHelper);
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    58
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    59
  ~CsmaStarHelper ();
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    60
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    61
public:
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    62
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    63
   * \returns a node pointer to the hub node in the
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    64
   *          star, i.e., the center node
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    65
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    66
  Ptr<Node> GetHub () const;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    67
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    68
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    69
   * \param i an index into the spokes of the star
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    70
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    71
   * \returns a node pointer to the node at the indexed spoke
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    72
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    73
  Ptr<Node> GetSpokeNode (uint32_t i) const;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    74
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    75
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    76
   * \returns the net-device container which contains all of 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    77
   *          the devices on the hub node
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    78
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    79
  NetDeviceContainer GetHubDevices () const;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    80
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    81
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    82
   * \returns the net-device container which contains all of 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    83
   *          the spoke node devices
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    84
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    85
  NetDeviceContainer GetSpokeDevices () const;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    86
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    87
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    88
   * \param i index into the hub interfaces
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    89
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    90
   * \returns Ipv4Address according to indexed hub interface
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    91
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    92
  Ipv4Address GetHubIpv4Address (uint32_t i) const;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    93
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    94
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    95
   * \param i index into the spoke interfaces
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    96
   *
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    97
   * \returns Ipv4Address according to indexed spoke interface
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    98
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
    99
  Ipv4Address GetSpokeIpv4Address (uint32_t i) const;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   100
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   101
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   102
   * \returns the total number of spokes in the star
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   103
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   104
  uint32_t SpokeCount () const;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   105
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   106
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   107
   * \param stack an InternetStackHelper which is used to install 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   108
   *              on every node in the star
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   109
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   110
  void InstallStack (InternetStackHelper stack);
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   111
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   112
  /**
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   113
   * \param address an Ipv4AddressHelper which is used to install 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   114
   *                Ipv4 addresses on all the node interfaces in 
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   115
   *                the star
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   116
   */
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   117
  void AssignIpv4Addresses (Ipv4AddressHelper address);
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   118
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   119
private:
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   120
  NodeContainer m_hub;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   121
  NetDeviceContainer m_hubDevices;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   122
  NodeContainer m_spokes;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   123
  NetDeviceContainer m_spokeDevices;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   124
  Ipv4InterfaceContainer m_hubInterfaces;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   125
  Ipv4InterfaceContainer m_spokeInterfaces;
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   126
};
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   127
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   128
} // namespace ns3
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   129
ebe626d82692 Bug 1105 Move topology helpers into separate per-device modules
John Abraham<john.abraham@gatech.edu>
parents:
diff changeset
   130
#endif /* CSMA_STAR_HELPER_H */