nix-vector coding style changes
authorJosh Pelkey <jpelkey@gatech.edu>
Fri, 13 May 2011 14:57:56 -0400
changeset 7183 13fae068d099
parent 7182 5ecfee5d17de
child 7184 a15feb312428
nix-vector coding style changes
src/nix-vector-routing/examples/nix-simple.cc
src/nix-vector-routing/examples/nms-p2p-nix.cc
src/nix-vector-routing/model/ipv4-nix-vector-routing.cc
src/nix-vector-routing/model/ipv4-nix-vector-routing.h
--- a/src/nix-vector-routing/examples/nix-simple.cc	Fri May 13 14:57:43 2011 -0400
+++ b/src/nix-vector-routing/examples/nix-simple.cc	Fri May 13 14:57:56 2011 -0400
@@ -42,7 +42,7 @@
 
 NS_LOG_COMPONENT_DEFINE ("NixSimpleExample");
 
-  int 
+int
 main (int argc, char *argv[])
 {
   LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO);
@@ -64,7 +64,7 @@
   pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));
 
   NodeContainer allNodes = NodeContainer (nodes12, nodes23.Get (1), nodes34.Get (1));
-  
+
   // NixHelper to install nix-vector routing
   // on all nodes
   Ipv4NixVectorHelper nixRouting;
--- a/src/nix-vector-routing/examples/nms-p2p-nix.cc	Fri May 13 14:57:43 2011 -0400
+++ b/src/nix-vector-routing/examples/nms-p2p-nix.cc	Fri May 13 14:57:56 2011 -0400
@@ -83,7 +83,7 @@
   if (nCN < 2) 
     {
       cout << "Number of total CNs (" << nCN << ") lower than minimum of 2"
-        << endl;
+           << endl;
       return 1;
     }
 
@@ -336,7 +336,7 @@
           ifs3[z][i] = address.Assign (ndc3[i]);
         }
     }
-    // Create Ring Links
+  // Create Ring Links
   if (nCN > 1) 
     {
       cout << "Forming Ring Topology..." << endl;
@@ -363,11 +363,11 @@
   cout << "Creating TCP Traffic Flows:" << endl;
   Config::SetDefault ("ns3::OnOffApplication::MaxBytes", UintegerValue (500000));
   Config::SetDefault ("ns3::OnOffApplication::OnTime",
-      RandomVariableValue (ConstantVariable (1)));
+                      RandomVariableValue (ConstantVariable (1)));
   Config::SetDefault ("ns3::OnOffApplication::OffTime",
-      RandomVariableValue (ConstantVariable (0)));
+                      RandomVariableValue (ConstantVariable (0)));
   Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (512));
-  
+
   UniformVariable urng;
   int r1;
   double r2;
@@ -386,7 +386,7 @@
             {
               // Sinks
               PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory",
-                  InetSocketAddress (Ipv4Address::GetAny (), 9999));
+                                           InetSocketAddress (Ipv4Address::GetAny (), 9999));
               ApplicationContainer sinkApp = sinkHelper.Install (
                   nodes_net2LAN[z][i][j].Get (0));
               sinkApp.Start (Seconds (0.0));
@@ -395,12 +395,12 @@
               r2 = 10 * urng.GetValue ();
               OnOffHelper client ("ns3::TcpSocketFactory", Address ());
               AddressValue remoteAddress(InetSocketAddress (
-                  ifs2LAN[z][i][j].GetAddress (0), 9999));
-            client.SetAttribute ("Remote", remoteAddress);
-            ApplicationContainer clientApp;
-            clientApp.Add (client.Install (nodes_net1[x][r1].Get (0)));
-            clientApp.Start (Seconds (r2));
-          }
+                                           ifs2LAN[z][i][j].GetAddress (0), 9999));
+              client.SetAttribute ("Remote", remoteAddress);
+              ApplicationContainer clientApp;
+              clientApp.Add (client.Install (nodes_net1[x][r1].Get (0)));
+              clientApp.Start (Seconds (r2));
+            }
         }
       // Subnet 3 LANs
       cout << "Net3 ]" << endl;
@@ -410,7 +410,7 @@
             {
               // Sinks
               PacketSinkHelper sinkHelper ("ns3::TcpSocketFactory",
-                  InetSocketAddress (Ipv4Address::GetAny (), 9999));
+                                           InetSocketAddress (Ipv4Address::GetAny (), 9999));
               ApplicationContainer sinkApp = sinkHelper.Install (
                   nodes_net3LAN[z][i][j].Get (0));
               sinkApp.Start (Seconds (0.0));
@@ -419,7 +419,7 @@
               r2 = 10 * urng.GetValue ();
               OnOffHelper client ("ns3::TcpSocketFactory", Address ());
               AddressValue remoteAddress (InetSocketAddress (
-                  ifs3LAN[z][i][j].GetAddress (0), 9999));
+                                            ifs3LAN[z][i][j].GetAddress (0), 9999));
               client.SetAttribute ("Remote", remoteAddress);
               ApplicationContainer clientApp;
               clientApp.Add (client.Install (nodes_net1[x][r1].Get (0)));
--- a/src/nix-vector-routing/model/ipv4-nix-vector-routing.cc	Fri May 13 14:57:43 2011 -0400
+++ b/src/nix-vector-routing/model/ipv4-nix-vector-routing.cc	Fri May 13 14:57:56 2011 -0400
@@ -40,12 +40,12 @@
   static TypeId tid = TypeId ("ns3::Ipv4NixVectorRouting")
     .SetParent<Ipv4RoutingProtocol> ()
     .AddConstructor<Ipv4NixVectorRouting> ()
-    ;
+  ;
   return tid;
 }
 
 Ipv4NixVectorRouting::Ipv4NixVectorRouting ()
-:m_totalNeighbors (0)
+  : m_totalNeighbors (0)
 {
   NS_LOG_FUNCTION_NOARGS ();
 }
@@ -88,20 +88,20 @@
 void
 Ipv4NixVectorRouting::FlushGlobalNixRoutingCache ()
 {
-    NS_LOG_FUNCTION_NOARGS ();
-    NodeList::Iterator listEnd = NodeList::End ();
-    for (NodeList::Iterator i = NodeList::Begin (); i != listEnd; i++)
-      {
-        Ptr<Node> node = *i;
-        Ptr<Ipv4NixVectorRouting> rp = node->GetObject<Ipv4NixVectorRouting> ();
-        if (!rp)
-          {
-            continue;
-          }
-        NS_LOG_LOGIC ("Flushing Nix caches.");
-        rp->FlushNixCache ();
-        rp->FlushIpv4RouteCache ();
-      }
+  NS_LOG_FUNCTION_NOARGS ();
+  NodeList::Iterator listEnd = NodeList::End ();
+  for (NodeList::Iterator i = NodeList::Begin (); i != listEnd; i++)
+    {
+      Ptr<Node> node = *i;
+      Ptr<Ipv4NixVectorRouting> rp = node->GetObject<Ipv4NixVectorRouting> ();
+      if (!rp)
+        {
+          continue;
+        }
+      NS_LOG_LOGIC ("Flushing Nix caches.");
+      rp->FlushNixCache ();
+      rp->FlushIpv4RouteCache ();
+    }
 }
 
 void
@@ -214,7 +214,7 @@
         {
           NS_LOG_LOGIC ("Adding loopback to nix.");
           NS_LOG_LOGIC ("Adding Nix: " << i << " with " << nixVector->BitCount (numberOfDevices) 
-                        << " bits, for node " << m_node->GetId());
+                                       << " bits, for node " << m_node->GetId());
           nixVector->AddNeighborIndex (i, nixVector->BitCount (numberOfDevices));
           return true;
         }
@@ -286,7 +286,7 @@
       totalNeighbors += netDeviceContainer.GetN ();
     }
   NS_LOG_LOGIC ("Adding Nix: " << destId << " with " 
-                << nixVector->BitCount (totalNeighbors) << " bits, for node " << parentNode->GetId());
+                               << nixVector->BitCount (totalNeighbors) << " bits, for node " << parentNode->GetId());
   nixVector->AddNeighborIndex (destId, nixVector->BitCount (totalNeighbors));
 
   // recurse through parent vector, grabbing the path 
@@ -520,7 +520,7 @@
         {
           m_totalNeighbors = FindTotalNeighbors ();
         }
-  
+
       // Get the interface number that we go out of, by extracting
       // from the nix-vector
       uint32_t numberOfBits = nixVectorForPacket->BitCount (m_totalNeighbors);
@@ -603,8 +603,8 @@
 
 bool 
 Ipv4NixVectorRouting::RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
-                             UnicastForwardCallback ucb, MulticastForwardCallback mcb,
-                             LocalDeliverCallback lcb, ErrorCallback ecb)
+                                  UnicastForwardCallback ucb, MulticastForwardCallback mcb,
+                                  LocalDeliverCallback lcb, ErrorCallback ecb)
 {
   NS_LOG_FUNCTION_NOARGS ();
 
@@ -648,7 +648,7 @@
     }
 
   NS_LOG_LOGIC ("At Node " << m_node->GetId() << ", Extracting " << numberOfBits << 
-                       " bits from Nix-vector: " << nixVector << " : " << *nixVector);
+                " bits from Nix-vector: " << nixVector << " : " << *nixVector);
 
   // call the unicast callback
   // local deliver is handled by Ipv4StaticRoutingImpl
@@ -827,11 +827,11 @@
                       continue;
                     }
                 }
-                if (!(localNetDevice->IsLinkUp ()))
-                  {
-                    NS_LOG_LOGIC ("Link is down.");
-                    continue;
-                  }
+              if (!(localNetDevice->IsLinkUp ()))
+                {
+                  NS_LOG_LOGIC ("Link is down.");
+                  continue;
+                }
               Ptr<Channel> channel = localNetDevice->GetChannel ();
               if (channel == 0)
                 { 
@@ -868,7 +868,7 @@
       // It is now black.
       greyNodeList.pop ();
     }
-  
+
   // Didn't find the dest...
   return false;
 }
--- a/src/nix-vector-routing/model/ipv4-nix-vector-routing.h	Fri May 13 14:57:43 2011 -0400
+++ b/src/nix-vector-routing/model/ipv4-nix-vector-routing.h	Fri May 13 14:57:56 2011 -0400
@@ -48,123 +48,123 @@
  */
 class Ipv4NixVectorRouting : public Ipv4RoutingProtocol
 {
-  public:
-    Ipv4NixVectorRouting ();
-    ~Ipv4NixVectorRouting ();
-    /** 
-     * @brief The Interface ID of the Global Router interface. 
-     * 
-     * @see Object::GetObject () 
-     */
-    static TypeId GetTypeId (void); 
-    /** 
-     * @brief Set the Node pointer of the node for which this
-     * routing protocol is to be placed
-     *
-     * @param node Node pointer 
-     */
-    void SetNode (Ptr<Node> node);
+public:
+  Ipv4NixVectorRouting ();
+  ~Ipv4NixVectorRouting ();
+  /**
+   * @brief The Interface ID of the Global Router interface.
+   *
+   * @see Object::GetObject ()
+   */
+  static TypeId GetTypeId (void);
+  /**
+   * @brief Set the Node pointer of the node for which this
+   * routing protocol is to be placed
+   *
+   * @param node Node pointer
+   */
+  void SetNode (Ptr<Node> node);
 
-    /** 
-     * @brief Called when run-time link topology change occurs 
-     * which iterates through the node list and flushes any 
-     * nix vector caches
-     * 
-     */
-    void FlushGlobalNixRoutingCache (void);
+  /**
+   * @brief Called when run-time link topology change occurs
+   * which iterates through the node list and flushes any
+   * nix vector caches
+   *
+   */
+  void FlushGlobalNixRoutingCache (void);
 
-  private:
-    /* flushes the cache which stores nix-vector based on
-     * destination IP */
-    void FlushNixCache (void);
+private:
+  /* flushes the cache which stores nix-vector based on
+   * destination IP */
+  void FlushNixCache (void);
 
-    /* flushes the cache which stores the Ipv4 route 
-     * based on the destination IP */
-    void FlushIpv4RouteCache (void);
+  /* flushes the cache which stores the Ipv4 route
+   * based on the destination IP */
+  void FlushIpv4RouteCache (void);
 
-    /* upon a run-time topology change caches are 
-     * flushed and the total number of neighbors is 
-     * reset to zero */
-    void ResetTotalNeighbors (void);
+  /* upon a run-time topology change caches are
+   * flushed and the total number of neighbors is
+   * reset to zero */
+  void ResetTotalNeighbors (void);
 
-    /*  takes in the source node and dest IP and calls GetNodeByIp, 
-     *  BFS, accounting for any output interface specified, and finally 
-     *  BuildNixVector to return the built nix-vector */
-    Ptr<NixVector> GetNixVector (Ptr<Node>, Ipv4Address, Ptr<NetDevice>);
+  /*  takes in the source node and dest IP and calls GetNodeByIp,
+   *  BFS, accounting for any output interface specified, and finally
+   *  BuildNixVector to return the built nix-vector */
+  Ptr<NixVector> GetNixVector (Ptr<Node>, Ipv4Address, Ptr<NetDevice>);
 
-    /* checks the cache based on dest IP for the nix-vector */
-    Ptr<NixVector> GetNixVectorInCache (Ipv4Address);
+  /* checks the cache based on dest IP for the nix-vector */
+  Ptr<NixVector> GetNixVectorInCache (Ipv4Address);
 
-    /* checks the cache based on dest IP for the Ipv4Route */
-    Ptr<Ipv4Route> GetIpv4RouteInCache (Ipv4Address);
+  /* checks the cache based on dest IP for the Ipv4Route */
+  Ptr<Ipv4Route> GetIpv4RouteInCache (Ipv4Address);
 
-    /* given a net-device returns all the adjacent net-devices, 
-     * essentially getting the neighbors on that channel */
-    void GetAdjacentNetDevices (Ptr<NetDevice>, Ptr<Channel>, NetDeviceContainer &);
+  /* given a net-device returns all the adjacent net-devices,
+   * essentially getting the neighbors on that channel */
+  void GetAdjacentNetDevices (Ptr<NetDevice>, Ptr<Channel>, NetDeviceContainer &);
 
-    /* iterates through the node list and finds the one 
-     * corresponding to the given Ipv4Address */
-    Ptr<Node> GetNodeByIp (Ipv4Address);
+  /* iterates through the node list and finds the one
+   * corresponding to the given Ipv4Address */
+  Ptr<Node> GetNodeByIp (Ipv4Address);
 
-    /* Recurses the parent vector, created by BFS and actually builds the nixvector */
-    bool BuildNixVector (const std::vector< Ptr<Node> > & parentVector, uint32_t source, uint32_t dest, Ptr<NixVector> nixVector);
+  /* Recurses the parent vector, created by BFS and actually builds the nixvector */
+  bool BuildNixVector (const std::vector< Ptr<Node> > & parentVector, uint32_t source, uint32_t dest, Ptr<NixVector> nixVector);
 
-    /* special variation of BuildNixVector for when a node is sending to itself */
-    bool BuildNixVectorLocal (Ptr<NixVector> nixVector);
+  /* special variation of BuildNixVector for when a node is sending to itself */
+  bool BuildNixVectorLocal (Ptr<NixVector> nixVector);
 
-    /* simple iterates through the nodes net-devices and determines 
-     * how many neighbors it has */
-    uint32_t FindTotalNeighbors (void);
+  /* simple iterates through the nodes net-devices and determines
+   * how many neighbors it has */
+  uint32_t FindTotalNeighbors (void);
 
-    /* determine if the netdevice is bridged */
-    Ptr<BridgeNetDevice> NetDeviceIsBridged (Ptr<NetDevice> nd) const;
+  /* determine if the netdevice is bridged */
+  Ptr<BridgeNetDevice> NetDeviceIsBridged (Ptr<NetDevice> nd) const;
 
 
-    /* Nix index is with respect to the neighbors.  The net-device index must be 
-     * derived from this */
-    uint32_t FindNetDeviceForNixIndex (uint32_t nodeIndex, Ipv4Address & gatewayIp);
+  /* Nix index is with respect to the neighbors.  The net-device index must be
+   * derived from this */
+  uint32_t FindNetDeviceForNixIndex (uint32_t nodeIndex, Ipv4Address & gatewayIp);
 
-    /* Breadth first search algorithm
-     * Param1: total number of nodes
-     * Param2: Source Node
-     * Param3: Dest Node
-     * Param4: (returned) Parent vector for retracing routes
-     * Param5: specific output interface to use from source node, if not null
-     * Returns: false if dest not found, true o.w.
-     */
-    bool BFS (uint32_t numberOfNodes, 
-             Ptr<Node> source, 
-             Ptr<Node> dest, 
-             std::vector< Ptr<Node> > & parentVector,
-             Ptr<NetDevice> oif);
+  /* Breadth first search algorithm
+   * Param1: total number of nodes
+   * Param2: Source Node
+   * Param3: Dest Node
+   * Param4: (returned) Parent vector for retracing routes
+   * Param5: specific output interface to use from source node, if not null
+   * Returns: false if dest not found, true o.w.
+   */
+  bool BFS (uint32_t numberOfNodes,
+            Ptr<Node> source,
+            Ptr<Node> dest,
+            std::vector< Ptr<Node> > & parentVector,
+            Ptr<NetDevice> oif);
 
-    void DoDispose (void);
+  void DoDispose (void);
 
-    /* From Ipv4RoutingProtocol */
-    virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr);
-    virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
-                             UnicastForwardCallback ucb, MulticastForwardCallback mcb,
-                             LocalDeliverCallback lcb, ErrorCallback ecb);  
-    virtual void NotifyInterfaceUp (uint32_t interface); 
-    virtual void NotifyInterfaceDown (uint32_t interface); 
-    virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address); 
-    virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address); 
-    virtual void SetIpv4 (Ptr<Ipv4> ipv4); 
-    virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
+  /* From Ipv4RoutingProtocol */
+  virtual Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr);
+  virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
+                           UnicastForwardCallback ucb, MulticastForwardCallback mcb,
+                           LocalDeliverCallback lcb, ErrorCallback ecb);
+  virtual void NotifyInterfaceUp (uint32_t interface);
+  virtual void NotifyInterfaceDown (uint32_t interface);
+  virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
+  virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
+  virtual void SetIpv4 (Ptr<Ipv4> ipv4);
+  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
 
 
-    /* cache stores nix-vectors based on destination ip */
-    NixMap_t m_nixCache;
+  /* cache stores nix-vectors based on destination ip */
+  NixMap_t m_nixCache;
 
-    /* cache stores Ipv4Routes based on destination ip */
-    Ipv4RouteMap_t m_ipv4RouteCache;
+  /* cache stores Ipv4Routes based on destination ip */
+  Ipv4RouteMap_t m_ipv4RouteCache;
 
-    Ptr<Ipv4> m_ipv4;
-    Ptr<Node> m_node;
+  Ptr<Ipv4> m_ipv4;
+  Ptr<Node> m_node;
 
-    /* total neighbors used for nix-vector to determine
-     * number of bits */
-    uint32_t m_totalNeighbors;
+  /* total neighbors used for nix-vector to determine
+   * number of bits */
+  uint32_t m_totalNeighbors;
 };
 } // namespace ns3
 #endif