src/devices/csma-cd/csma-cd-ipv4-topology.h
changeset 1376 ad7e61edfb9d
parent 1375 4f45bec005b8
parent 1299 394c16278532
child 1377 2fcc78ee9558
equal deleted inserted replaced
1375:4f45bec005b8 1376:ad7e61edfb9d
     1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
       
     2 //
       
     3 // Copyright (c) 2007 Emmanuelle Laprise
       
     4 //
       
     5 // This program is free software; you can redistribute it and/or modify
       
     6 // it under the terms of the GNU General Public License version 2 as
       
     7 // published by the Free Software Foundation;
       
     8 //
       
     9 // This program is distributed in the hope that it will be useful,
       
    10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 // GNU General Public License for more details.
       
    13 //
       
    14 // You should have received a copy of the GNU General Public License
       
    15 // along with this program; if not, write to the Free Software
       
    16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
       
    17 //
       
    18 // Author: Emmanuelle Laprise <emmanuelle.laprise@bluekazoo.ca>
       
    19 //
       
    20 
       
    21 #ifndef __CSMA_CD_IPV4_TOPOLOGY_H__
       
    22 #define __CSMA_CD_IPV4_TOPOLOGY_H__
       
    23 
       
    24 #include "ns3/ptr.h"
       
    25 #include "ns3/ipv4-address.h"
       
    26 #include "ns3/ipv4.h"
       
    27 #include "ns3/ipv4-route.h"
       
    28 #include "ns3/internet-node.h"
       
    29 #include "ns3/csma-cd-net-device.h"
       
    30 
       
    31 // The topology class consists of only static methods thar are used to
       
    32 // create the topology and data flows for an ns3 simulation
       
    33 
       
    34 namespace ns3 {
       
    35 
       
    36 class CsmaCdIpv4Channel;
       
    37 class Node;
       
    38 class IPAddr;
       
    39 class DataRate;
       
    40 class Queue;
       
    41 
       
    42 /**
       
    43  * \brief A helper class to create Topologies based on the
       
    44  * InternetNodes and CsmaCdChannels. Either the
       
    45  * SimpleCsmaCdNetDevice or the LLCCsmaCdNetDevice can be used
       
    46  * when constructing these topologies.
       
    47  */
       
    48 class CsmaCdIpv4Topology {
       
    49 public:
       
    50 
       
    51   /**
       
    52    * \param n1 Node to be attached to the Csma/Cd channel
       
    53    * \param ch CsmaCdChannel to which node n1 should be attached
       
    54    * \param addr Mac address of the node
       
    55    *
       
    56    * Add a Csma/Cd node to a Csma/Cd channel. This function adds
       
    57    * a EthernetCsmaCdNetDevice to the nodes so that they can
       
    58    * connect to a CsmaCdChannel. This means that Ethernet headers
       
    59    * and trailers will be added to the packet before sending out on
       
    60    * the net device.
       
    61    * 
       
    62    * \return ifIndex of the device
       
    63    */
       
    64   static uint32_t AddIpv4CsmaCdNode( Ptr<Node> n1,
       
    65                                      Ptr<CsmaCdChannel> ch,
       
    66                                      Eui48Address addr);
       
    67 
       
    68   /**
       
    69    * \param n1 Node to be attached to the Csma/Cd channel
       
    70    * \param ch CsmaCdChannel to which node n1 should be attached
       
    71    * \param addr Mac address of the node
       
    72    *
       
    73    * Add a Csma/Cd node to a Csma/Cd channel. This function adds
       
    74    * a RawCsmaCdNetDevice to the nodes so that they can connect
       
    75    * to a CsmaCdChannel.
       
    76    */
       
    77   static void AddIpv4RawCsmaCdNode( Ptr<Node> n1,
       
    78                                     Ptr<CsmaCdChannel> ch,
       
    79                                     Eui48Address addr);
       
    80 
       
    81   /**
       
    82    * \param n1 Node to be attached to the Csma/Cd channel
       
    83    * \param ch CsmaCdChannel to which node n1 should be attached
       
    84    * \param addr Mac address of the node
       
    85    *
       
    86    * Add a Csma/Cd node to a Csma/Cd channel. This function adds
       
    87    * a LlcCsmaCdNetDevice to the nodes so that they can connect
       
    88    * to a CsmaCdChannel.
       
    89    */
       
    90   static void AddIpv4LlcCsmaCdNode( Ptr<Node> n1,
       
    91                                     Ptr<CsmaCdChannel> ch,
       
    92                                     Eui48Address addr);
       
    93 
       
    94 
       
    95 
       
    96   /** 
       
    97    * \param n1 Node
       
    98    * \param ndNum NetDevice number with which to associate address
       
    99    * \param addr1 Ipv4 Address for ndNum of n1
       
   100    * \param network network mask for ndNum of node n1
       
   101    * 
       
   102    * Add an Ipv4Address to the Ipv4 interface associated with the
       
   103    * ndNum CsmaCdIpv4NetDevices on the provided
       
   104    * CsmaCdIpv4Channel
       
   105    */
       
   106   static void AddIpv4Address(Ptr<Node> n1, int ndNum, 
       
   107                              const Ipv4Address& addr1,
       
   108                              const Ipv4Mask& netmask1);
       
   109 
       
   110   /**
       
   111    * \param nd1 Node
       
   112    * \param nd2 Node
       
   113    * 
       
   114    * Add an IPV4 host route between the two specified net devices
       
   115    */
       
   116   static void AddIpv4Routes (Ptr<NetDevice> nd1, Ptr<NetDevice> nd2);
       
   117 };
       
   118 
       
   119 } // namespace ns3
       
   120 
       
   121 #endif
       
   122