Types of links (directed/undirected and wired/wireless)

JBotSim can deal with several types of links. In particular, a link can be directed or undirected and it can be wired or wireless. Both can be manipulated either implicitly or explicitly by program.

Directed vs undirected links

Internally, JBotSim relies on directed links for its management (e.g. delivering messages). However, the user can use either directed links or undirected links, the latter being the default. In fact, the concept of undirected link is nothing but an abstraction for two directed links (one in each direction), although the user does not need to know this. This is made more precise in the following few facts:

Wireless links

If the nodes have wireless capabilities (by default, they do), then JBotSim will automatically maintain a set of wireless links between those nodes whose mutual distance is within some communication range. More precisely:

Wired links

Contrary to wireless links, wired links do not depend on the distance between the nodes. Once they are created, they remain available forever or until they are explicitly deleted (by program).

If you do not want wireless links to interfere with wired links, you can disable the wireless capability of a single node or disable it globally, through calling .disableWireless() on the Node or the Topology object, respectively. Reciprocally, you can re-enable it using .enableWireless() on the same objects.

Wired links are typically created or removed by program directly, as discussed next.

Creating links by program

You can create links directly in your program using one of the following constructors:

    Link(Node from, Node to)
    Link(Node from, Node to, Link.Mode mode)
    Link(Node from, Node to, Link.Type type)
    Link(Node from, Node to, Link.Type type, Link.Mode mode)

Link.Mode is an enum type that contains the two constants WIRED and WIRELESS, and Link.Type contains the two constants DIRECTED and UNDIRECTED. For example, the following call

    new Link(n1, n2, Link.Mode.WIRED, Link.Mode.DIRECTED);

creates a wired (i.e. permanent) and directed link from n1 to n2. The simpler versions of the constructors correspond to values WIRED and UNDIRECTED by default for the mode and type, respectively. For example, the following code creates a topology with two nodes and a permanent undirected link between them.

    Topology tp = new Topology();
    Node n1 = new Node();
    Node n2 = new Node();
    tp.addNode(100, 100, n1);
    tp.addNode(200, 100, n2);
    Link link = new Link(n1, n2);

The coordinates in the addNode() method are optional, for graphical purpose only.