Skip to content

internet: Add PrintRoute function For Global Routing

This MR is with reference to the Patch Requirement for the IPv6 Global Routing GSoC Project.

The Patch Requiement states the following:

  • Add a function to print the path that a packet will use (according to Ipv4GlobalRouting), i.e., given source and destination IP print the IP addresses of the nodes that Ipv4GlobalRouting will use.

The details of the changes are given below:

  • Add a public static function Ipv4GlobalRoutingHelper::PrintRoute.

    It has 4 overloads.

    PrintRoute(): Prints the route from:

    • Source node to destination node given a output stream
    • Source Node to a destination IP given a output stream
    • The other two overloads are for defaulting to the std::cout output stream

If no route is found it prints:

 >There does not exist a path from Node x to Node y.
  • Add Ipv4GlobalRoutingHelper::PrintRouteAt, which helps schedule the print time.

    This also has similar 4 Overloads but takes in a printTime argument to determine when in the simulation the output is printed.

  • Add GlobalRouteManagerImpl::PrintRoute(),(2 overloads for the Node and IP case).This is called by Ipv4GlobalRoutingHelper::PrintRoute() via the GlobalRouteManager class. It uses the LookUpGlobal() function in Ipv4GlobalRouting to find gateways to the destination and print them.

  • Add GlobalRouteManagerImpl::GetNodeByIP, which searches all nodes and their interfaces to find the node assigned to a given IPv4 address. This is a helper function used in

    GlobalRouteManagerImpl::PrintRoutingPath().

  • Add #include "ns3/ipv4-routing-helper.h" in src/internet/model/global-route-manager-impl.h

  • Make GlobalRouteManagerImpl a friend class ofsrc/internet/model/ipv4-global-routing.hto use the LookUpGlobal() function.

  • Add a new example file src/internet/examples/Ipv4-global-routing-print-route.cc to explain its use.

  • Add Ipv4-global-routing-print-route.cc into the CMAKE list

The following is the expected output and network topology for the example file:

/*Simple point to point links:






*
      ________
     /        \
   n0 -- n1 -- n2 -- n3     n4----n5

   n0 IP: 10.1.1.1, 10.1.4.1
   n1 IP: 10.1.1.2, 10.1.2.1
   n2 IP: 10.1.2.2, 10.1.3.1, 10.1.4.2
   n3 IP: 10.1.3.2
   n4 IP: 10.1.5.1
   n5 IP: 10:1:5:2

Test 1:Route from n1 to 10.1.2.2 Expected Output:

PrintRoute at Time: +0s from Node 1 to address 10.1.2.2, 64 hops Max.
 1  10.1.2.2 (Node 2)

Test 2: Route from n1 to n3 Expected Output:

PrintRoute at Time: +0s from Node 1 to Node 3, 64 hops Max.
 1  10.1.2.2 (Node 2)
 2  10.1.3.2 (Node 3)

Test 3: Route from n0 to 10.1.5.2 Expected Output:

PrintRoute at Time: +0s from Node 0 to address 10.1.5.2, 64 hops Max.
There does not exist a path from Node 0 to Node 5.

Test 4: Route from n0 to n3 Expected Output:

PrintRoute at Time: +0s from Node 0 to Node 3, 64 hops Max.
 1  10.1.4.2 (Node 2)
 2  10.1.3.2 (Node 3)

Test 5: Route from n0 to 10.1.2.2Expected Output:

PrintRoute at Time: +0s from Node 0 to address 10.1.2.2, 64 hops Max.
 1  10.1.4.2
    10.1.2.2

Test 6: Route from n0 to n3 Expected Output:

PrintRoute at Time: +0s from Node 0 to Node 3, 64 hops Max.
 1  10.1.4.2
 2  10.1.3.2

Test 7: Route from n1 to 10.1.2.2 Expected Output:

PrintRoute at Time: +2s from Node 1 to address 10.1.2.2, 64 hops Max.
 1  10.1.2.2 (Node 2)

Test 8: Route from n1 to n3 Expected Output:

PrintRoute at Time: +4s from Node 1 to Node 3, 64 hops Max.
 1  10.1.2.2 (Node 2)
 2  10.1.3.2 (Node 3)

Signed-off-by: Shashwat Patni shashwatpatni25@gmail.com

Edited by Shashwat Patni

Merge request reports

Loading