ERROR caused by NEW module

119 views
Skip to first unread message

Dongsheng Jia

unread,
Aug 30, 2023, 10:23:41 AM8/30/23
to ns-3-users
Dear friends,
I am stuck in trouble. When I'm trying to reproduce one paper(link: mshsyr/TrustMod: TrustMod is a trust management module for NS-3. (github.com)), I modified the original module and added a new module named trust module step by step according to given mannual. But it doesn't work!(cry~~~) I will try my best to specify my problem as below, and wish someone can give me some advice.
Problem described:

related original module: wifi module & AODV module
new module: trust module

In trust module: a trust class has been created. And related code depends on wifi module and AODV module. So 'wifi' and 'AODV' are included in the wscript of trust module.
In wifi module: the trust class has been used(shown in figure 1), but in the wscript of wifi module, trust module is not included(maybe the authors forgot it, and i added it in wifi module(if i don't do this, trust-related classed or methods cannot be referened.)).
In AODV module: trust-related methods or classes have been used. So 'trust' is included in the wscript of AODV module(and wifi module is included according to original code).

       Once I build this code by waf, something goes wrongly(shown in figure 2). I guess it may be caused by circular reference.My solution is to integrate trust module with AODV module, which mean i added trust-related .cc and .h files to AODV module, and adjust the wscript in AODV module. So wifi module can depends on AODV module directly. However, the second problem is that the 'cycle detected ' error happends in wifi module and AODV module. My solution about this is to create a new module named wificopy(copy and modify wifi module, and i hope wificopy (instead of wifi module)can be used by AODV module, so as to solve the problem 'cycle detected in the process' ). But it is really a big project to modify wifi module!!! And i am a beginer of ns3, it is too difficult for me.   Can anyone help me to solve the problem caused by adding new module or tell me how to copy and modify the original ns3 module? i would appreciate it!!! I don't know whether I describe it clearly. 
a30136fc54eb61e8e2493a8e5acff7c.png Figure 1.122222222222222.png  Figure 2. 

Tommaso Pecorella

unread,
Aug 30, 2023, 8:43:16 PM8/30/23
to ns-3-users
I checked your repo, and the wscript doesn't show the dependencies: module = bld.create_ns3_module('trust', ['internet', 'config-store']), perhaps it's that. Try modifying it to: module = bld.create_ns3_module('trust', ['internet', 'config-store', 'wifi', 'aodv'])

I'll avoid pointing out that using an extremely old ns-3 release is not recommended, and your result will be probably quite... imprecise.

Dongsheng Jia

unread,
Aug 30, 2023, 10:33:35 PM8/30/23
to ns-3-users
Dear Tommaso Pecorella,
Thanks a lot, i agree with you. Actually i wonder whether the authors provided complete dependency relationship or not. In fact, I have tried to add 'AODV' to the wscript of trust module. And it's the reason why "cycle detected in the process ...." error happened: Trust's wscript: ..., wifi, AODV.  wifi's wscript: ..., trust. AODV's wscript: ..., trust, wifi. This is why the compiling doesn't works. I have no idea to solve this problem.  I would appreciate it if you can help me to solve this. By the way, I am really beginner about ns3. I tried to configure the latest ns3 on Ubuntu (using VMware) for a week, but failed (helpless). And the configured ns-3.33 is found in BiliBili (a video platform in China ), so i used it. I don't know that the old one will result in the inaccuracy of the experiment.

Regard
Dongsheng Jia 

Tommaso Pecorella

unread,
Aug 31, 2023, 6:17:23 PM8/31/23
to ns-3-users
Mmm... so it's not your code (better, for you).

Given that we moved away from waf, and the support for older releases (and 3.30 is *very* old) is practically non-existent... it's a shoot in the dark. It's not that we don't want - 3.30 doesn't even compile on my computer - not anymore.

Said that, try to compile it as a static library (./waf configure –enable-static if I remember right). The problem, however, is that a module working at IP level shouldn't depend on a specific NetDevice, so adding a dependency on WiFi to AODV is horribly wrong - by design - and this should tell you something about the overall quality of the software (and proposed algorithm) you're dealing with. No offence, but it looks to me that the original author took some questionable shortcuts. Some *very* questionable shortcuts.

My personal suggestion (if you want to improve the model) is to check why there's a dependency on WiFi (or on other modules). An example... is AODV really needing WiFi (err... no). According to the PDF in the repo, the only place where WiFi is used in AODV is here:
Ptr<WifiNetDevice> wifiNetDevice = DynamicCast<WifiNetDevice> (device);
Ptr<Node> node = wifiNetDevice->GetNode();
Ptr<Trust> trust = node->GetObject<ns3::Trust> ();


Now, this is... unnecessary. You can simply write:
Ptr<Trust> trust = GetObject<ns3::Trust> ();

because... aggregation magic (AODV is aggregated to the node, and aggregation is mutual, so if Trust is aggregated to the node, it's also aggregated to AODV).

A less "magic" way is:
device->GetNode()->GetObject<ns3::Trust> ();

because GetNode() is a virtual function of NetDevice, there's no need whatsoever to have to cast it to a specific NetDevice type. Virtual functions are virtual for a reason. 

Dongsheng Jia

unread,
Sep 3, 2023, 11:38:01 AM9/3/23
to ns-3-users
Thanks a lot!!! I will try to modify this code according to your advice! It will be very helpful for me!!! Yes, it's not my code, and it does help me a lot, 
  • I've been busy learning these codes recently,Hahahaha.

Dongsheng Jia

unread,
Sep 7, 2023, 2:44:41 AM9/7/23
to ns-3-users
Hello  Pecorella, I have tried your advice, but it doesn't works. But i come to understand what you means. Let me explain what i have done according to your advice. 
scenario 1. i  tried to compile the code as a static library(the order is "./waf configure --build-profile=debug --enable-examples --enable-tests --enable-static"), and the order is right, but it doesn't solve the problem.
seenario 2.  i think what you said is right. The Wifi module should not depend on AODV module logically, and AODV module is not included in the original wscript in Wifi. So i was a little confused when i firstly saw Wifi module depends on AODV module when debugging. But now i am clear that  the problem may comes from the class Trust, as you said before. It involves methods or class related to AODV module in class Trust (such as class routingprotocol or IsNeighbor method)(as shown in Figure , these methods or classes comes from AODV module ). So the basic error is that class Trust is used in Wifi module, but classes or methods related AODV module are used in class Trust. Thus, the AODV is used in wifi module. Am i right? So even though you simplify the code by the code "Ptr<Trust> trust = GetObject<ns3::Trust> ();", but the logic is not changed, AODV → class Trust, Trust → wifi。This is why the "cycle detected " problem happends. 
 So it seems to be a endless loop whatever i do. AODV module depends on WIfi module.  Wifi module has to use classs Trust, and class Trust involves classes or method related to AODV module. And AODV also depends on Trust module.  What a mess( helpless)~Do you have any good idea? 
f7ea1627f3a7cc9ee1cd3a06ea30a44.png
                                                              Figure 1. the classes or methods related to AODV module  used in class Trust. (aodv::RoutingProtocol & IsNeighbor())

Tommaso Pecorella

unread,
Sep 7, 2023, 7:47:50 AM9/7/23
to ns-3-users
I don't really know how to help you (except taking one or two days off to fix it - but I really don't have that time now).

My best suggestion at this point (but it will require some effort) is to give up the idea to have a new module. If you have to heavily modify AODV to make it a "trust-AODV", and if the Trust module only works with AODV... embrace the chaos and merge the two module:
  1. Duplicate the aodv module, change its name, and all the occurrences of "aodv" in the model. Basically make a "TrustAodv" class, functionally equivalent to the "Aodv" one.
  2. Add the required methods to the new "TrustAodv" class
  3. Add the "trust" module files to the new "trust-aodv" model
  4. Continue until you have the merge.
The only missing part is "Wifi module has to use class Trust". This is due to the "suggestion" in section 2.1 in the PDF. This is THE root of your issues. The solution here is to define a new Trace (or a callback) in wifi, and connect to it in the new TrustAodv model. This is a common solution to break circular dependencies - and you can find plenty of examples in the current modules. Check for example the "MacRx" or "MacTx" traces in src/wifi/model/wifi-mac.cc.
Mind that you'll have to add some code to "connect" the trace, use the DoInitialize function.

That will break the circular dependency.

Hope this helps,

T.

Dongsheng Jia

unread,
Sep 7, 2023, 8:40:12 AM9/7/23
to ns-3-users
Hahaha, alright, I almost give up. Let me give it the last chance. In fact, I have tried to duplicate the Wifi module to solve this problem, but failed. It's a very big project and i could not finish it(AODC module would be simpler, but also difficult to me).  Someone is also trying to duplicate(seen https://groups.google.com/g/ns-3-users/c/6VALDQb-uIQ) . I will consider your advice. Anyway, it's very very kind of you to give me so many advice!!! Have a good time!!!
Dongsheng Jia

faisal Lone

unread,
Sep 9, 2023, 8:54:09 PM9/9/23
to ns-3-...@googlegroups.com
Please contact the author. I guess it shadi hajar..have talked to him regarding this module..really great guy..he ll respond for sure.

--
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 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/ad8229c4-54ab-4dff-9f5b-c4095f8b8119n%40googlegroups.com.

Dongsheng Jia

unread,
Sep 10, 2023, 3:03:46 AM9/10/23
to ns-3-users
I have talked to him the day before yesterday! He is very  enthusiastic! But I haven't solve it yet, I will keep contacting with him. Have you ever compiled it, bro? Is it the same problem? 

faisal Lone

unread,
Sep 10, 2023, 2:38:36 PM9/10/23
to ns-3-...@googlegroups.com
i started using ns3, but then moved to omnet++ as it has much better frameworks for vehicular networks (VEINS).

Dongsheng Jia

unread,
Sep 10, 2023, 8:52:35 PM9/10/23
to ns-3-users
Well, alright. I have to say the code provided by the author has a fatal mistake, but I cannot correct it.
Reply all
Reply to author
Forward
0 new messages