NEmu

Network Emulator for Mobile Universes

Documentation - Virtual Routers (VRouter)

NEmu provides already configured Linux routers called VRouter. Those ones can be linked/unlinked in the same way as a basic virtual host in order to be a part of a network topology. Routers provide essential services in order to simplify the management of the virtual network. A virtual router is a x86/64 virtual machine which runs on an custom TinyCore Linux distribution.

VRouter(name, conf, arch, hds, nics, services, **opts)

This function creates a new virtual router called name in the current session.
conf is the name of a common router configuration (please refer to the next function) (default: None).
hds is a list of virtual file systems which will be used by the router (default: empty list).
nics is a list of network interface cards which will be used by the router (default: empty list).
services is a list of Service elements (default: empty list).
opts are other arguments of QEMU. (arg=val in opts will become -arg val for QEMU).
Configurations of routers are set in symlink.{session name}/rcd/{router name}.

VRouterConf(name, services, **opts)

A VRouterConf is a common configuration applied to several routers in order to reduce the duplication of code. A VRouter can use a VRouterConf and adds extra configurations in the same time.

GenVRouter(*names)

A router is automatically configured at session start, gathering all information needed. A router is configured only one time. This function allows the user to force a reconfiguration of the router without launching it.

Service(name, *largs, **kargs)

A Service is an optional feature for virtual routers. List of available services can be found here.
name is the Service name.
largs contains arguments in list form.
kargs contains arguments in keyword form.

UserService(name, root, *largs, **kargs)

An UserService is a regular Service which is located outside the NEmu root directory.
name is the Service name.
root is the directory where the Service is located.
largs contains arguments in list form.
kargs contains arguments in keyword form.

ListService(*names)

This function lists the usage of services contained in the list names. If this list is empty, all services will be listed. In spite of the fact that several services are already provided by NEmu, you can add some extra new services (please refer to the Writing a new VRouter Service section)

Here is a short example of configuration where the router:

This is the related configuration:

VRouter("router", nics=[VNic(), VNic(), VNic()], services=[
      Service("ipforward"),
      Service("ifup", '1:192.168.1.1', '2:192.168.2.1'),
      Service("gateway", 0),
      Service("masquerade", ipsrc="192.168.0.0/16"),
      Service("dnsmasq", domain="local1", net="192.168.1.0/24", 
                     start="192.168.1.10", end="192.168.1.20", ifaces=[1]),
      Service("dnsmasq", domain="local2", net="192.168.2.0/24", 
                     start="192.168.2.10", end="192.168.2.20", ifaces=[2]),
      Service("password", "root", password="plop"),
      Service("sshd")]
                , sdl=None)

VHost("alice", hds=[VFs("debian.img", "cow")], nics=[VNic()])
VHost("bob", hds=[VFs("debian.img", "cow")], nics=[VNic()])

VSlirp("slirp", net='192.168.0.0/24')

VSwitch("sw1", niface=2)
VSwitch("sw2", niface=2)

Link("router:0", "slirp")
Link("router:1", "sw1:0")
Link("router:2", "sw2:0")

Link("alice", "sw1:1")
Link("bob", "sw2:1")

The resulting virtual network will be:

router usecase