disallow routing on bridge devices with IP address, fix wifi-wired-bridging
authorCraig Dowell <craigdo@ee.washington.edu>
Wed, 26 Nov 2008 13:48:53 -0800
changeset 3947 756887a9bbea
parent 3946 6a20c485ddb5
child 3948 a8e97cf0aae3
disallow routing on bridge devices with IP address, fix wifi-wired-bridging
examples/wifi-wired-bridging.cc
src/routing/global-routing/global-route-manager-impl.cc
src/routing/global-routing/global-router-interface.cc
--- a/examples/wifi-wired-bridging.cc	Mon Nov 24 21:39:00 2008 -0800
+++ b/examples/wifi-wired-bridging.cc	Wed Nov 26 13:48:53 2008 -0800
@@ -14,30 +14,32 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-// Default network topology
+// Default network topology includes some number of AP nodes specified by
+// the variable nWifis (defaults to two).  Off of each AP node, there are some
+// number of STA nodes specified by the variable nStas (defaults to two).
+// Each AP talks to its associated STA nodes.  There are bridge net devices
+// on each AP node that bridge the whole thing into one network.
 //
 //      +-----+      +-----+            +-----+      +-----+
-//      | sta |      | sta |            | sta |      | sta | 
+//      | STA |      | STA |            | STA |      | STA | 
 //      +-----+      +-----+            +-----+      +-----+
-//    192.168.1.2  192.168.1.3        192.168.2.2  192.168.2.3
+//    192.168.0.3  192.168.0.4        192.168.0.5  192.168.0.6
 //      --------     --------           --------     --------
 //      WIFI STA     WIFI STA           WIFI STA     WIFI STA
-//      --------     --------     |     --------     --------
+//      --------     --------           --------     --------
 //        ((*))       ((*))       |      ((*))        ((*))
 //                                |   
-//              ((*))             |            ((*))
-//             -------            |           -------
-//    ######## WIFI AP                        WIFI AP #########
-//    #        -------                        -------         #
-//  B #      102.168.1.1                    102.168.2.1       # B
-//  R #     +----------+                   +----------+       # R
-//  I #     | backbone |                   | backbone |       # I
-//  D #     +----------+                   +----------+       # D
-//  G #      192.168.0.1                    192.168.0.2       # G
-//  E #          ----                           ----          # E
-//    ########## CSMA                           CSMA ##########    
-//                |                              |      
-//                ================================
+//              ((*))             |             ((*))
+//             -------                         -------
+//             WIFI AP   CSMA ========= CSMA   WIFI AP 
+//             -------   ----           ----   -------
+//             ##############           ##############
+//                 BRIDGE                   BRIDGE
+//             ##############           ############## 
+//               192.168.0.1              192.168.0.2
+//               +---------+              +---------+  
+//               | AP Node |              | AP Node |
+//               +---------+              +---------+  
 //
 
 #include "ns3/core-module.h"
@@ -86,7 +88,6 @@
   stack.Install (backboneNodes);
 
   backboneDevices = csma.Install (backboneNodes);
-  backboneInterfaces = ip.Assign (backboneDevices);
 
   double wifiX = 0.0;
   for (uint32_t i = 0; i < nWifis; ++i)
@@ -109,7 +110,6 @@
       wifiPhy.SetChannel (wifiChannel.Create ());
 
       sta.Create (nStas);
-      ip.NewNetwork ();
       mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
 				     "MinX", DoubleValue (wifiX),
 				     "MinY", DoubleValue (0.0),
@@ -127,8 +127,12 @@
 		   "BeaconGeneration", BooleanValue (true),
 		   "BeaconInterval", TimeValue (Seconds (2.5)));
       apDev = wifi.Install (wifiPhy, backboneNodes.Get (i));
-      apInterface = ip.Assign (apDev);
-      bridge.Install (backboneNodes.Get (i), NetDeviceContainer (apDev, backboneDevices.Get (i)));
+
+      NetDeviceContainer bridgeDev;
+      bridgeDev = bridge.Install (backboneNodes.Get (i), NetDeviceContainer (apDev, backboneDevices.Get (i)));
+
+      // assign AP IP address to bridge, not wifi
+      apInterface = ip.Assign (bridgeDev);
 
       // setup the STAs
       stack.Install (sta);
--- a/src/routing/global-routing/global-route-manager-impl.cc	Mon Nov 24 21:39:00 2008 -0800
+++ b/src/routing/global-routing/global-route-manager-impl.cc	Wed Nov 26 13:48:53 2008 -0800
@@ -214,7 +214,7 @@
           return *i;
         }
     }
-  NS_ASSERT_MSG(false, "Index <n> out of range.");
+  NS_ASSERT_MSG (false, "Index <n> out of range.");
   return 0;
 }
 
@@ -726,7 +726,7 @@
 /*
   if (w->GetVertexType () == SPFVertex::VertexNetwork && l)
     {
-        NS_ASSERT_MSG(0, "Error:  SPFNexthopCalculation parameter problem");
+        NS_ASSERT_MSG (0, "Error:  SPFNexthopCalculation parameter problem");
     }
 */
 
@@ -778,7 +778,7 @@
 // return the link record describing the link from <w> to <v>.  Think of it as
 // SPFGetLink.
 //
-          NS_ASSERT(l);
+          NS_ASSERT (l);
           GlobalRoutingLinkRecord *linkRemote = 0;
           linkRemote = SPFGetNextLink (w, v, linkRemote);
 // 
@@ -792,7 +792,7 @@
 // from the root node to the host represented by vertex <w>, you have to send
 // the packet to the next hop address specified in w->m_nextHop.
 //
-          w->SetNextHop(linkRemote->GetLinkData ());
+          w->SetNextHop (linkRemote->GetLinkData ());
 // 
 // Now find the outgoing interface corresponding to the point to point link
 // from the perspective of <v> -- remember that <l> is the link "from"
@@ -846,7 +846,7 @@
  * use can then be derived from the next hop IP address (or 
  * it can be inherited from the parent network).
  */
-                w->SetNextHop(linkRemote->GetLinkData ());
+                w->SetNextHop (linkRemote->GetLinkData ());
                 w->SetOutgoingTypeId (v->GetOutgoingTypeId ());
                 NS_LOG_LOGIC ("Next hop from " << 
                   v->GetVertexId () << " to " << w->GetVertexId () << 
@@ -1001,7 +1001,7 @@
 // of the tree.  Initially, this queue is empty.
 //
   CandidateQueue candidate;
-  NS_ASSERT(candidate.Size () == 0);
+  NS_ASSERT (candidate.Size () == 0);
 //
 // Initialize the shortest-path tree to only contain the router doing the 
 // calculation.  Each router (and corresponding network) is a vertex in the
@@ -1108,7 +1108,7 @@
         }
       else
         {
-          NS_ASSERT_MSG(0, "illegal SPFVertex type");
+          NS_ASSERT_MSG (0, "illegal SPFVertex type");
         }
 //
 // RFC2328 16.1. (5). 
--- a/src/routing/global-routing/global-router-interface.cc	Mon Nov 24 21:39:00 2008 -0800
+++ b/src/routing/global-routing/global-router-interface.cc	Wed Nov 26 13:48:53 2008 -0800
@@ -589,8 +589,7 @@
         {
           uint32_t ifIndexBridge;
           bool rc = FindIfIndexForDevice(node, ndLocal, ifIndexBridge);
-          NS_ABORT_MSG_IF (rc, "GlobalRouter::ProcessBridgedBroadcastLink(): "
-                               "Bridge ports must not have an IPv4 interface index");
+          NS_ABORT_MSG_IF (rc, "GlobalRouter::DiscoverLSAs(): Bridge ports must not have an IPv4 interface index");
         }
 
       //
@@ -782,8 +781,18 @@
 GlobalRouter::ProcessBridgedBroadcastLink (Ptr<NetDevice> nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
 {
   NS_LOG_FUNCTION (nd << pLSA << &c);
+  NS_ASSERT_MSG (nd->IsBridge (), "GlobalRouter::ProcessBridgedBroadcastLink(): Called with non-bridge net device");
 
-  NS_ASSERT_MSG (nd->IsBridge (), "GlobalRouter::ProcessBridgedBroadcastLink(): Called with non-bridge net device");
+#if 0
+  //
+  // It is possible to admit the possibility that a bridge device on a node
+  // can also participate in routing.  This would surprise people who don't
+  // come from Microsoft-land where they do use such a construct.  Based on
+  // the principle of least-surprise, we will leave the relatively simple
+  // code in place to do this, but not enable it until someone really wants
+  // the capability.  Even then, we will not enable this code as a default
+  // but rather something you will have to go and turn on.
+  //
 
   Ptr<BridgeNetDevice> bnd = nd->GetObject<BridgeNetDevice> ();
   NS_ABORT_MSG_UNLESS (bnd, "GlobalRouter::DiscoverLSAs (): GetObject for <BridgeNetDevice> failed");
@@ -817,6 +826,7 @@
   // to do is to repeat what is done for a single broadcast link on all of 
   // those net devices living under the bridge (trolls?)
   //
+
   bool areTransitNetwork = false;
   Ipv4Address desigRtr ("255.255.255.255");
 
@@ -921,6 +931,7 @@
       pLSA->AddLinkRecord (plr);
       plr = 0;
     }
+#endif
 }
 
   void