Skip to main content

Two nodes side by side

We have seen how to create a single node and how to implement its behavior. Now, we will create two nodes of the same type. All we need to do is to create two nodes instead of one in the network NED file:

network SingleNodeNetwork
{
    submodules:
        node1: Node;
        node2: Node;
    connections:       
}

If you immediately re-run the simulation, you will notice that the nodes are displayed on top of each other. You can pull them apart manually or you change a little bit the display in the Node.ned and Node.cc file so that it looks like this (note the position of the node has been deleted):

// in NED:
parameters:
        @display("b=60,10,rect,blue,black,2");
// in CC:
dispStr.parse("b=60,10,rect,red,black,2");

If you re-run it now, you will see the nodes positioned automatically next to each other.