ECMP in ns3

702 views
Skip to first unread message

Nick

unread,
May 1, 2018, 2:44:11 AM5/1/18
to ns-3-users
Hi everyone,I am a beginner in ns3.
This is my code and my topology.
And the outputs suggest that inter-cluster routing doesn't work,and the nodes which connect to the same switch can route each other.
I want to know that if I have to impl ECMP or there is a way I didn't find out or I just impl the topo in a wrong way.
Best regards.
p1.cc
a副本.png

richard

unread,
May 1, 2018, 6:01:03 AM5/1/18
to ns-3-users
You can enable a per-packet ECMP load balancing by enabling Ipv4GlobalRouting::RandomEcmpRouting.

However, if you want you can have a look at the code and implement a per-flow load balancing, for that you have to go to ipv4-global-routing.cc, check how the RandomEcmpRouting is done and then you add a new flag to enable PerFlowEcmpRouting, take the packet, hash the 5-tuple % number of output interfaces and then you select output. If you have more questions ask me and i can give you my already done implementation (however i did that for ns3.26 so you would have to copy it carefully).

Kind regards,
Richard

方浩文

unread,
May 1, 2018, 9:43:57 AM5/1/18
to ns-3-...@googlegroups.com
Dear Richard
Thanks for your answer, and it would be really helpful if I can have your code.It's very generous of you.
Best regards.


--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/CuEjOFbwCCU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.

richard

unread,
May 1, 2018, 6:52:24 PM5/1/18
to ns-3-users
You can find the ipv4-global-routing.cc attached. You can see that I implemented several ECMPs, feel free to use them. 


On Tuesday, 1 May 2018 15:43:57 UTC+2, Nick wrote:
Dear Richard
Thanks for your answer, and it would be really helpful if I can have your code.It's very generous of you.
Best regards.

2018年5月1日 下午6:01,"richard" <richard....@gmail.com>写道:
You can enable a per-packet ECMP load balancing by enabling Ipv4GlobalRouting::RandomEcmpRouting.

However, if you want you can have a look at the code and implement a per-flow load balancing, for that you have to go to ipv4-global-routing.cc, check how the RandomEcmpRouting is done and then you add a new flag to enable PerFlowEcmpRouting, take the packet, hash the 5-tuple % number of output interfaces and then you select output. If you have more questions ask me and i can give you my already done implementation (however i did that for ns3.26 so you would have to copy it carefully).

Kind regards,
Richard




On Tuesday, 1 May 2018 08:44:11 UTC+2, Nick wrote:
Hi everyone,I am a beginner in ns3.
This is my code and my topology.
And the outputs suggest that inter-cluster routing doesn't work,and the nodes which connect to the same switch can route each other.
I want to know that if I have to impl ECMP or there is a way I didn't find out or I just impl the topo in a wrong way.
Best regards.

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/CuEjOFbwCCU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
ipv4-global-routing.cc

方浩文

unread,
May 2, 2018, 2:30:24 AM5/2/18
to ns-3-...@googlegroups.com
Thanks a lot!  :)

To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.

oloa...@gmail.com

unread,
May 3, 2018, 8:06:13 AM5/3/18
to ns-3-users

Dear Richard,

Currently, I am also working with flow based traffic through multi-path network. Thank you for sharing your code.
Btw, for implementing flow-based with ECMP routing protocol, did you work only with ipv4-global-routing.cc file?

Ones more, if it is possible, would you mind to share your script example in using flow based in ECMP.

Thank you,

Steven    

richard

unread,
May 3, 2018, 12:30:44 PM5/3/18
to ns-3-users
I only modified that one, the main script i can not find it, but you just have to set the routing variable to ECMP and use Point To Point interfaces the rest should be normal ns3. 

oloa...@gmail.com

unread,
May 3, 2018, 2:09:32 PM5/3/18
to ns-3-users

Dear Richard, thanks for your quick respons.

I have tried to run the scenario by setting routing variable to ECMP, however I found some errors about variable declaration, like below:

--------------------------------
../src/internet/model/ipv4-global-routing.cc: In static member function ‘static ns3::TypeId ns3::Ipv4GlobalRouting::GetTypeId()’:
../src/internet/model/ipv4-global-routing.cc:71:30: error: ‘ECMP_NONE’ was not declared in this scope
                    EnumValue(ECMP_NONE),
                              ^
../src/internet/model/ipv4-global-routing.cc:72:38: error: ‘m_ecmpMode’ is not a member of ‘ns3::Ipv4GlobalRouting’
                    MakeEnumAccessor(&Ipv4GlobalRouting::m_ecmpMode),
                                      ^
../src/internet/model/ipv4-global-routing.cc:73:58: error: ‘ECMP_RANDOM’ was not declared in this scope
                    MakeEnumChecker(ECMP_NONE,"ECMP_NONE",ECMP_RANDOM,"ECMP_RANDOM",


------------------------------

Would you mind to give me any hint why this is happen? Here in I attached the script that I used. Thanks

Steven
ecmp-routing-1.cc

richard

unread,
May 3, 2018, 6:06:56 PM5/3/18
to ns-3-users
did you add all the variables to the .h?

oloa...@gmail.com

unread,
May 14, 2018, 3:43:31 PM5/14/18
to ns-3-users

Hi Richard, I am sorry for my late respond. I have added all variables like:  m_ecmpMode, m_flowletGap, m_drillRandomChecks, ECMP_RANDOM, ECMP_PER_FLOW to the .h file. I set types of all variables as "bool".
However I still got many errors as below. Would you mind to give me any hint to solve this problem?

Rey

-------

[1425/2642] Compiling src/internet/model/ipv4-global-routing.cc
In file included from ../src/internet/model/ipv4-global-routing.cc:32:0:
../src/internet/model/ipv4-global-routing.h: In static member function ‘static ns3::TypeId ns3::Ipv4GlobalRouting::GetTypeId()’:
../src/internet/model/ipv4-global-routing.h:241:8: error: invalid use of member ‘ns3::Ipv4GlobalRouting::ECMP_NONE’ in static member function
   bool ECMP_NONE;
        ^
../src/internet/model/ipv4-global-routing.cc:71:30: error: from this location
                    EnumValue(ECMP_NONE),
                              ^
In file included from ../src/internet/model/ipv4-global-routing.cc:32:0:
../src/internet/model/ipv4-global-routing.h:241:8: error: invalid use of member ‘ns3::Ipv4GlobalRouting::ECMP_NONE’ in static member function
   bool ECMP_NONE;
        ^
../src/internet/model/ipv4-global-routing.cc:73:36: error: from this location

                    MakeEnumChecker(ECMP_NONE,"ECMP_NONE",ECMP_RANDOM,"ECMP_RANDOM",
                                    ^
In file included from ../src/internet/model/ipv4-global-routing.cc:32:0:
../src/internet/model/ipv4-global-routing.h:242:8: error: invalid use of member ‘ns3::Ipv4GlobalRouting::ECMP_RANDOM’ in static member function
   bool ECMP_RANDOM;
        ^
../src/internet/model/ipv4-global-routing.cc:73:58: error: from this location

                    MakeEnumChecker(ECMP_NONE,"ECMP_NONE",ECMP_RANDOM,"ECMP_RANDOM",
                                                          ^
In file included from ../src/internet/model/ipv4-global-routing.cc:32:0:
../src/internet/model/ipv4-global-routing.h:243:8: error: invalid use of member ‘ns3::Ipv4GlobalRouting::ECMP_PER_FLOW’ in static member function
   bool ECMP_PER_FLOW;
        ^
../src/internet/model/ipv4-global-routing.cc:74:5: error: from this location
     ECMP_PER_FLOW, "ECMP_PER_FLOW",
     ^
In file included from ../src/internet/model/ipv4-global-routing.cc:32:0:
../src/internet/model/ipv4-global-routing.h:244:8: error: invalid use of member ‘ns3::Ipv4GlobalRouting::ECMP_RR’ in static member function
   bool ECMP_RR;
        ^
../src/internet/model/ipv4-global-routing.cc:75:12: error: from this location
            ECMP_RR, "ECMP_RR",
            ^
In file included from ../src/internet/model/ipv4-global-routing.cc:32:0:
../src/internet/model/ipv4-global-routing.h:245:8: error: invalid use of member ‘ns3::Ipv4GlobalRouting::ECMP_RANDOM_FLOWLET’ in static member function
   bool ECMP_RANDOM_FLOWLET;
        ^
../src/internet/model/ipv4-global-routing.cc:76:12: error: from this location
            ECMP_RANDOM_FLOWLET, "ECMP_RANDOM_FLOWLET",
            ^
In file included from ../src/internet/model/ipv4-global-routing.cc:32:0:
../src/internet/model/ipv4-global-routing.h:246:8: error: invalid use of member ‘ns3::Ipv4GlobalRouting::ECMP_DRILL’ in static member function
   bool ECMP_DRILL;
        ^
../src/internet/model/ipv4-global-routing.cc:77:12: error: from this location
            ECMP_DRILL, "ECMP_DRILL"))
            ^
../src/internet/model/ipv4-global-routing.cc: In constructor ‘ns3::Ipv4GlobalRouting::Ipv4GlobalRouting()’:
../src/internet/model/ipv4-global-routing.cc:109:3: error: class ‘ns3::Ipv4GlobalRouting’ does not have any field named ‘m_lastInterfaceUsed’
   m_lastInterfaceUsed(0),
   ^
In file included from ../src/internet/model/ipv4-global-routing.cc:32:0:
../src/internet/model/ipv4-global-routing.h:249:8: error: ‘ns3::Ipv4GlobalRouting::m_respondToInterfaceEvents’ will be initialized after [-Werror=reorder]
   bool m_respondToInterfaceEvents;
        ^
../src/internet/model/ipv4-global-routing.h:237:8: error:   ‘bool ns3::Ipv4GlobalRouting::m_ecmpMode’ [-Werror=reorder]
   bool m_ecmpMode;
        ^
../src/internet/model/ipv4-global-routing.cc:106:1: error:   when initialized here [-Werror=reorder]
 Ipv4GlobalRouting::Ipv4GlobalRouting ()
 ^
In file included from ../src/internet/model/ipv4-global-routing.cc:32:0:
../src/internet/model/ipv4-global-routing.h:240:8: error: ‘ns3::Ipv4GlobalRouting::m_drillMemoryUnits’ will be initialized after [-Werror=reorder]
   bool m_drillMemoryUnits;
        ^
../src/internet/model/ipv4-global-routing.h:239:8: error:   ‘bool ns3::Ipv4GlobalRouting::m_drillRandomChecks’ [-Werror=reorder]
   bool m_drillRandomChecks;
        ^
../src/internet/model/ipv4-global-routing.cc:106:1: error:   when initialized here [-Werror=reorder]
 Ipv4GlobalRouting::Ipv4GlobalRouting ()
 ^
../src/internet/model/ipv4-global-routing.cc:123:3: error: ‘m_seed’ was not declared in this scope
   m_seed = m_rand->GetInteger (0,(uint32_t)-1);
   ^
../src/internet/model/ipv4-global-routing.cc:128:3: error: ‘hasher’ was not declared in this scope
   hasher = Hasher();
   ^
../src/internet/model/ipv4-global-routing.cc: At global scope:
../src/internet/model/ipv4-global-routing.cc:201:85: error: no ‘uint64_t ns3::Ipv4GlobalRouting::GetFlowHash(const ns3::Ipv4Header&, ns3::Ptr<const ns3::Packet>)’ member function declared in class ‘ns3::Ipv4GlobalRouting’
 Ipv4GlobalRouting::GetFlowHash(const Ipv4Header &header, Ptr<const Packet> ipPayload)
                                                                                     ^
../src/internet/model/ipv4-global-routing.cc:267:86: error: no ‘std::string ns3::Ipv4GlobalRouting::GetFlowTuple(const ns3::Ipv4Header&, ns3::Ptr<const ns3::Packet>)’ member function declared in class ‘ns3::Ipv4GlobalRouting’
 Ipv4GlobalRouting::GetFlowTuple(const Ipv4Header &header, Ptr<const Packet> ipPayload)
                                                                                      ^
../src/internet/model/ipv4-global-routing.cc:312:65: error: no ‘uint32_t ns3::Ipv4GlobalRouting::GetNextInterface(uint32_t)’ member function declared in class ‘ns3::Ipv4GlobalRouting’
 Ipv4GlobalRouting::GetNextInterface(uint32_t m_lastInterfaceUsed)
                                                                 ^
../src/internet/model/ipv4-global-routing.cc:322:110: error: no ‘uint32_t ns3::Ipv4GlobalRouting::GetQueueSize(std::vector<ns3::Ipv4RoutingTableEntry*>, uint32_t)’ member function declared in class ‘ns3::Ipv4GlobalRouting’
 uint32_t Ipv4GlobalRouting::GetQueueSize(std::vector<Ipv4RoutingTableEntry*> allRoutes, uint32_t selectIndex ){
                                                                                                              ^
../src/internet/model/ipv4-global-routing.cc:451:1: error: prototype for ‘ns3::Ptr<ns3::Ipv4Route> ns3::Ipv4GlobalRouting::LookupGlobal(const ns3::Ipv4Header&, ns3::Ptr<const ns3::Packet>, ns3::Ptr<ns3::NetDevice>)’ does not match any in class ‘ns3::Ipv4GlobalRouting’
 Ipv4GlobalRouting::LookupGlobal (const Ipv4Header &header, Ptr<const Packet> ipPayload, Ptr<NetDevice> oif)
 ^
../src/internet/model/ipv4-global-routing.cc:342:1: error: candidate is: ns3::Ptr<ns3::Ipv4Route> ns3::Ipv4GlobalRouting::LookupGlobal(ns3::Ipv4Address, ns3::Ptr<ns3::NetDevice>)
 Ipv4GlobalRouting::LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif)
 ^
../src/internet/model/ipv4-global-routing.cc:867:1: error: prototype for ‘void ns3::Ipv4GlobalRouting::PrintRoutingTable(ns3::Ptr<ns3::OutputStreamWrapper>, ns3::Time::Unit) const’ does not match any in class ‘ns3::Ipv4GlobalRouting’
 Ipv4GlobalRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const
 ^
In file included from ../src/internet/model/ipv4-global-routing.cc:32:0:
../src/internet/model/ipv4-global-routing.h:101:16: error: candidate is: virtual void ns3::Ipv4GlobalRouting::PrintRoutingTable(ns3::Ptr<ns3::OutputStreamWrapper>) const
   virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
                ^
../src/internet/model/ipv4-global-routing.cc: In member function ‘virtual ns3::Ptr<ns3::Ipv4Route> ns3::Ipv4GlobalRouting::RouteOutput(ns3::Ptr<ns3::Packet>, const ns3::Ipv4Header&, ns3::Ptr<ns3::NetDevice>, ns3::Socket::SocketErrno&)’:
../src/internet/model/ipv4-global-routing.cc:938:56: error: no matching function for call to ‘ns3::Ipv4GlobalRouting::LookupGlobal(const ns3::Ipv4Header&, ns3::Ptr<ns3::Packet>&, ns3::Ptr<ns3::NetDevice>&)’
   Ptr<Ipv4Route> rtentry = LookupGlobal (header, p, oif);
                                                        ^
../src/internet/model/ipv4-global-routing.cc:938:56: note: candidate is:
../src/internet/model/ipv4-global-routing.cc:342:1: note: ns3::Ptr<ns3::Ipv4Route> ns3::Ipv4GlobalRouting::LookupGlobal(ns3::Ipv4Address, ns3::Ptr<ns3::NetDevice>)
 Ipv4GlobalRouting::LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif)
 ^
../src/internet/model/ipv4-global-routing.cc:342:1: note:   candidate expects 2 arguments, 3 provided
../src/internet/model/ipv4-global-routing.cc: In member function ‘virtual bool ns3::Ipv4GlobalRouting::RouteInput(ns3::Ptr<const ns3::Packet>, const ns3::Ipv4Header&, ns3::Ptr<const ns3::NetDevice>, ns3::Ipv4RoutingProtocol::UnicastForwardCallback, ns3::Ipv4RoutingProtocol::MulticastForwardCallback, ns3::Ipv4RoutingProtocol::LocalDeliverCallback, ns3::Ipv4RoutingProtocol::ErrorCallback)’:
../src/internet/model/ipv4-global-routing.cc:987:51: error: no matching function for call to ‘ns3::Ipv4GlobalRouting::LookupGlobal(const ns3::Ipv4Header&, ns3::Ptr<const ns3::Packet>&)’
   Ptr<Ipv4Route> rtentry = LookupGlobal (header, p);
                                                   ^
../src/internet/model/ipv4-global-routing.cc:987:51: note: candidate is:
../src/internet/model/ipv4-global-routing.cc:342:1: note: ns3::Ptr<ns3::Ipv4Route> ns3::Ipv4GlobalRouting::LookupGlobal(ns3::Ipv4Address, ns3::Ptr<ns3::NetDevice>)
 Ipv4GlobalRouting::LookupGlobal (Ipv4Address dest, Ptr<NetDevice> oif)
 ^
../src/internet/model/ipv4-global-routing.cc:342:1: note:   no known conversion for argument 1 from ‘const ns3::Ipv4Header’ to ‘ns3::Ipv4Address’
cc1plus: all warnings being treated as errors

Waf: Leaving directory `/home/jedi/ns3/ns-allinone-3.26/ns-3.26/build'
Build failed
 -> task in 'ns3-internet' failed (exit status 1):
    {task 3066466380L: cxx ipv4-global-routing.cc -> ipv4-global-routing.cc.1.o}
['/usr/bin/g++', '-O0', '-ggdb', '-g3', '-Wall', '-Werror', '-std=c++11', '-Wno-error=deprecated-declarations', '-fstrict-aliasing', '-Wstrict-aliasing', '-fPIC', '-pthread', '-I.', '-I..', '-DNS3_BUILD_PROFILE_DEBUG', '-DNS3_ASSERT_ENABLE', '-DNS3_LOG_ENABLE', '-DHAVE_SYS_IOCTL_H=1', '-DHAVE_IF_NETS_H=1', '-DHAVE_NET_ETHERNET_H=1', '-DHAVE_PACKET_H=1', '-DHAVE_IF_TUN_H=1', '-DHAVE_GSL=1', '-DHAVE_SQLITE3=1', '../src/internet/model/ipv4-global-routing.cc', '-c', '-o', '/home/jedi/ns3/ns-allinone-3.26/ns-3.26/build/src/internet/model/ipv4-global-routing.cc.1.o']

pdbarnes

unread,
May 14, 2018, 4:41:35 PM5/14/18
to ns-3-users
The symbols ECMP_NONE etc. appear to be declared as enum values, so you can't create a variable with those names.  That seems to be most of your errors.

Peter

QingLin Xun

unread,
Oct 18, 2021, 10:59:45 PM10/18/21
to ns-3-users

Dear Richard,

Thank you for sharing your code. I am having trouble working with getting the header. source IP .

In the RouteOutput function, its header has not initialized srcIP , therefore the Hash algorithm does not para. about srcIP correct. What can I do to solve this problem?

 src:102.102.102.102 , dst:10.8.9.2 , Node:0 , TTL:0 , Tos:0

Luiz Henrique Neves Rodrigues

unread,
Oct 19, 2021, 3:50:12 AM10/19/21
to ns-3-...@googlegroups.com
HASH....


You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/4ca704dc-058d-4106-9037-43ed778a2f1an%40googlegroups.com.


--
Luiz Henrique Neves Rodrigues
Doutorando
IME - USP
Reply all
Reply to author
Forward
0 new messages