What does node[0] mean in when using a module

182 views
Skip to first unread message

maths soso

unread,
Aug 16, 2022, 11:06:48 AM8/16/22
to OMNeT++ Users
In one of the veins projects, in the "RSUExampleScenario.ned", the following command: 
node[0]: Car{} 
has been declared, I just started learning NED, I can't understand the meaning of that line, declaring 0 cars,? isn't it supposed to be node[1] if only one car is necessary like many other programming languages? and how does Veins create a node for each vehicle ? I cannot find anywhere that is specified to create a node for each vehicle. My understanding of the Scenario.ned is to create only one node for the whole simulation.


Dragos Ilie

unread,
Aug 16, 2022, 11:43:19 AM8/16/22
to omn...@googlegroups.com
Many popular programming languages (C, C++, Java and Python) use index 0 to access the first element in an array. From what I remember, the reason is that the generated code will place the array starting at a memory address p. If we use assume the array consists of bytes, the first element is at address p+0, the second element at p+1 and so on. So the index represents the “distance” from the start of array. Ned follows the same convention

--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/omnetpp/9a46c42c-ca58-441e-9d4f-6c37425ade93n%40googlegroups.com.

maths soso

unread,
Aug 16, 2022, 3:01:41 PM8/16/22
to OMNeT++ Users
Thank you, I am aware of that, I am asking two questions :
- Why when declaring the array we use node[0], in the languages you mentioned you need to put the size of the array instead of 0.
- And what makes omnet++ add more nodes when vehicles are spawned?
Reply all
Reply to author
Forward
0 new messages