Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Wednesday, November 17, 2010

distributed emulation with Linux netns

Starting with SVN r133 you can use distributed emulation on Linux for wired networks. For wireless networks (WLANs) you should still use EMANE. GRE tunnels are automatically built between emulation servers.

The Emulation Servers dialog is shown below. This hasn't changed. Be sure to set listenaddr = 0.0.0.0 in your /etc/core/core.conf before starting cored.py (the default listen address is localhost.)

One of the easiest ways to assign nodes to servers is to select a group of nodes and right-click on them, then choose Assign to...
Nodes belonging to different servers need a tunnel between servers to forward data. This is indicated in the GUI with a dashed link line.
The above screenshot shows a gt.42243.61 device added to one of the Linux bridges. This is the GRE tunneling device automatically generated on one of the servers. The gretap device type is used, a gre having a MAC address, so that it may join an Ethernet bridge.

Thursday, November 11, 2010

node types and services

Previously the CORE GUI generated router configs for the router node type. This was mostly limited to Quagga OSPFv2 and OSPFv3, without an easy way to customize processes. Now the configuration has been pushed to the CORE services layer (cored.py) and is more exposed to the user.

Node types:
Users may now customize node types. The default types are router, host, PC, and mdr. Clicking the edit button at the end of the submenu allows the user to define new node types or change existing ones.
In the above screenshot, a new node type "supernode" has been defined, and assigned a custom icon. This new node type will appear in the toolbar. Next, a default set of services that will be started with that node type can be selected.
Services: Services can be assigned to a node or node type. When you place a node, it will automatically have the default services configured for that node type. A service can be a routing protocol, server daemon, or even simply a script that runs after the node is started. A service can also auto-generate its config file(s) based on node properties such as name, interfaces, and addresses.

The above screenshot shows the default services that will be started for the custom type "supernode." The below screenshot shows how services can later be customized for each individual node.

Notice the Customize button, available when selecting services for a certain node. This button has been pressed to invoke the custom services dialog. (This dialog may be improved in the future.) Each service defines its own:
  • per-node directories
  • config files
  • startup index
  • startup/shutdown commands
All of the services are defined in Python files (see core/python/core/services/*.py). All of the above attributes may be customized for each node. Future plans are to allow the user to easily define their own service types using Python extensions (probably ~/.core/services/*.py).

Because all of the services are defined in CORE Python daemon, Python scripts (without GUI) will be able to take advantage of auto-generated configs. The bad news is that router configs are no longer saved in the imn scenario files, unless you customize the config files of a service; effectively the imn file format has changed.

Friday, May 21, 2010

CORE is now a Python package

The CORE Python code has been reorganized into a Python package. New example scripts are included in the source under core/python/examples/netns/. Here is a snippet from one of the samples, how you would make N nodes connected to a switch:

from core import pycore
from core.misc import ipaddr

def main:
...
# IP subnet
prefix = ipaddr.IPv4Prefix("10.83.0.0/16")
session = pycore.Session()
# emulated ethernet switch
switch = session.addobj(cls = pycore.nodes.SwitchNode)
print "creating %d nodes with addresses from %s" % \
(options.numnodes, prefix)
for i in xrange(1, options.numnodes + 1):
tmp = session.addobj(cls = pycore.nodes.LxcNode, name = "n%d" % i)
tmp.newnetif(switch, ["%s/%s" % (prefix.addr(i), prefix.prefixlen)])
tmp.cmd(["sysctl", "net.ipv4.icmp_echo_ignore_broadcasts=0"])
n.append(tmp)

# start a shell on node 1
n[1].term("bash")