NEmu

Network Emulator for Mobile Universes

Documentation - Linking virtual elements

Linking or unlinking elemens is really simple.

Link(client, core)

Links the virtual interface client to the virtual interface core.
client is the name of a virtual element and its interface. This argument should be {virtual element name}:{interface number} or {virtual element name} (in this case, the target interface will be the first).
core is the name of another virtual element its interface. This argument should be {virtual element name}:{interface number} or {virtual element name} (in this case, the target interface will be the first).

Unlink(*targets)

Unlinks all virtual elements listed in argument. An element should be {virtual element name}:{interface number} or {virtual element name} (in this case, all interfaces will be unlinked).

The connection configuration is setup first in the core target interface, thus it represents a server. The client target interface uses the previous core configuration in order to enable the connection to the server.
The server configuration is autonomously setup by the Link function. However you can set it by yourself if you want by using the SetIface function.

SetIface(name, addr, port, proto, laddr, lport)

This function allows you to set an interface of a virtual element more finely.
name is the name of the virtual element and its interface. This argument should be {virtual element name}:{interface number} or {virtual element name} (in this case, the target interface will be the first).
addr is the real IP address for the socket (Default: local).
port is the real IP port for the socket (Default: autoset).
proto is the real prototype for the socket. This argument can be tcp, udp, vde or tap (Default: autoset).
laddr is the real local IP address for the udp socket (Default: None).
lport is the real local IP port for the udp socket (Default: autoset).

UnsetIface(name)

This function unsets an interface of a virtual link. name is the name of the virtual element and its interface. This argument should be {virtual element name}:{interface number} or {virtual element name} (in this case, all interfaces will be unset).

Here is a Link usage example:

VHost("alice", nics=[VNic()])
VHost("bob", nics=[VNic()])
VHost("coffee", nics=[VNic(), VNic()])
VHost("dean", nics=[VNic()])

VSwitch("sw", 3)
VLine("pp")

SetIface("pp:0", proto='tcp', port=9000)
SetIface("pp:1", proto='udp', port=8000, lport=8001)

Link("alice", "sw:0")
Link("bob", "sw:1")
Link("coffee:0", "sw:3")
Link("coffee:1", "pp:0")
Link("dean", "pp:1")

Actually, it is possible to call link without calling SetIface first. In this case, an implicit call to SetIface will be performed with default parameters. Therefore the two following scripts are equivalent:

# With SetIface
VHost("alice", nics=[VNic()])
VHost("bob", nics=[VNic()])
VLine("sw")

SetIface("sw:0")
SetIface("sw:1")
Link("alice", "sw:0")
Link("bob", "sw:1")
# Without SetIface
VHost("alice", nics=[VNic()])
VHost("bob", nics=[VNic()])
VLine("sw")

Link("alice", "sw:0")
Link("bob", "sw:1")