src/helper/ipv4-interface-container.h
author Craig Dowell <craigdo@ee.washington.edu>
Sun, 04 Oct 2009 20:52:24 -0700
changeset 5361 e8989b44bffb
parent 5229 0d0779ac3278
child 5399 73f6b9cbad86
permissions -rw-r--r--
Doxygen and wscript messages point to test.py
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2748
f65f6e2629dc introduce Ipv4InterfaceContainer and make Ipv4AddressHelper::Allocate return it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2699
diff changeset
     1
#ifndef IPV4_INTERFACE_CONTAINER_H
f65f6e2629dc introduce Ipv4InterfaceContainer and make Ipv4AddressHelper::Allocate return it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2699
diff changeset
     2
#define IPV4_INTERFACE_CONTAINER_H
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
#include <stdint.h>
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
#include <vector>
2748
f65f6e2629dc introduce Ipv4InterfaceContainer and make Ipv4AddressHelper::Allocate return it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2699
diff changeset
     6
#include "ns3/ipv4.h"
f65f6e2629dc introduce Ipv4InterfaceContainer and make Ipv4AddressHelper::Allocate return it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2699
diff changeset
     7
#include "ns3/ipv4-address.h"
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
namespace ns3 {
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
2697
cab2a59cba8f doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2603
diff changeset
    11
/**
5361
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    12
 * \brief holds a vector of std::pair of Ptr<Ipv4> and interface index.
2697
cab2a59cba8f doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2603
diff changeset
    13
 *
5361
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    14
 * Typically ns-3 Ipv4Interfaces are installed on devices using an Ipv4 address
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    15
 * helper.  The helper's Assign() method takes a NetDeviceContainer which holds 
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    16
 * some number of Ptr<NetDevice>.  For each of the NetDevices in the 
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    17
 * NetDeviceContainer the helper will find the associated Ptr<Node> and
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    18
 * Ptr<Ipv4>.  It makes sure that an interface exists on the node for the 
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    19
 * device and then adds an Ipv4Address according to the address helper settings
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    20
 * (incrementing the Ipv4Address somehow as it goes).  The helper then converts
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    21
 * the Ptr<Ipv4> and the interface index to a std::pair and adds them to a 
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    22
 * container -- a container of this type.
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    23
 *
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    24
 * The point is then to be able to implicitly associate an index into the 
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    25
 * original NetDeviceContainer (that identifies a particular net device) with
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    26
 * an identical index into the Ipv4InterfaceContainer that has a std::pair with
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    27
 * the Ptr<Ipv4> and interface index you need to play with the interface.
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    28
 *
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    29
 * @see Ipv4AddressHelper
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    30
 * @see Ipv4
2697
cab2a59cba8f doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2603
diff changeset
    31
 */
2748
f65f6e2629dc introduce Ipv4InterfaceContainer and make Ipv4AddressHelper::Allocate return it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2699
diff changeset
    32
class Ipv4InterfaceContainer
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    33
{
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    34
public:
2697
cab2a59cba8f doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2603
diff changeset
    35
  /**
2748
f65f6e2629dc introduce Ipv4InterfaceContainer and make Ipv4AddressHelper::Allocate return it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2699
diff changeset
    36
   * Create an empty Ipv4InterfaceContainer.
2697
cab2a59cba8f doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2603
diff changeset
    37
   */
2748
f65f6e2629dc introduce Ipv4InterfaceContainer and make Ipv4AddressHelper::Allocate return it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2699
diff changeset
    38
  Ipv4InterfaceContainer ();
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    39
2697
cab2a59cba8f doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2603
diff changeset
    40
  /**
3793
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 2754
diff changeset
    41
   * Concatenate the entries in the other container with ours.
5227
ecb08c1fc273 Fix some doxygen warnings revealed by WARN_NO_PARAMDOC=YES in doc/doxygen.conf.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4472
diff changeset
    42
   * \param other container
3793
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 2754
diff changeset
    43
   */
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 2754
diff changeset
    44
  void Add (Ipv4InterfaceContainer other);
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 2754
diff changeset
    45
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 2754
diff changeset
    46
  /**
5361
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    47
   * \returns the number of Ptr<Ipv4> and interface pairs stored in this 
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    48
   * Ipv4InterfaceContainer.
2697
cab2a59cba8f doxygen
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2603
diff changeset
    49
   */
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
  uint32_t GetN (void) const;
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4140
diff changeset
    52
  /**
5227
ecb08c1fc273 Fix some doxygen warnings revealed by WARN_NO_PARAMDOC=YES in doc/doxygen.conf.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4472
diff changeset
    53
   * \param i interface index
ecb08c1fc273 Fix some doxygen warnings revealed by WARN_NO_PARAMDOC=YES in doc/doxygen.conf.
Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
parents: 4472
diff changeset
    54
   * \param j interface address index (if interface has multiple addresses)
4375
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4140
diff changeset
    55
   * \returns the IPv4 address of the j'th address of the interface
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4140
diff changeset
    56
   *  corresponding to index i.
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4140
diff changeset
    57
   * 
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4140
diff changeset
    58
   * If the second parameter is omitted, the zeroth indexed address of 
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4140
diff changeset
    59
   * the interface is returned.  Unless IP aliaising is being used on
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4140
diff changeset
    60
   * the interface, the second parameter may typically be omitted.
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4140
diff changeset
    61
   */
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4140
diff changeset
    62
  Ipv4Address GetAddress (uint32_t i, uint32_t j = 0) const;
db81fdcb06e7 Implementation cut over to use Ipv4InterfaceAddress
Tom Henderson <tomh@tomh.org>
parents: 4140
diff changeset
    63
5361
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    64
2754
de159080cf8d add SetMetric
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2748
diff changeset
    65
  void SetMetric (uint32_t i, uint16_t metric);
5361
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    66
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4375
diff changeset
    67
  /**
5361
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    68
   * Manually add an entry to the container consisting of the individual parts
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    69
   * of an entry std::pair.
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    70
   *
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    71
   * \param ipv4 pointer to Ipv4 object
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    72
   * \param interface interface index of the Ipv4Interface to add to the container
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    73
   *
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    74
   * @see Ipv4InterfaceContainer
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    75
   */
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    76
  void Add (Ptr<Ipv4> ipv4, uint32_t interface);
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    77
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    78
  /**
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    79
   * Manually add an entry to the container consisting of a previously composed 
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    80
   * entry std::pair.
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    81
   *
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4375
diff changeset
    82
   * \param ipv4 pointer to Ipv4 object
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4375
diff changeset
    83
   * \param interface interface index of the Ipv4Interface to add to the container
5361
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    84
   *
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    85
   * @see Ipv4InterfaceContainer
4472
e20a31541404 src/ and utils/ changes for IPv4 routing rework
Tom Henderson <tomh@tomh.org>
parents: 4375
diff changeset
    86
   */
5229
0d0779ac3278 ===================================================================
Craig Dowell <craigdo@ee.washington.edu>
parents: 5227
diff changeset
    87
  void Add (std::pair<Ptr<Ipv4>, uint32_t>);
5361
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    88
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    89
  /**
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    90
   * Manually add an entry to the container consisting of the individual parts
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    91
   * of an entry std::pair.
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    92
   *
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    93
   * \param ipv4Name std:string referring to the saved name of an Ipv4 Object that
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    94
   *        has been previously named using the Object Name Service.
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    95
   * \param interface interface index of the Ipv4Interface to add to the container
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    96
   *
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    97
   * @see Ipv4InterfaceContainer
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
    98
   */
4140
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3793
diff changeset
    99
  void Add (std::string ipv4Name, uint32_t interface);
2699
cbc8b1ae341d add NodeContainer::GetGlobal
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2697
diff changeset
   100
5361
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
   101
  /**
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
   102
   * Get the std::pair of an Ptr<Ipv4> and interface stored at the location 
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
   103
   * specified by the index.
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
   104
   *
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
   105
   * \param i the index of the entery to retrieve.
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
   106
   *
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
   107
   * @see Ipv4InterfaceContainer
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
   108
   */
e8989b44bffb Doxygen and wscript messages point to test.py
Craig Dowell <craigdo@ee.washington.edu>
parents: 5229
diff changeset
   109
  std::pair<Ptr<Ipv4>, uint32_t> Get (uint32_t i) const;
5229
0d0779ac3278 ===================================================================
Craig Dowell <craigdo@ee.washington.edu>
parents: 5227
diff changeset
   110
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   111
 private:
3793
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 2754
diff changeset
   112
  
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 2754
diff changeset
   113
  typedef std::vector<std::pair<Ptr<Ipv4>,uint32_t> > InterfaceVector;
a5895f134543 make star topologies easier to create
Craig Dowell <craigdo@ee.washington.edu>
parents: 2754
diff changeset
   114
  InterfaceVector m_interfaces;
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   115
};
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   116
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   117
} // namespace ns3
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   118
2748
f65f6e2629dc introduce Ipv4InterfaceContainer and make Ipv4AddressHelper::Allocate return it.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2699
diff changeset
   119
#endif /* IPV4_INTERFACE_CONTAINER_H */