Coder Social home page Coder Social logo

nlan's Introduction

Interactive SDN/IOT with tega db and Jupyter/IPython

All in one

This project nlan (meaning "new LAN") unifies outputs from my two other projects "neutron-lan" and "tega".

Background and motivation

  • OpenDaylight MD-SAL is too heavy for networking Linux containers on my Raspberry Pi.
  • YANG is incompatible with Python dict, Golang map and so on: I just want JSON-centric MD-SAL.
  • As my hobby, I design a model-driven/event-driven architecture for networking Linux containers.
  • I think Jupyter/IPython is a wonderful IDE for SDN/IOT (and also for Deep Learning...).
  • OCP networking is a wonderland!
  • If the computing power moves to the network edge, what you need is not VLAN but application-level logical seperation of network (SSL/TLS, WebSocket, RTP/RTCP, ...), that is, what you need is "session".

Architecture

Sort of "immutable infrastructure" for networking...

NLAN architecture

NLAN archiecture internal

Visualization and analytics

I use Jupyter and IPython for visualization and analytics of NLAN.

import networkx as nx
get_ipython().magic('matplotlib inline')

import tega.driver
d = tega.driver.Driver(host='192.168.57.133')
subnets = d.get(path='graph.subnets')

g = nx.DiGraph(subnets['172.21.1.0/24'])
nx.draw_spring(g, node_size=1000, with_labels=True, arrows=True, alpha=0.8)

NLAN visualization

Directional graph of IP routing that Quagga and GoBGP have setup on the network

Note: in case of OpenFlow Controller, the directional graph is calculated by the controller.

OpenFlow-based SDN: calculate directional graph and write the edges(flow entries) to the switches/routers.
SDN with BGP/OSPF: write config/policy to the switches/routers, then each of the switches/routers calculates directional graph.

Jupyter notebook examples

You can find the notebooks here.

NLAN services

  • PTN: Packet Transport Network (Layer 1 and Layer 2)
  • Vhosts: netns-based virtual hosts
  • Router: Quagga configuration

To be added:

  • Links: direct linking(veth/macvlan/tun/tap)
  • Bridges: non-distributed virtual switch(linux bridge per vlan)
  • DVR: Distributed Virtual Switch and Distributed Virtual Router (Layer 2 and Layer 3)

Target use cases

Use case 1 has already been implemented, and use case 2 is being planned at the moment.

Use case 1: Network simulation

This use case makes use of NLAN's PTN, vHosts and Router services. WAN simulation

Declarative state representations:

Data trees on tega db

NLAN data trees

Running the simulated network on Raspberry Pi

This is sort of micro NFV(Network Function Virtualization) on a single Rapsberry Pi.

  • Nine virtual routers (Linux containers)
  • Sixteen virutal hosts (netns)

You can learn how routing protocols work on this simulated network.

Setting up the software on Raspberry Pi

Log in the virtual routers with ssh, and try "ip" or "vtysh" commands:

  • ip route
  • ip addr
  • ip link
  • ip netns
  • vtysh: show run
  • vtysh: show ip route
  • vtysh: show ip bgp :

Quagga and GoBGP:

This use case makes use of Quagga, but gobgp may optionally be used as Route Reflector or Route Server on "RR" container in the fig above.

You can also launch gobgpd from NLAN agent by including "EmbeddedBgp: true" in your NLAN state file:

      Router:
        Loopback: 10.1.1.5/32
        EmbeddedBgp: true
        Bgp:
          - As: 100
            Neighbors:
              - Peer: 10.200.1.101
                RemoteAs: 100
                RouteReflectorClient: true
              - Peer: 10.200.1.102
                RemoteAs: 100
                RouteReflectorClient: true
              - Peer: 10.200.1.103
                RemoteAs: 100
                RouteReflectorClient: true
              - Peer: 10.200.1.104
                RemoteAs: 100
                RouteReflectorClient: true

Use case 2: SOHO NFV (Network Functions Virtualization)

This is the next use case I am going to work on... (as my hobby: not so practical)

SONO-NFV

Network simulation with Linux containers

I use Linux containers as virtual routers, and this tool will set up virtual links (L0/L1) and virtual switches (L2) over the containers. Then I will run Quagga/Zebra(L3) daemons over the virtual routers to study how legacy routing protocols work.

NLAN installation

[Step 1] Make a Docker image named "router" following the instruction here.

[Step 2] Install and start tega db:

You need to have Python3.5 installed on your Ubuntu/Debian.

$ go get github.com/araobp/tega/driver
$ cd $GOPATH/src/github.com/araobp/tega
$ python setup.py install
$ pip install mako

For Hypriot/RaspberryPi, you need to export this environment variable:

$ export SETUP_SCRIPT=setup_rpi.sh

For Debian/Ubuntu, you do not need to export the variable above.

Then start tega db:

$ cd scripts
$ ./tegadb

   __
  / /____  ____ _____ _
 / __/ _ \/ __ `/ __ `/
/ /_/  __/ /_/ / /_/ /
\__/\___/\__, /\__,_/
        /____/

tega_id: global, config: None, operational: None

Namespace(config=None, extensions='/root/work/src/github.com/araobp/nlan/plugins/nlan', ghost=None, gport=None, logdir='./var', loglevel='INFO', maxlen=10, operational=None, port=8739, tegaid='global')

INFO:2016-03-16 15:14:51,966:Reloading log from ./var...
INFO:2016-03-16 15:14:51,972:Reloading done
INFO:2016-03-16 15:14:52,675:plugin attached to idb: Hook
INFO:2016-03-16 15:14:52,692:plugin attached to idb: Deployment
INFO:2016-03-16 15:14:52,707:plugin attached to idb: Subnets
INFO:2016-03-16 15:14:52,712:plugin attached to idb: Topo
INFO:2016-03-16 15:14:52,739:plugin attached to idb: PtnBgp
INFO:2016-03-16 15:14:52,765:plugin attached to idb: Workflow
INFO:2016-03-16 15:14:52,782:plugin attached to idb: Fabric
INFO:2016-03-16 15:14:52,800:plugin attached to idb: ServerClient
INFO:2016-03-16 15:14:52,823:plugin attached to idb: IpAddressManagement
INFO:2016-03-16 15:14:52,842:plugin attached to idb: Template

[Step 2] Try this at the tega CLI to put "ptn-bgp" state onto tega db:

[tega: 2] plugins.ptnbgp()

The script sets up this network.

You may also try "plugins.fabric()" instead. It will setup L3 fabric simulating a data center network.

[Step 3(option)] You may take a snapshop of tega db to make tega db's start-up faster:

[tega: 3] ss 

[Step 4] Execute the following command to build Docker image with NLAN agent embedded and to start the containers:

[tega: 4] plugins.deploy() 

NLAN agent on each container connects to tega db to fetch NLAN state.

If you want to monitor the activities of each agents, subscribe(path="hosts") on the CLI (example).

[Step 5] Confirm that all the containers are running

[tega: 5] subscribers
Deployment: [Deployment]
IpAddressManagement: [IpAddressManagement]
Template: [Template]
Topo: [Topo, config-.*]
ce1: [ce1]
ce2: [ce2]
ce3: [ce3]
ce4: [ce4]
pe1: [pe1]
pe2: [pe2]
pe3: [pe3]
pe4: [pe4]
rr: [rr]

[Step 6] Try raw commands to check the state of each container

[tega: 6] raw.ce1('ip route')
default via 172.17.0.1 dev eth0
10.1.1.1 via 10.201.11.1 dev int_br111  proto zebra
10.1.1.2 via 10.202.11.1 dev int_br211  proto zebra
10.1.1.3 via 10.201.11.1 dev int_br111  proto zebra
10.1.2.2 via 10.201.11.1 dev int_br111  proto zebra
10.1.2.3 via 10.201.11.1 dev int_br111  proto zebra
10.1.2.4 via 10.201.11.1 dev int_br111  proto zebra
10.10.10.0/24 dev eth0  proto kernel  scope link  src 10.10.10.6
10.200.1.0/24 via 10.201.11.1 dev int_br111  proto zebra
10.200.2.0/24 via 10.201.11.1 dev int_br111  proto zebra
10.201.11.0/24 dev int_br111  proto kernel  scope link  src 10.201.11.2
10.201.12.0/24 via 10.201.11.1 dev int_br111  proto zebra
10.202.11.0/24 dev int_br211  proto kernel  scope link  src 10.202.11.2
10.202.12.0/24 via 10.202.11.1 dev int_br211  proto zebra
10.203.13.0/24 via 10.201.11.1 dev int_br111  proto zebra
10.203.14.0/24 via 10.201.11.1 dev int_br111  proto zebra
10.204.13.0/24 via 10.201.11.1 dev int_br111  proto zebra
10.204.14.0/24 via 10.201.11.1 dev int_br111  proto zebra
172.17.0.0/16 dev eth0  proto kernel  scope link  src 172.17.0.7
172.21.1.0/24 dev br_172.21.1.1  proto kernel  scope link  src 172.21.1.1
172.21.2.0/24 via 10.201.11.1 dev int_br111  proto zebra
172.21.3.0/24 via 10.201.11.1 dev int_br111  proto zebra
172.21.4.0/24 via 10.201.11.1 dev int_br111  proto zebra
172.22.1.0/24 dev br_172.22.1.1  proto kernel  scope link  src 172.22.1.1
172.22.2.0/24 via 10.201.11.1 dev int_br111  proto zebra
172.22.3.0/24 via 10.201.11.1 dev int_br111  proto zebra
172.22.4.0/24 via 10.201.11.1 dev int_br111  proto zebra

[tega: 7] raw.ce2('ip route')
               :
               

You may also start a ssh session to the containers:

$ cd scripts 
$ ./ssh.sh pe1
       :
$ ./ssh.sh ce1
       :

The password is "root".

Or you may also use "ip netns" command to the containers:

$ ip netns exec pe1 ip route

[Step 8] Call hook functions to reflesh operational data trees

[tega: 8] plugins.hook() 

[Step 9] Check the operational trees

[tega: 9] getr operational-(\w*)\.ip
operational-ce1.ip:
  groups:
  - [ce1]
  instance:
    addr: {10.1.2.1: lo, 10.10.10.6: eth0, 10.201.11.2: int_br111, 10.202.11.2: int_br211,
      127.0.0.1: lo, 172.17.0.7: eth0, 172.21.1.1: br_172.21.1.1, 172.22.1.1: br_172.22.1.1}
    dev:
      br_172.21.1.1: [172.21.1.1]
      br_172.22.1.1: [172.22.1.1]
      eth0: [172.17.0.7, 10.10.10.6]
      int_br111: [10.201.11.2]
      int_br211: [10.202.11.2]
      lo: [127.0.0.1, 10.1.2.1]
    hook: {addr: '%ce1.ipAddr', route: '%ce1.ipRoute'}
    route:
      10.1.1.1/32: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      10.1.1.2/32: {Dev: int_br211, Src: '', Via: 10.202.11.1}
      10.1.1.3/32: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      10.1.1.4/32: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      10.1.2.2/32: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      10.1.2.3/32: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      10.1.2.4/32: {Dev: int_br211, Src: '', Via: 10.202.11.1}
      10.10.10.0/24: {Dev: eth0, Src: 10.10.10.6, Via: ''}
      10.200.1.0/24: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      10.200.2.0/24: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      10.201.11.0/24: {Dev: int_br111, Src: 10.201.11.2, Via: ''}
      10.201.12.0/24: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      10.202.11.0/24: {Dev: int_br211, Src: 10.202.11.2, Via: ''}
      10.202.12.0/24: {Dev: int_br211, Src: '', Via: 10.202.11.1}
      10.203.13.0/24: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      10.203.14.0/24: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      10.204.13.0/24: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      10.204.14.0/24: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      172.17.0.0/16: {Dev: eth0, Src: 172.17.0.7, Via: ''}
      172.21.1.0/24: {Dev: br_172.21.1.1, Src: 172.21.1.1, Via: ''}
      172.21.2.0/24: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      172.21.3.0/24: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      172.21.4.0/24: {Dev: int_br211, Src: '', Via: 10.202.11.1}
      172.22.1.0/24: {Dev: br_172.22.1.1, Src: 172.22.1.1, Via: ''}
      172.22.2.0/24: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      172.22.3.0/24: {Dev: int_br111, Src: '', Via: 10.201.11.1}
      172.22.4.0/24: {Dev: int_br211, Src: '', Via: 10.202.11.1}
      default: {Dev: eth0, Src: '', Via: 172.17.0.1}
operational-ce2.ip:
  groups:
  - [ce2]
  instance:
    addr: {10.1.2.2: lo, 10.10.10.7: eth0, 10.201.12.2: int_br112, 10.202.12.2: int_br212,
      127.0.0.1: lo, 172.17.0.8: eth0, 172.21.2.1: br_172.21.2.1, 172.22.2.1: br_172.22.2.1}
    dev:
      br_172.21.2.1: [172.21.2.1]
      br_172.22.2.1: [172.22.2.1]
      eth0: [172.17.0.8, 10.10.10.7]
      int_br112: [10.201.12.2]
                 :

[Step 10] Start jupyter notebook and open the notebooks here.

cd to the project root directory, then:
$ cd ipynb
$ jupyter notebook

You need to change the IP address to the one that tega db binds:

import tega.driver
d = tega.driver.Driver(host='192.168.57.133')  <== MODIFY THIS!

Development environment setup

Python3.5

  • Download the source code from here.
  • Build and install it.

IPython/Jupyter

The easiest way is to install Anaconda

Note that Anaconda already includes Python3.5 and other packages used by this project as well.

Golang and protobuf

$ ./autogen.sh
$ ./configure
$ make
$ make install
  • Add /usr/local/lib to LD_LIBRARY_PATH
$ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARLY_PATH

Go plugin for vim

Install vim-go to your vim.

nlan's People

Contributors

araobp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nlan's Issues

Migrating from etcd to tega

I would prefer tega rather than etcd:

  • tega is schema-less
  • tega supports JSON types, etcd supports string-type only
  • tega can accept CRUD operation at an arbitrary path/depth
  • tega supports Data Change Notification (DCN) at an arbitrary path/depth
  • tega supports pubsub and bi-directional communications: I don't need to know IP addresses of each docker containers
  • tega supports RPC inventory: you can invoke RPC APIs from tega CLI
  • tega can run on Raspberry Pi: small footprint
  • tega supports rollback: MUST for router configuration
  • tega supports two-phase commit: MUST for router configuration
  • tega supports an interactive CLI, etcd does not
  • I don't need a RAFT-based data base for such a small project
  • tega supports a plugin framework
  • tega uses coroutine (tornado), zero-overhead and good for a single-core CPU

I need to develop tega driver for golang.

On the other hand, nlan agent (golang) seems to run faster than the original neutron-lan agent (python):

  • Golang supports light-weight thread (goroutine)
  • Python has an overhead (a few M bytes) of its runtime: python interpreter: no good for docker/RaspberryPi
  • Python (CPython) is not good at parallel computing because of GIL

BTY, I would use ZooKeeper rather than etcd, since ZooKeeper supports "ephemeral nodes" that are useful features for SDN-related projects. But for this project, I have decided to use tega, because I need to run a config DB on my small Raspberry Pi!

stats agent

Is it possible to collect stats info from netlink?

I don't like screen-scraping.

Let's investigate if this is useful for stats: https://github.com/milosgajdos83/tenus

My plan is to make the agent collect stats and put it onto nlan.stats. tree (ephemeral).

Example:

nlan.stats.ce1.interfaces
nlan.stats.ce1.interface.eth0.address
         :

Or make the agent work as micro functions and collect stats on demand.
Example:

nlan.stats.ce1.interfaces()
nlan.stats.ce1.interface.eth0.address()
         :

Panic from master.go

$ ./master.sh ptn-bgp
2015/12/29 17:58:21 /root/work/src/github.com/araobp/nlan/etc/ptn-bgp.yaml
2015/12/29 17:58:21 # iBGP/eBGP simulation
#
States:
  - Router: pe1
    Model:
      Ptn:
        Networks:
          - Id: wan
            Nodes:
              Ptn: ptnpe1w
              L2sw: l2swpe1w
            Links:
              LocalIp: {{.pe1}}
              RemoteIps: [{{.pe2}}, {{.pe3}}, {{.pe4}}, {{.rr}}]
            L2Vpn:
              - Vid: 101
                Vni: 1
                Peers: [{{.pe2}}, {{.pe3}}, {{.pe4}}, {{.rr}}]
                Ip: 10.200.1.101/24
              - Vid: 102
                Vni: 2
                Peers: [{{.pe2}}, {{.pe3}}, {{.pe4}}, {{.rr}}]
                Ip: 10.200.2.101/24
          - Id: access
            Nodes:
              Ptn: ptnpe1a
              L2sw: l2swpe1a
            Links:
              LocalIp: {{.pe1}}
              RemoteIps: [{{.ce1}}, {{.ce2}}]
            L2Vpn:
              - Vid: 11
                Vni: 111
                Peers: [{{.ce1}}]
                Ip: 10.201.11.1/24
              - Vid: 12
                Vni: 112
                Peers: [{{.ce2}}]
                Ip: 10.201.12.1/24
      Router:
        Loopback: 10.1.1.1/32
        Bgp:
          - As: 100
            Neighbors:
              - Peer: 10.200.1.105
                RemoteAs: 100
                NextHopSelf: true
              - Peer: 10.201.11.2
                RemoteAs: 1001
              - Peer: 10.201.12.2
                RemoteAs: 1002
  - Router: pe2
    Model:
      Ptn:
        Networks:
          - Id: wan
            Nodes:
              Ptn: ptnpe2w
              L2sw: l2swpe2w
            Links:
              LocalIp: {{.pe2}}
              RemoteIps: [{{.pe1}}, {{.pe3}}, {{.pe4}}, {{.rr}}]
            L2Vpn:
              - Vid: 101
                Vni: 1
                Peers: [{{.pe1}}, {{.pe3}}, {{.pe4}}, {{.rr}}]
                Ip: 10.200.1.102/24
              - Vid: 102
                Vni: 2
                Peers: [{{.pe2}}, {{.pe3}}, {{.pe4}}, {{.rr}}]
                Ip: 10.200.2.102/24
          - Id: access
            Nodes:
              Ptn: ptnpe2a
              L2sw: l2swpe2a
            Links:
              LocalIp: {{.pe2}}
              RemoteIps: [{{.ce1}}, {{.ce2}}]
            L2Vpn:
              - Vid: 11
                Vni: 211
                Peers: [{{.ce1}}]
                Ip: 10.202.11.1/24
              - Vid: 12
                Vni: 212
                Peers: [{{.ce2}}]
                Ip: 10.202.12.1/24
      Router:
        Loopback: 10.1.1.2/32
        Bgp:
          - As: 100
            Neighbors:
              - Peer: 10.200.1.105
                RemoteAs: 100
                NextHopSelf: true
              - Peer: 10.202.11.2
                RemoteAs: 1001
              - Peer: 10.202.12.2
                RemoteAs: 1002
  - Router: pe3
    Model:
      Ptn:
        Networks:
          - Id: wan
            Nodes:
              Ptn: ptnpe3w
              L2sw: l2swpe3w
            Links:
              LocalIp: {{.pe3}}
              RemoteIps: [{{.pe1}}, {{.pe2}}, {{.pe4}}, {{.rr}}]
            L2Vpn:
              - Vid: 101
                Vni: 1
                Peers: [{{.pe1}}, {{.pe2}}, {{.pe4}}, {{.rr}}]
                Ip: 10.200.1.103/24
              - Vid: 102
                Vni: 2
                Peers: [{{.pe1}}, {{.pe2}}, {{.pe4}}, {{.rr}}]
                Ip: 10.200.2.103/24
          - Id: access
            Nodes:
              Ptn: ptnpe3a
              L2sw: l2swpe3a
            Links:
              LocalIp: {{.pe3}}
              RemoteIps: [{{.ce3}}, {{.ce4}}]
            L2Vpn:
              - Vid: 13
                Vni: 313
                Peers: [{{.ce3}}]
                Ip: 10.203.13.1/24
              - Vid: 14
                Vni: 314
                Peers: [{{.ce4}}]
                Ip: 10.203.14.1/24
      Router:
        Loopback: 10.1.1.3/32
        Bgp:
          - As: 100
            Neighbors:
              - Peer: 10.200.1.105
                RemoteAs: 100
                NextHopSelf: true
              - Peer: 10.203.13.2
                RemoteAs: 1003
              - Peer: 10.203.14.2
                RemoteAs: 1004
  - Router: pe4
    Model:
      Ptn:
        Networks:
          - Id: wan
            Nodes:
              Ptn: ptnpe4w
              L2sw: l2swpe4w
            Links:
              LocalIp: {{.pe4}}
              RemoteIps: [{{.pe1}}, {{.pe2}}, {{.pe3}}, {{.rr}}]
            L2Vpn:
              - Vid: 101
                Vni: 1
                Peers: [{{.pe1}}, {{.pe2}}, {{.pe3}}, {{.rr}}]
                Ip: 10.200.1.104/24
              - Vid: 102
                Vni: 2
                Peers: [{{.pe1}}, {{.pe2}}, {{.pe3}}, {{.rr}}]
                Ip: 10.200.2.104/24
          - Id: access
            Nodes:
              Ptn: ptnpe4a
              L2sw: l2swpe4a
            Links:
              LocalIp: {{.pe4}}
              RemoteIps: [{{.ce3}}, {{.ce4}}]
            L2Vpn:
              - Vid: 13
                Vni: 413
                Peers: [{{.ce3}}]
                Ip: 10.204.13.1/24
              - Vid: 14
                Vni: 414
                Peers: [{{.ce4}}]
                Ip: 10.204.14.1/24
      Router:
        Loopback: 10.1.1.4/32
        Bgp:
          - As: 100
            Neighbors:
              - Peer: 10.200.1.105
                RemoteAs: 100
                NextHopSelf: true
              - Peer: 10.204.13.2
                RemoteAs: 1003
              - Peer: 10.204.14.2
                RemoteAs: 1004
  - Router: rr
    Model:
      Ptn:
        Networks:
          - Id: wan
            Nodes:
              Ptn: ptnrrw
              L2sw: l2swrrw
            Links:
              LocalIp: {{.rr}}
              RemoteIps: [{{.pe1}}, {{.pe2}}, {{.pe3}}, {{.pe4}}]
            L2Vpn:
              - Vid: 101
                Vni: 1
                Peers: [{{.pe1}}, {{.pe2}}, {{.pe3}}, {{.pe4}}]
                Ip: 10.200.1.105/24
              - Vid: 102
                Vni: 2
                Peers: [{{.pe1}}, {{.pe2}}, {{.pe3}}, {{.pe4}}]
                Ip: 10.200.2.105/24
      Router:
        Loopback: 10.1.1.5/32
        Bgp:
          - As: 100
            Neighbors:
              - Peer: 10.200.1.101
                RemoteAs: 100
                RouteReflectorClient: true
              - Peer: 10.200.1.102
                RemoteAs: 100
                RouteReflectorClient: true
              - Peer: 10.200.1.103
                RemoteAs: 100
                RouteReflectorClient: true
              - Peer: 10.200.1.104
                RemoteAs: 100
                RouteReflectorClient: true
  - Router: ce1
    Model:
      Ptn:
        Networks:
          - Id: access
            Nodes:
              Ptn: ptnce1a
              L2sw: l2swce1a
            Links:
              LocalIp: {{.ce1}}
              RemoteIps: [{{.pe1}}, {{.pe2}}]
            L2Vpn:
              - Vid: 1
                Vni: 111
                Peers: [{{.pe1}}]
                Ip: 10.201.11.2/24
              - Vid: 2
                Vni: 211
                Peers: [{{.pe2}}]
                Ip: 10.202.11.2/24
      Vhosts:
        VhostProps:
          - Network: 172.21.1.1/24
            Vhosts: 2
          - Network: 172.22.1.1/24
            Vhosts: 2
      Router:
        Loopback: 10.1.2.1/32
        Bgp:
          - As: 1001
            Neighbors:
              - Peer: 10.201.11.1
                RemoteAs: 100
              - Peer: 10.202.11.1
                RemoteAs: 100
  - Router: ce2
    Model:
      Ptn:
        Networks:
          - Id: access
            Nodes:
              Ptn: ptnce2a
              L2sw: l2swce2a
            Links:
              LocalIp: {{.ce2}}
              RemoteIps: [{{.pe1}}, {{.pe2}}]
            L2Vpn:
              - Vid: 1
                Vni: 112
                Peers: [{{.pe1}}]
                Ip: 10.201.12.2/24
              - Vid: 2
                Vni: 212
                Peers: [{{.pe2}}]
                Ip: 10.202.12.2/24
      Vhosts:
        VhostProps:
          - Network: 172.21.2.1/24
            Vhosts: 2
          - Network: 172.22.2.1/24
            Vhosts: 2
      Router:
        Loopback: 10.1.2.2/32
        Bgp:
          - As: 1002
            Neighbors:
              - Peer: 10.201.12.1
                RemoteAs: 100
              - Peer: 10.202.12.1
                RemoteAs: 100
  - Router: ce3
    Model:
      Ptn:
        Networks:
          - Id: access
            Nodes:
              Ptn: ptnce3a
              L2sw: l2swce3a
            Links:
              LocalIp: {{.ce3}}
              RemoteIps: [{{.pe3}}, {{.pe4}}]
            L2Vpn:
              - Vid: 3
                Vni: 313
                Peers: [{{.pe3}}]
                Ip: 10.203.13.2/24
              - Vid: 4
                Vni: 413
                Peers: [{{.pe4}}]
                Ip: 10.204.13.2/24
      Vhosts:
        VhostProps:
          - Network: 172.21.3.1/24
            Vhosts: 2
          - Network: 172.22.3.1/24
            Vhosts: 2
      Router:
        Loopback: 10.1.2.3/32
        Bgp:
          - As: 1003
            Neighbors:
              - Peer: 10.203.13.1
                RemoteAs: 100
              - Peer: 10.204.13.1
                RemoteAs: 100
  - Router: ce4
    Model:
      Ptn:
        Networks:
          - Id: access
            Nodes:
              Ptn: ptnce4a
              L2sw: l2swce4a
            Links:
              LocalIp: {{.ce4}}
              RemoteIps: [{{.pe3}}, {{.pe4}}]
            L2Vpn:
              - Vid: 3
                Vni: 314
                Peers: [{{.pe3}}]
                Ip: 10.203.14.2/24
              - Vid: 4
                Vni: 414
                Peers: [{{.pe4}}]
                Ip: 10.204.14.2/24
      Vhosts:
        VhostProps:
          - Network: 172.21.4.1/24
            Vhosts: 2
          - Network: 172.22.4.1/24
            Vhosts: 2
      Router:
        Loopback: 10.1.2.4/32
        Bgp:
          - As: 1004
            Neighbors:
              - Peer: 10.203.14.1
                RemoteAs: 100
              - Peer: 10.204.14.1
                RemoteAs: 100
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x8 pc=0xa03ac]

goroutine 1 [running]:
github.com/araobp/nlan/util.ListHosts(0x51ee01, 0x10bebee0)
        /root/work/src/github.com/araobp/nlan/util/etcd.go:78 +0x154
github.com/araobp/nlan/common.ReadState(0x10b256c8, 0x0, 0x1, 0x51af10)
        /root/work/src/github.com/araobp/nlan/common/state.go:32 +0x22c
main.main()
        /root/work/src/github.com/araobp/nlan/master.go:120 +0x1a4

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /root/go/src/runtime/asm_arm.s:1036 +0x4

goroutine 13 [IO wait]:
net.runtime_pollWait(0xb63f6bb8, 0x72, 0x10b0e090)
        /root/go/src/runtime/netpoll.go:157 +0x60
net.(*pollDesc).Wait(0x10b17db8, 0x72, 0x0, 0x0)
        /root/go/src/net/fd_poll_runtime.go:73 +0x34
net.(*pollDesc).WaitRead(0x10b17db8, 0x0, 0x0)
        /root/go/src/net/fd_poll_runtime.go:78 +0x30
net.(*netFD).Read(0x10b17d80, 0x10c0b000, 0x1000, 0x1000, 0x0, 0xb63f1030, 0x10b0e090)
        /root/go/src/net/fd_unix.go:232 +0x1c4
net.(*conn).Read(0x10b25810, 0x10c0b000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
        /root/go/src/net/net.go:172 +0xc8
net/http.noteEOFReader.Read(0xb63f6cf0, 0x10b25810, 0x10b14cec, 0x10c0b000, 0x1000, 0x1000, 0x23977c, 0x0, 0x0)
        /root/go/src/net/http/transport.go:1370 +0x5c
net/http.(*noteEOFReader).Read(0x10bee780, 0x10c0b000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
        <autogenerated>:126 +0xd0
bufio.(*Reader).fill(0x10bec4b0)
        /root/go/src/bufio/bufio.go:97 +0x1c4
bufio.(*Reader).Peek(0x10bec4b0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)
        /root/go/src/bufio/bufio.go:132 +0xcc
net/http.(*persistConn).readLoop(0x10b14cc0)
        /root/go/src/net/http/transport.go:876 +0xe4
created by net/http.(*Transport).dialConn
        /root/go/src/net/http/transport.go:685 +0xab4

goroutine 14 [select]:
net/http.(*persistConn).writeLoop(0x10b14cc0)
        /root/go/src/net/http/transport.go:1009 +0x314
created by net/http.(*Transport).dialConn
        /root/go/src/net/http/transport.go:686 +0xad0
2015/12/29 17:58:22 /root/work/src/github.com/araobp/nlan/etc/ptn-bgp.yaml
2015/12/29 17:58:22 # iBGP/eBGP simulation
#
States:
  - Router: pe1
    Model:
      Ptn:
        Networks:
          - Id: wan
            Nodes:
              Ptn: ptnpe1w
              L2sw: l2swpe1w
            Links:
              LocalIp: {{.pe1}}
              RemoteIps: [{{.pe2}}, {{.pe3}}, {{.pe4}}, {{.rr}}]
            L2Vpn:
              - Vid: 101
                Vni: 1
                Peers: [{{.pe2}}, {{.pe3}}, {{.pe4}}, {{.rr}}]
                Ip: 10.200.1.101/24
              - Vid: 102
                Vni: 2
                Peers: [{{.pe2}}, {{.pe3}}, {{.pe4}}, {{.rr}}]
                Ip: 10.200.2.101/24
          - Id: access
            Nodes:
              Ptn: ptnpe1a
              L2sw: l2swpe1a
            Links:
              LocalIp: {{.pe1}}
              RemoteIps: [{{.ce1}}, {{.ce2}}]
            L2Vpn:
              - Vid: 11
                Vni: 111
                Peers: [{{.ce1}}]
                Ip: 10.201.11.1/24
              - Vid: 12
                Vni: 112
                Peers: [{{.ce2}}]
                Ip: 10.201.12.1/24
      Router:
        Loopback: 10.1.1.1/32
        Bgp:
          - As: 100
            Neighbors:
              - Peer: 10.200.1.105
                RemoteAs: 100
                NextHopSelf: true
              - Peer: 10.201.11.2
                RemoteAs: 1001
              - Peer: 10.201.12.2
                RemoteAs: 1002
  - Router: pe2
    Model:
      Ptn:
        Networks:
          - Id: wan
            Nodes:
              Ptn: ptnpe2w
              L2sw: l2swpe2w
            Links:
              LocalIp: {{.pe2}}
              RemoteIps: [{{.pe1}}, {{.pe3}}, {{.pe4}}, {{.rr}}]
            L2Vpn:
              - Vid: 101
                Vni: 1
                Peers: [{{.pe1}}, {{.pe3}}, {{.pe4}}, {{.rr}}]
                Ip: 10.200.1.102/24
              - Vid: 102
                Vni: 2
                Peers: [{{.pe2}}, {{.pe3}}, {{.pe4}}, {{.rr}}]
                Ip: 10.200.2.102/24
          - Id: access
            Nodes:
              Ptn: ptnpe2a
              L2sw: l2swpe2a
            Links:
              LocalIp: {{.pe2}}
              RemoteIps: [{{.ce1}}, {{.ce2}}]
            L2Vpn:
              - Vid: 11
                Vni: 211
                Peers: [{{.ce1}}]
                Ip: 10.202.11.1/24
              - Vid: 12
                Vni: 212
                Peers: [{{.ce2}}]
                Ip: 10.202.12.1/24
      Router:
        Loopback: 10.1.1.2/32
        Bgp:
          - As: 100
            Neighbors:
              - Peer: 10.200.1.105
                RemoteAs: 100
                NextHopSelf: true
              - Peer: 10.202.11.2
                RemoteAs: 1001
              - Peer: 10.202.12.2
                RemoteAs: 1002
  - Router: pe3
    Model:
      Ptn:
        Networks:
          - Id: wan
            Nodes:
              Ptn: ptnpe3w
              L2sw: l2swpe3w
            Links:
              LocalIp: {{.pe3}}
              RemoteIps: [{{.pe1}}, {{.pe2}}, {{.pe4}}, {{.rr}}]
            L2Vpn:
              - Vid: 101
                Vni: 1
                Peers: [{{.pe1}}, {{.pe2}}, {{.pe4}}, {{.rr}}]
                Ip: 10.200.1.103/24
              - Vid: 102
                Vni: 2
                Peers: [{{.pe1}}, {{.pe2}}, {{.pe4}}, {{.rr}}]
                Ip: 10.200.2.103/24
          - Id: access
            Nodes:
              Ptn: ptnpe3a
              L2sw: l2swpe3a
            Links:
              LocalIp: {{.pe3}}
              RemoteIps: [{{.ce3}}, {{.ce4}}]
            L2Vpn:
              - Vid: 13
                Vni: 313
                Peers: [{{.ce3}}]
                Ip: 10.203.13.1/24
              - Vid: 14
                Vni: 314
                Peers: [{{.ce4}}]
                Ip: 10.203.14.1/24
      Router:
        Loopback: 10.1.1.3/32
        Bgp:
          - As: 100
            Neighbors:
              - Peer: 10.200.1.105
                RemoteAs: 100
                NextHopSelf: true
              - Peer: 10.203.13.2
                RemoteAs: 1003
              - Peer: 10.203.14.2
                RemoteAs: 1004
  - Router: pe4
    Model:
      Ptn:
        Networks:
          - Id: wan
            Nodes:
              Ptn: ptnpe4w
              L2sw: l2swpe4w
            Links:
              LocalIp: {{.pe4}}
              RemoteIps: [{{.pe1}}, {{.pe2}}, {{.pe3}}, {{.rr}}]
            L2Vpn:
              - Vid: 101
                Vni: 1
                Peers: [{{.pe1}}, {{.pe2}}, {{.pe3}}, {{.rr}}]
                Ip: 10.200.1.104/24
              - Vid: 102
                Vni: 2
                Peers: [{{.pe1}}, {{.pe2}}, {{.pe3}}, {{.rr}}]
                Ip: 10.200.2.104/24
          - Id: access
            Nodes:
              Ptn: ptnpe4a
              L2sw: l2swpe4a
            Links:
              LocalIp: {{.pe4}}
              RemoteIps: [{{.ce3}}, {{.ce4}}]
            L2Vpn:
              - Vid: 13
                Vni: 413
                Peers: [{{.ce3}}]
                Ip: 10.204.13.1/24
              - Vid: 14
                Vni: 414
                Peers: [{{.ce4}}]
                Ip: 10.204.14.1/24
      Router:
        Loopback: 10.1.1.4/32
        Bgp:
          - As: 100
            Neighbors:
              - Peer: 10.200.1.105
                RemoteAs: 100
                NextHopSelf: true
              - Peer: 10.204.13.2
                RemoteAs: 1003
              - Peer: 10.204.14.2
                RemoteAs: 1004
  - Router: rr
    Model:
      Ptn:
        Networks:
          - Id: wan
            Nodes:
              Ptn: ptnrrw
              L2sw: l2swrrw
            Links:
              LocalIp: {{.rr}}
              RemoteIps: [{{.pe1}}, {{.pe2}}, {{.pe3}}, {{.pe4}}]
            L2Vpn:
              - Vid: 101
                Vni: 1
                Peers: [{{.pe1}}, {{.pe2}}, {{.pe3}}, {{.pe4}}]
                Ip: 10.200.1.105/24
              - Vid: 102
                Vni: 2
                Peers: [{{.pe1}}, {{.pe2}}, {{.pe3}}, {{.pe4}}]
                Ip: 10.200.2.105/24
      Router:
        Loopback: 10.1.1.5/32
        Bgp:
          - As: 100
            Neighbors:
              - Peer: 10.200.1.101
                RemoteAs: 100
                RouteReflectorClient: true
              - Peer: 10.200.1.102
                RemoteAs: 100
                RouteReflectorClient: true
              - Peer: 10.200.1.103
                RemoteAs: 100
                RouteReflectorClient: true
              - Peer: 10.200.1.104
                RemoteAs: 100
                RouteReflectorClient: true
  - Router: ce1
    Model:
      Ptn:
        Networks:
          - Id: access
            Nodes:
              Ptn: ptnce1a
              L2sw: l2swce1a
            Links:
              LocalIp: {{.ce1}}
              RemoteIps: [{{.pe1}}, {{.pe2}}]
            L2Vpn:
              - Vid: 1
                Vni: 111
                Peers: [{{.pe1}}]
                Ip: 10.201.11.2/24
              - Vid: 2
                Vni: 211
                Peers: [{{.pe2}}]
                Ip: 10.202.11.2/24
      Vhosts:
        VhostProps:
          - Network: 172.21.1.1/24
            Vhosts: 2
          - Network: 172.22.1.1/24
            Vhosts: 2
      Router:
        Loopback: 10.1.2.1/32
        Bgp:
          - As: 1001
            Neighbors:
              - Peer: 10.201.11.1
                RemoteAs: 100
              - Peer: 10.202.11.1
                RemoteAs: 100
  - Router: ce2
    Model:
      Ptn:
        Networks:
          - Id: access
            Nodes:
              Ptn: ptnce2a
              L2sw: l2swce2a
            Links:
              LocalIp: {{.ce2}}
              RemoteIps: [{{.pe1}}, {{.pe2}}]
            L2Vpn:
              - Vid: 1
                Vni: 112
                Peers: [{{.pe1}}]
                Ip: 10.201.12.2/24
              - Vid: 2
                Vni: 212
                Peers: [{{.pe2}}]
                Ip: 10.202.12.2/24
      Vhosts:
        VhostProps:
          - Network: 172.21.2.1/24
            Vhosts: 2
          - Network: 172.22.2.1/24
            Vhosts: 2
      Router:
        Loopback: 10.1.2.2/32
        Bgp:
          - As: 1002
            Neighbors:
              - Peer: 10.201.12.1
                RemoteAs: 100
              - Peer: 10.202.12.1
                RemoteAs: 100
  - Router: ce3
    Model:
      Ptn:
        Networks:
          - Id: access
            Nodes:
              Ptn: ptnce3a
              L2sw: l2swce3a
            Links:
              LocalIp: {{.ce3}}
              RemoteIps: [{{.pe3}}, {{.pe4}}]
            L2Vpn:
              - Vid: 3
                Vni: 313
                Peers: [{{.pe3}}]
                Ip: 10.203.13.2/24
              - Vid: 4
                Vni: 413
                Peers: [{{.pe4}}]
                Ip: 10.204.13.2/24
      Vhosts:
        VhostProps:
          - Network: 172.21.3.1/24
            Vhosts: 2
          - Network: 172.22.3.1/24
            Vhosts: 2
      Router:
        Loopback: 10.1.2.3/32
        Bgp:
          - As: 1003
            Neighbors:
              - Peer: 10.203.13.1
                RemoteAs: 100
              - Peer: 10.204.13.1
                RemoteAs: 100
  - Router: ce4
    Model:
      Ptn:
        Networks:
          - Id: access
            Nodes:
              Ptn: ptnce4a
              L2sw: l2swce4a
            Links:
              LocalIp: {{.ce4}}
              RemoteIps: [{{.pe3}}, {{.pe4}}]
            L2Vpn:
              - Vid: 3
                Vni: 314
                Peers: [{{.pe3}}]
                Ip: 10.203.14.2/24
              - Vid: 4
                Vni: 414
                Peers: [{{.pe4}}]
                Ip: 10.204.14.2/24
      Vhosts:
        VhostProps:
          - Network: 172.21.4.1/24
            Vhosts: 2
          - Network: 172.22.4.1/24
            Vhosts: 2
      Router:
        Loopback: 10.1.2.4/32
        Bgp:
          - As: 1004
            Neighbors:
              - Peer: 10.203.14.1
                RemoteAs: 100
              - Peer: 10.204.14.1
                RemoteAs: 100
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x8 pc=0xa03ac]

goroutine 1 [running]:
github.com/araobp/nlan/util.ListHosts(0x51ee01, 0x10bebee0)
        /root/work/src/github.com/araobp/nlan/util/etcd.go:78 +0x154
github.com/araobp/nlan/common.ReadState(0x10b256c8, 0x0, 0x1, 0x51af10)
        /root/work/src/github.com/araobp/nlan/common/state.go:32 +0x22c
main.main()
        /root/work/src/github.com/araobp/nlan/master.go:120 +0x1a4

goroutine 17 [syscall, locked to thread]:
runtime.goexit()
        /root/go/src/runtime/asm_arm.s:1036 +0x4

goroutine 13 [IO wait]:
net.runtime_pollWait(0xb6383b98, 0x72, 0x10b0e090)
        /root/go/src/runtime/netpoll.go:157 +0x60
net.(*pollDesc).Wait(0x10b17db8, 0x72, 0x0, 0x0)
        /root/go/src/net/fd_poll_runtime.go:73 +0x34
net.(*pollDesc).WaitRead(0x10b17db8, 0x0, 0x0)
        /root/go/src/net/fd_poll_runtime.go:78 +0x30
net.(*netFD).Read(0x10b17d80, 0x10c0b000, 0x1000, 0x1000, 0x0, 0xb637e030, 0x10b0e090)
        /root/go/src/net/fd_unix.go:232 +0x1c4
net.(*conn).Read(0x10b25810, 0x10c0b000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
        /root/go/src/net/net.go:172 +0xc8
net/http.noteEOFReader.Read(0xb6383cd0, 0x10b25810, 0x10b14ecc, 0x10c0b000, 0x1000, 0x1000, 0x23977c, 0x0, 0x0)
        /root/go/src/net/http/transport.go:1370 +0x5c
net/http.(*noteEOFReader).Read(0x10bee780, 0x10c0b000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
        <autogenerated>:126 +0xd0
bufio.(*Reader).fill(0x10bec4b0)
        /root/go/src/bufio/bufio.go:97 +0x1c4
bufio.(*Reader).Peek(0x10bec4b0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)
        /root/go/src/bufio/bufio.go:132 +0xcc
net/http.(*persistConn).readLoop(0x10b14ea0)
        /root/go/src/net/http/transport.go:876 +0xe4
created by net/http.(*Transport).dialConn
        /root/go/src/net/http/transport.go:685 +0xab4

goroutine 14 [select]:
net/http.(*persistConn).writeLoop(0x10b14ea0)
        /root/go/src/net/http/transport.go:1009 +0x314
created by net/http.(*Transport).dialConn
        /root/go/src/net/http/transport.go:686 +0xad0

Simple local DB

Local DB for storing state.

For the time being, just save state in a file ...

cmd plugin

A plugin to execute shell command at remote containers.

New physical interface to RPI

I 've got WiFI USB dongle. Use it as "eth1".

          (snort as IDS)
                 |
Internet - eth0 -+- (iptables) --- (R) --- eth1 - Other hosts

SDN model with iproute2 (w/o Open vSwitch)

I don't want to run OVSDB in my containers any longer to simplify the architecture.

I just use Linux bridges and Linux-native tunnels such as tuntap or VXLAN.

Something like this:
new arch

IP address of docker0

Docker on HypriotOS assigns 172.17.0.1 instead of 172.17.42.1:

$ ip addr show dev docker0
3: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:db:b8:08:2d brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:dbff:feb8:82d/64 scope link
       valid_lft forever preferred_lft forever

Embedding gobgp

Add an option to run gobgp in an embedded mode.
Coexistence of quagga and gobgp

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.