OLD | NEW |
(Empty) | |
| 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2017 NITK Surathkal |
| 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 * Authors: Shravya K.S. <shravya.ks0@gmail.com> |
| 19 * |
| 20 */ |
| 21 |
| 22 // Define an object to create a BCube topology. |
| 23 |
| 24 #ifndef POINT_TO_POINT_BCUBE_HELPER_H |
| 25 #define POINT_TO_POINT_BCUBE_HELPER_H |
| 26 |
| 27 #include <vector> |
| 28 |
| 29 #include "internet-stack-helper.h" |
| 30 #include "point-to-point-helper.h" |
| 31 #include "ipv4-address-helper.h" |
| 32 #include "ipv6-address-helper.h" |
| 33 #include "ipv4-interface-container.h" |
| 34 #include "ipv6-interface-container.h" |
| 35 #include "net-device-container.h" |
| 36 |
| 37 namespace ns3 { |
| 38 |
| 39 /** |
| 40 * \ingroup point-to-point-layout |
| 41 * |
| 42 * \brief A helper to make it easier to create a BCube topology |
| 43 * with p2p links |
| 44 */ |
| 45 class PointToPointBCubeHelper |
| 46 { |
| 47 public: |
| 48 /** |
| 49 * Create a PointToPointBCubeHelper in order to easily create |
| 50 * BCube topologies using p2p links |
| 51 * |
| 52 * \param nLevels total number of levels in BCube |
| 53 * |
| 54 * \param nServers total number of servers in one BCube |
| 55 * |
| 56 * \param pointToPoint the PointToPointHelper which is used |
| 57 * to connect all of the nodes together |
| 58 * in the BCube |
| 59 */ |
| 60 PointToPointBCubeHelper (uint32_t nLevels, |
| 61 uint32_t nServers, |
| 62 PointToPointHelper pointToPoint); |
| 63 |
| 64 ~PointToPointBCubeHelper (); |
| 65 |
| 66 /** |
| 67 * \param row the row address of the desired switch |
| 68 * |
| 69 * \param col the column address of the desired switch |
| 70 * |
| 71 * \returns a pointer to the switch specified by the |
| 72 * (row, col) address |
| 73 */ |
| 74 Ptr<Node> GetSwitchNode (uint32_t row, uint32_t col) const; |
| 75 |
| 76 /** |
| 77 * \param col the column address of the desired server |
| 78 * |
| 79 * \returns a pointer to the server specified by the |
| 80 * column address |
| 81 */ |
| 82 Ptr<Node> GetServerNode (uint32_t col) const; |
| 83 |
| 84 /** |
| 85 * This returns an IPv4 address of the switch specified by |
| 86 * the (row, col) address. Technically, a switch will have |
| 87 * multiple interfaces in the BCube; therefore, it also has |
| 88 * multiple IPv4 addresses. This method only returns one of |
| 89 * the addresses. The address being returned belongs to an |
| 90 * interface which connects the lowest index server to this |
| 91 * switch. |
| 92 * |
| 93 * \param row the row address of the desired switch |
| 94 * |
| 95 * \param col the column address of the desired switch |
| 96 * |
| 97 * \returns Ipv4Address of one of the interfaces of the switch |
| 98 * specified by the (row, col) address |
| 99 */ |
| 100 Ipv4Address GetSwitchIpv4Address (uint32_t row, uint32_t col) const; |
| 101 |
| 102 /** |
| 103 * This returns an IPv6 address at the switch specified by |
| 104 * the (row, col) address. Technically, a switch will have |
| 105 * multiple interfaces in the BCube; therefore, it also has |
| 106 * multiple IPv6 addresses. This method only returns one of |
| 107 * the addresses. The address being returned belongs to an |
| 108 * interface which connects the lowest index server to this |
| 109 * switch. |
| 110 * |
| 111 * \param row the row address of the desired switch |
| 112 * |
| 113 * \param col the column address of the desired switch |
| 114 * |
| 115 * \returns Ipv6Address of one of the interfaces of the switch |
| 116 * specified by the (row, col) address |
| 117 */ |
| 118 Ipv6Address GetSwitchIpv6Address (uint32_t row, uint32_t col) const; |
| 119 |
| 120 /** |
| 121 * This returns an IPv4 address at the server specified by |
| 122 * the col address. Technically, a server will have multiple |
| 123 * interfaces in the BCube; therefore, it also has multiple |
| 124 * IPv4 addresses. This method only returns one of the addresses. |
| 125 * The address being returned belongs to an interface which |
| 126 * connects the lowest level switch to this server. |
| 127 * |
| 128 * \param col the column address of the desired server |
| 129 * |
| 130 * \returns Ipv4Address of one of the interfaces of the server |
| 131 * specified by the column address |
| 132 */ |
| 133 Ipv4Address GetServerIpv4Address (uint32_t col) const; |
| 134 |
| 135 /** |
| 136 * This returns an IPv6 address at the server specified by |
| 137 * the col address. Technically, a server will have multiple |
| 138 * interfaces in the BCube; therefore, it also has multiple |
| 139 * IPv6 addresses. This method only returns one of the addresses. |
| 140 * The address being returned belongs to an interface which |
| 141 * connects the lowest level switch to this server. |
| 142 * |
| 143 * \param col the column address of the desired server |
| 144 * |
| 145 * \returns Ipv6Address of one of the interfaces of the server |
| 146 * specified by the column address |
| 147 */ |
| 148 Ipv6Address GetServerIpv6Address (uint32_t col) const; |
| 149 |
| 150 /** |
| 151 * \param stack an InternetStackHelper which is used to install |
| 152 * on every node in the BCube |
| 153 */ |
| 154 void InstallStack (InternetStackHelper stack); |
| 155 |
| 156 /** |
| 157 * Assigns IPv4 addresses to all the interfaces of switch |
| 158 * |
| 159 * \param network an IPv4 address representing the network portion |
| 160 * of the IPv4 address |
| 161 * |
| 162 * \param mask the mask length |
| 163 */ |
| 164 void AssignIpv4Addresses (Ipv4Address network, Ipv4Mask mask); |
| 165 |
| 166 /** |
| 167 * Assigns IPv6 addresses to all the interfaces of the switch |
| 168 * |
| 169 * \param network an IPv6 address representing the network portion |
| 170 * of the IPv6 address |
| 171 * |
| 172 * \param prefix the prefix length |
| 173 */ |
| 174 void AssignIpv6Addresses (Ipv6Address network, Ipv6Prefix prefix); |
| 175 |
| 176 /** |
| 177 * Sets up the node canvas locations for every node in the BCube. |
| 178 * This is needed for use with the animation interface |
| 179 * |
| 180 * \param ulx upper left x value |
| 181 * \param uly upper left y value |
| 182 * \param lrx lower right x value |
| 183 * \param lry lower right y value |
| 184 */ |
| 185 void BoundingBox (double ulx, double uly, double lrx, double lry); |
| 186 |
| 187 private: |
| 188 uint32_t m_numLevels; //!< number of l
evels (k) |
| 189 uint32_t m_numServers; //!< number of s
ervers (n) |
| 190 std::vector<NetDeviceContainer> m_levelSwitchDevices; //!< Net Device
container for servers and switches |
| 191 std::vector<Ipv4InterfaceContainer> m_switchInterfaces; //!< IPv4 interf
aces of switch |
| 192 Ipv4InterfaceContainer m_serverInterfaces; //!< IPv4 interf
aces of server |
| 193 std::vector<Ipv6InterfaceContainer> m_switchInterfaces6; //!< IPv6 interf
aces of switch |
| 194 Ipv6InterfaceContainer m_serverInterfaces6; //!< IPv6 interf
aces of server |
| 195 NodeContainer m_switches; //!< all the swi
tches in the BCube |
| 196 NodeContainer m_servers; //!< all the ser
vers in the BCube |
| 197 }; |
| 198 |
| 199 } // namespace ns3 |
| 200 |
| 201 #endif /* POINT_TO_POINT_BCUBE_HELPER_H */ |
OLD | NEW |