Manual Node attribute definition

26 views
Skip to first unread message

jack....@gmail.com

unread,
Jun 22, 2017, 4:09:17 AM6/22/17
to ns-3-users
Hi,

I want to implement a Sensor Network using NS-3. Previously, I used to use C++ for my simulations; however, based on recommendations, I plan to move to NS-3.

My question: I know how to create nodes using NodeContainer. However, could you please let me know how I can assign my own defined attributes to a node? For example, in C++, I used a struct for sensor nodes to contain different attributes of nodes, including S[i].E_res as the remaining energy, S[i].L as a node level, etc. I just wanted to know, how I should define such attributes in NS-3 when we don't have an explicit sensor struct defined in my C++ codes.

Cheers

Jack

Konstantinos

unread,
Jun 22, 2017, 4:50:56 AM6/22/17
to ns-3-users
Hi Jack,

I would recommend to study the documentation. ns-3 is a modular project and each module provides certain functionality.
For example, there is a module for specific NetDevices (lr-wpan, wifi, etc), another for energy, and so on. These modules get 'installed' on the nodes so you can access attributes from them.

Regards,
K

On Thursday, June 22, 2017 at 9:09:17 AM UTC+1, jack....@gmail.com wrote:
Hi,

I want to implement a Sensor Network using NS-3. Previously, I used to use C++ for my simulations; however, based on recommendations, I plan to move to NS-3.
project

jack....@gmail.com

unread,
Jun 22, 2017, 2:05:39 PM6/22/17
to ns-3-users
Dear Konstantinos,

Thank you for your answer. I see what you meant about modules and using them because I have studied the tutorial. But, my question was about modules that are not already defined. Let me clear it by using an example. In my algorithm, nodes are divided into cluster heads (CHs) and cluster members (CMs). CHs should have a table to keep the information of their CMs. For example, how many nodes they have in their clusters, the node ID of their CH neighbors, and so on. As I said, I used to define a struct for each node (thus a vector of structs for all nodes) in C++ to keep these information. I am specifically looking for a clue to see how I can save some information (like the node ID of neighbors) in a node. Perhaps I should use structures in NS-3, as I used in C++, to do that.

Could you please provide a simple example (with few lines of code) to give me the idea?

Thank you in advance
Reply all
Reply to author
Forward
0 new messages