├── scripts ├── dump-ping.sh └── dump-traceroute.sh ├── patch_bgpd_quagga.patch ├── README.md ├── static ├── noip.py ├── simple.py ├── static-example2.py ├── static-default.py ├── static-err3.py ├── static-err.py ├── static-err2.py └── static-example1.py ├── .gitignore ├── ospfv3 └── ospfv3-example.py ├── Vagrantfile ├── bgp └── simple-bgp.py ├── manifests └── default.pp └── LICENSE /scripts/dump-ping.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | tcpdump -v -i $1 -n 'icmp6 && (ip6[40] == 128 || ip6[40]==129)' -------------------------------------------------------------------------------- /scripts/dump-traceroute.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | tcpdump -v -i $1 -n '(ip6 && udp) || (icmp6 && (ip6[40] == 1 || ip6[40]==3))' -------------------------------------------------------------------------------- /patch_bgpd_quagga.patch: -------------------------------------------------------------------------------- 1 | diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c 2 | index 1158ab1..d734c20 100644 3 | --- a/bgpd/bgp_nht.c 4 | +++ b/bgpd/bgp_nht.c 5 | @@ -409,8 +409,8 @@ make_prefix (int afi, struct bgp_info *ri, struct prefix *p) 6 | break; 7 | #ifdef HAVE_IPV6 8 | case AFI_IP6: 9 | - if (ri->attr->extra->mp_nexthop_len != 16 10 | - || IN6_IS_ADDR_LINKLOCAL (&ri->attr->extra->mp_nexthop_global)) 11 | + if (ri->attr->extra->mp_nexthop_len == 16 12 | + && IN6_IS_ADDR_LINKLOCAL (&ri->attr->extra->mp_nexthop_global)) 13 | return -1; 14 | 15 | p->family = AF_INET6; 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Routing Examples 2 | 3 | IPv6 routing examples that use [IPMininet](https://github.com/oliviertilmans/ipmininet) and are designed for helping the students who read for the [Computer Networking : Principles, Protocols and Practice](http://cnp3book.info.ucl.ac.be) ebook. Several examples are discussed in the [Networking notes blog](https://obonaventure.github.io/cnp3blog/), e.g. : 4 | 5 | - [Experimenting with Mininet and IPv6 routes](https://obonaventure.github.io/cnp3blog/ipmininet/) 6 | - [Observing IPv6 link local addresses](https://obonaventure.github.io/cnp3blog/ipv6-fe80/) 7 | - [Exploring static routing with IPMininet](https://obonaventure.github.io/cnp3blog/ipmininet-static/) 8 | - [Exploring OSPFv3 routing with IPMininet](https://obonaventure.github.io/cnp3blog/ipmininet-ospfv3/) 9 | - [Exploring BGP with IPMininet](https://obonaventure.github.io/cnp3blog/bgp/) 10 | - [Fixing incorrect IPv6 routing tables](https://obonaventure.github.io/cnp3blog/static2/) 11 | -------------------------------------------------------------------------------- /static/noip.py: -------------------------------------------------------------------------------- 1 | 2 | import ipmininet 3 | from ipmininet.cli import IPCLI 4 | from ipmininet.ipnet import IPNet 5 | from ipmininet.router.config import RouterConfig 6 | from ipmininet.iptopo import IPTopo 7 | 8 | from mininet.log import lg 9 | 10 | """ 11 | 12 | This file contains a simple topology with one router and two hosts 13 | 14 | 15 | h1 ---- r ---- h2 16 | 17 | In this topology, there are no IPv6 addresses assigned to the hosts or 18 | to the router. 19 | 20 | """ 21 | 22 | 23 | class NoIP(IPTopo): 24 | 25 | def build(self, *args, **kwargs): 26 | """ 27 | """ 28 | r = self.addRouter_v6('r', config=(RouterConfig)) 29 | h1 = self.addHost('h1') 30 | h2 = self.addHost('h2') 31 | self.addLink(r, h1) 32 | self.addLink(r, h2) 33 | super(NoIP, self).build(*args, **kwargs) 34 | 35 | 36 | def addRouter_v6(self, name, **kwargs): 37 | return self.addRouter(name, use_v4=False, use_v6=True, **kwargs) 38 | 39 | 40 | ipmininet.DEBUG_FLAG = True 41 | lg.setLogLevel("info") 42 | 43 | # Start network 44 | net = IPNet(topo=NoIP(), use_v4=False, allocate_IPs=False) 45 | 46 | try: 47 | net.start() 48 | IPCLI(net) 49 | finally: 50 | net.stop() 51 | 52 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # dotenv 83 | .env 84 | 85 | # virtualenv 86 | .venv 87 | venv/ 88 | ENV/ 89 | 90 | # Spyder project settings 91 | .spyderproject 92 | .spyproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # mkdocs documentation 98 | /site 99 | 100 | # mypy 101 | .mypy_cache/ 102 | 103 | # Vagrant 104 | .vagrant/ 105 | -------------------------------------------------------------------------------- /ospfv3/ospfv3-example.py: -------------------------------------------------------------------------------- 1 | from mininet.log import lg 2 | 3 | import ipmininet 4 | from ipmininet.cli import IPCLI 5 | from ipmininet.ipnet import IPNet 6 | from ipmininet.iptopo import IPTopo 7 | 8 | """This file contains a simple network topology""" 9 | 10 | 11 | class SimpleTopo(IPTopo): 12 | 13 | def build(self, *args, **kwargs): 14 | """ 15 | The network topology is the following : 16 | 17 | h1-- ra ---- rb ---- re -- h2 18 | | | | 19 | +----- rc -----+ 20 | 21 | 22 | """ 23 | 24 | #Routers 25 | ra = self.addRouter_v6('ra') 26 | rb = self.addRouter_v6('rb') 27 | rc = self.addRouter_v6('rc') 28 | re = self.addRouter_v6('re') 29 | 30 | #Links 31 | self.addLink(ra, rb, params1={"ip": "2001:2345:7::a/64"}, 32 | params2={"ip": "2001:2345:7::b/64"}, igp_metric=5) 33 | self.addLink(ra, rc, params1={"ip": "2001:2345:4::a/64"}, 34 | params2={"ip": "2001:2345:4::c/64"}) 35 | self.addLink(rb, rc, params1={"ip": "2001:2345:5::b/64"}, 36 | params2={"ip": "2001:2345:5::c/64"}) 37 | self.addLink(rb, re, params1={"ip": "2001:2345:6::b/64"}, 38 | params2={"ip": "2001:2345:6::e/64"}, igp_metric=5) 39 | self.addLink(rc, re, params1={"ip": "2001:2345:3::c/64"}, 40 | params2={"ip": "2001:2345:3::e/64"}) 41 | 42 | self.addLink(ra, self.addHost('h1'), 43 | params1={"ip": "2001:2345:1::a/64"}, 44 | params2={"ip": "2001:2345:1::1/64"}) 45 | self.addLink(re, self.addHost('h2'), 46 | params1={"ip": "2001:2345:2::e/64"}, 47 | params2={"ip": "2001:2345:2::2/64"}) 48 | super(SimpleTopo, self).build(*args, **kwargs) 49 | 50 | def addRouter_v6(self, name): 51 | return self.addRouter(name, use_v4=False, use_v6=True) 52 | 53 | ipmininet.DEBUG_FLAG = True 54 | lg.setLogLevel("info") 55 | 56 | # Start network 57 | net = IPNet(topo=SimpleTopo(), use_v4=False, allocate_IPs=False) 58 | net.start() 59 | IPCLI(net) 60 | net.stop() 61 | 62 | -------------------------------------------------------------------------------- /static/simple.py: -------------------------------------------------------------------------------- 1 | from mininet.log import lg 2 | 3 | import ipmininet 4 | from ipmininet.cli import IPCLI 5 | from ipmininet.ipnet import IPNet 6 | from ipmininet.iptopo import IPTopo 7 | from ipmininet.router.config.base import RouterConfig 8 | from ipmininet.router.config.zebra import StaticRoute, Zebra 9 | 10 | """ 11 | 12 | This file contains a simple topology with three routers and three hosts 13 | 14 | 15 | a ---- r1 ---- r2 ---- r3 ---- b 16 | + 17 | c 18 | 19 | """ 20 | 21 | 22 | class SimpleTopo(IPTopo): 23 | 24 | def build(self, *args, **kwargs): 25 | """ 26 | """ 27 | r1_routes = [StaticRoute("::/0", "2001:89ab:12::2")] 28 | r3_routes = [StaticRoute("::/0", "2001:89ab:23::1")] 29 | r2_routes = [StaticRoute("2001:7ab:1::/64", "2001:89ab:12::1"), 30 | StaticRoute("2001:7ab:3::/64", "2001:89ab:23::2")] 31 | 32 | r1 = self.addRouter_v6('r1', r1_routes) 33 | r2 = self.addRouter_v6('r2', r2_routes) 34 | r3 = self.addRouter_v6('r3', r3_routes) 35 | 36 | self.addLink(r1, r2, params1={"ip": "2001:89ab:12::1/64"}, 37 | params2={"ip": "2001:89ab:12::2/64"}) 38 | self.addLink(r2, r3, params1={"ip": "2001:89ab:23::1/64"}, 39 | params2={"ip": "2001:89ab:23::2/64"}) 40 | self.addLink(r1, self.addHost('a'), 41 | params1={"ip": "2001:7ab:1::1/64"}, 42 | params2={"ip": "2001:7ab:1::a/64"}) 43 | self.addLink(r2, self.addHost('b'), 44 | params1={"ip": "2001:7ab:2::1/64"}, 45 | params2={"ip": "2001:7ab:2::b/64"}) 46 | self.addLink(r3, self.addHost('c'), 47 | params1={"ip": "2001:7ab:3::1/64"}, 48 | params2={"ip": "2001:7ab:3::c/64"}) 49 | super(SimpleTopo, self).build(*args, **kwargs) 50 | 51 | def addRouter_v6(self, name, staticRoutes): 52 | return self.addRouter(name, use_v4=False, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 53 | 54 | ipmininet.DEBUG_FLAG = True 55 | lg.setLogLevel("info") 56 | 57 | # Start network 58 | net = IPNet(topo=SimpleTopo(), use_v4=False, allocate_IPs=False) 59 | 60 | try: 61 | net.start() 62 | IPCLI(net) 63 | finally: 64 | net.stop() 65 | 66 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # All Vagrant configuration is done below. The "2" in Vagrant.configure 5 | # configures the configuration version (we support older styles for 6 | # backwards compatibility). Please don't change it unless you know what 7 | # you're doing. 8 | Vagrant.configure("2") do |config| 9 | # The most common configuration options are documented and commented below. 10 | # For a complete reference, please see the online documentation at 11 | # https://docs.vagrantup.com. 12 | 13 | # Every Vagrant development environment requires a box. You can search for 14 | # boxes at https://atlas.hashicorp.com/search. 15 | config.vm.box = "ubuntu/xenial32" 16 | config.vm.provision "shell", inline: <<-SHELL 17 | if ! which puppet; then 18 | apt-get update 19 | apt-get install -y puppet-common 20 | fi 21 | # the xenial VM uses /home/ubuntu instead of the classical /home/vagrant 22 | cd /home ; ln -s ubuntu vagrant 23 | SHELL 24 | 25 | config.vm.provision "puppet" do |puppet| 26 | puppet.options = "--verbose --debug --parser future" 27 | end 28 | 29 | config.ssh.forward_x11 = true 30 | # config.ssh.password = "vagrant" 31 | 32 | # Disable automatic box update checking. If you disable this, then 33 | # boxes will only be checked for updates when the user runs 34 | # `vagrant box outdated`. This is not recommended. 35 | # config.vm.box_check_update = false 36 | 37 | # Create a forwarded port mapping which allows access to a specific port 38 | # within the machine from a port on the host machine. In the example below, 39 | # accessing "localhost:8080" will access port 80 on the guest machine. 40 | # config.vm.network "forwarded_port", guest: 80, host: 8080 41 | 42 | # Create a private network, which allows host-only access to the machine 43 | # using a specific IP. 44 | # config.vm.network "private_network", ip: "192.168.33.10" 45 | 46 | # Create a public network, which generally matched to bridged network. 47 | # Bridged networks make the machine appear as another physical device on 48 | # your network. 49 | # config.vm.network "public_network" 50 | 51 | # Provider-specific configuration so you can fine-tune various 52 | # backing providers for Vagrant. These expose provider-specific options. 53 | # Example for VirtualBox: 54 | # 55 | config.vm.provider "virtualbox" do |v| 56 | # Display the VirtualBox GUI when booting the machine 57 | #vb.gui = true 58 | 59 | # Customize the amount of memory on the VM and the number of CPUs: 60 | v.memory = "4096" 61 | v.cpus = 2 62 | end 63 | # 64 | # View the documentation for the provider you are using for more 65 | # information on available options. 66 | end 67 | -------------------------------------------------------------------------------- /static/static-example2.py: -------------------------------------------------------------------------------- 1 | from mininet.log import lg 2 | 3 | import ipmininet 4 | from ipmininet.cli import IPCLI 5 | from ipmininet.ipnet import IPNet 6 | from ipmininet.iptopo import IPTopo 7 | from ipmininet.router.config.base import RouterConfig 8 | from ipmininet.router.config.zebra import StaticRoute, Zebra 9 | 10 | """This file contains a simple network topology""" 11 | 12 | 13 | class SimpleTopo(IPTopo): 14 | 15 | def build(self, *args, **kwargs): 16 | """ 17 | """ 18 | 19 | #Routes 20 | ra_routes = [ StaticRoute("::/0", "2001:2345:4::c") ] 21 | 22 | rb_routes = [ StaticRoute("::/0", "2001:2345:5::c") ] 23 | 24 | re_routes = [ StaticRoute("::/0", "2001:2345:3::c") ] 25 | 26 | rc_routes = [ StaticRoute("2001:2345:1::/48", "2001:2345:4::a"), 27 | StaticRoute("2001:2345:7::/48", "2001:2345:5::b"), 28 | StaticRoute("2001:2345:6::/48", "2001:2345:5::b"), 29 | StaticRoute("2001:2345:2::/48", "2001:2345:3::e") 30 | ] 31 | 32 | #Routers 33 | ra = self.addRouter_v6('ra', ra_routes) 34 | rb = self.addRouter_v6('rb', rb_routes) 35 | rc = self.addRouter_v6('rc', rc_routes) 36 | re = self.addRouter_v6('re', re_routes) 37 | 38 | #Links 39 | self.addLink(ra, rb, params1={"ip": "2001:2345:7::a/64"}, 40 | params2={"ip": "2001:2345:7::b/64"}) 41 | self.addLink(ra, rc, params1={"ip": "2001:2345:4::a/64"}, 42 | params2={"ip": "2001:2345:4::c/64"}) 43 | self.addLink(rb, rc, params1={"ip": "2001:2345:5::b/64"}, 44 | params2={"ip": "2001:2345:5::c/64"}) 45 | self.addLink(rb, re, params1={"ip": "2001:2345:6::b/64"}, 46 | params2={"ip": "2001:2345:6::e/64"}) 47 | self.addLink(rc, re, params1={"ip": "2001:2345:3::c/64"}, 48 | params2={"ip": "2001:2345:3::e/64"}) 49 | 50 | self.addLink(ra, self.addHost('h1'), 51 | params1={"ip": "2001:2345:1::a/64"}, 52 | params2={"ip": "2001:2345:1::1/64"}) 53 | self.addLink(re, self.addHost('h2'), 54 | params1={"ip": "2001:2345:2::e/64"}, 55 | params2={"ip": "2001:2345:2::2/64"}) 56 | super(SimpleTopo, self).build(*args, **kwargs) 57 | 58 | def addRouter_v6(self, name, staticRoutes): 59 | return self.addRouter(name, use_v4=False, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 60 | 61 | ipmininet.DEBUG_FLAG = True 62 | lg.setLogLevel("info") 63 | 64 | # Start network 65 | net = IPNet(topo=SimpleTopo(), use_v4=False, allocate_IPs=False) 66 | net.start() 67 | IPCLI(net) 68 | net.stop() 69 | 70 | -------------------------------------------------------------------------------- /static/static-default.py: -------------------------------------------------------------------------------- 1 | from mininet.log import lg 2 | 3 | import ipmininet 4 | from ipmininet.cli import IPCLI 5 | from ipmininet.ipnet import IPNet 6 | from ipmininet.iptopo import IPTopo 7 | from ipmininet.router.config.base import RouterConfig 8 | from ipmininet.router.config.zebra import StaticRoute, Zebra 9 | 10 | """This file contains a simple network topology""" 11 | 12 | 13 | class SimpleTopo(IPTopo): 14 | 15 | def build(self, *args, **kwargs): 16 | """ 17 | the network 18 | 19 | h1 -- ra ---- rb ---- re -- h2 20 | | | | 21 | + ----- rc ---- + 22 | 23 | """ 24 | 25 | #Routes 26 | ra_routes = [ StaticRoute("::/0", "2001:2345:4::c") 27 | ] 28 | 29 | rb_routes = [ StaticRoute("2001:2345:0::/44", "2001:2345:7::a") 30 | ] 31 | 32 | rc_routes = [ StaticRoute("2001:2345:0::/46", "2001:2345:3::e") 33 | ] 34 | 35 | re_routes = [ StaticRoute("2001:2345:0::/40", "2001:2345:3::c") 36 | ] 37 | 38 | 39 | #Routers 40 | ra = self.addRouter_v6('ra', ra_routes) 41 | rb = self.addRouter_v6('rb', rb_routes) 42 | rc = self.addRouter_v6('rc', rc_routes) 43 | re = self.addRouter_v6('re', re_routes) 44 | 45 | #Links 46 | self.addLink(ra, rb, params1={"ip": "2001:2345:7::a/64"}, 47 | params2={"ip": "2001:2345:7::b/64"}) 48 | self.addLink(ra, rc, params1={"ip": "2001:2345:4::a/64"}, 49 | params2={"ip": "2001:2345:4::c/64"}) 50 | self.addLink(rb, rc, params1={"ip": "2001:2345:5::b/64"}, 51 | params2={"ip": "2001:2345:5::c/64"}) 52 | self.addLink(rb, re, params1={"ip": "2001:2345:6::b/64"}, 53 | params2={"ip": "2001:2345:6::e/64"}) 54 | self.addLink(rc, re, params1={"ip": "2001:2345:3::c/64"}, 55 | params2={"ip": "2001:2345:3::e/64"}) 56 | 57 | self.addLink(ra, self.addHost('h1'), 58 | params1={"ip": "2001:2345:1::a/64"}, 59 | params2={"ip": "2001:2345:1::1/64"}) 60 | self.addLink(re, self.addHost('h2'), 61 | params1={"ip": "2001:2345:2::e/64"}, 62 | params2={"ip": "2001:2345:2::2/64"}) 63 | super(SimpleTopo, self).build(*args, **kwargs) 64 | 65 | def addRouter_v6(self, name, staticRoutes): 66 | return self.addRouter(name, use_v4=False, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 67 | 68 | ipmininet.DEBUG_FLAG = True 69 | lg.setLogLevel("info") 70 | 71 | # Start network 72 | net = IPNet(topo=SimpleTopo(), use_v4=False, allocate_IPs=False) 73 | net.start() 74 | IPCLI(net) 75 | net.stop() 76 | 77 | -------------------------------------------------------------------------------- /static/static-err3.py: -------------------------------------------------------------------------------- 1 | from mininet.log import lg 2 | 3 | import ipmininet 4 | from ipmininet.cli import IPCLI 5 | from ipmininet.ipnet import IPNet 6 | from ipmininet.iptopo import IPTopo 7 | from ipmininet.router.config.base import RouterConfig 8 | from ipmininet.router.config.zebra import StaticRoute, Zebra 9 | 10 | """This file contains a simple network topology""" 11 | 12 | 13 | class SimpleTopo(IPTopo): 14 | 15 | def build(self, *args, **kwargs): 16 | """ 17 | the network 18 | 19 | h1 -- ra ---- rb ---- re -- h2 20 | | | | 21 | + ----- rc ---- + 22 | 23 | """ 24 | 25 | #Routes 26 | ra_routes = [ StaticRoute("::/0", "2001:2345:4::c"), 27 | StaticRoute("2001:2345:2::/47", "2001:2345:7::b") 28 | ] 29 | 30 | rb_routes = [ StaticRoute("2001:2345:0::/47", "2001:2345:7::a"), 31 | StaticRoute("2001:2345:0::/46", "2001:2345:6::e") 32 | ] 33 | 34 | rc_routes = [ StaticRoute("2001:2345:0::/46", "2001:2345:7::a"), 35 | StaticRoute("2001:2345:2::/47", "2001:2345:3::e") 36 | ] 37 | 38 | re_routes = [ StaticRoute("2001:2345:0::/40", "2001:2345:3::c") 39 | ] 40 | 41 | 42 | #Routers 43 | ra = self.addRouter_v6('ra', ra_routes) 44 | rb = self.addRouter_v6('rb', rb_routes) 45 | rc = self.addRouter_v6('rc', rc_routes) 46 | re = self.addRouter_v6('re', re_routes) 47 | 48 | #Links 49 | self.addLink(ra, rb, params1={"ip": "2001:2345:7::a/64"}, 50 | params2={"ip": "2001:2345:7::b/64"}) 51 | self.addLink(ra, rc, params1={"ip": "2001:2345:4::a/64"}, 52 | params2={"ip": "2001:2345:4::c/64"}) 53 | self.addLink(rb, rc, params1={"ip": "2001:2345:5::b/64"}, 54 | params2={"ip": "2001:2345:5::c/64"}) 55 | self.addLink(rb, re, params1={"ip": "2001:2345:6::b/64"}, 56 | params2={"ip": "2001:2345:6::e/64"}) 57 | self.addLink(rc, re, params1={"ip": "2001:2345:3::c/64"}, 58 | params2={"ip": "2001:2345:3::e/64"}) 59 | 60 | self.addLink(ra, self.addHost('h1'), 61 | params1={"ip": "2001:2345:1::a/64"}, 62 | params2={"ip": "2001:2345:1::1/64"}) 63 | self.addLink(re, self.addHost('h2'), 64 | params1={"ip": "2001:2345:2::e/64"}, 65 | params2={"ip": "2001:2345:2::2/64"}) 66 | super(SimpleTopo, self).build(*args, **kwargs) 67 | 68 | def addRouter_v6(self, name, staticRoutes): 69 | return self.addRouter(name, use_v4=False, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 70 | 71 | ipmininet.DEBUG_FLAG = True 72 | lg.setLogLevel("info") 73 | 74 | # Start network 75 | net = IPNet(topo=SimpleTopo(), use_v4=False, allocate_IPs=False) 76 | net.start() 77 | IPCLI(net) 78 | net.stop() 79 | 80 | -------------------------------------------------------------------------------- /static/static-err.py: -------------------------------------------------------------------------------- 1 | from mininet.log import lg 2 | 3 | import ipmininet 4 | from ipmininet.cli import IPCLI 5 | from ipmininet.ipnet import IPNet 6 | from ipmininet.iptopo import IPTopo 7 | from ipmininet.router.config.base import RouterConfig 8 | from ipmininet.router.config.zebra import StaticRoute, Zebra 9 | 10 | """This file contains a simple network topology""" 11 | 12 | 13 | class SimpleTopo(IPTopo): 14 | 15 | def build(self, *args, **kwargs): 16 | """ 17 | """ 18 | 19 | #Routes 20 | ra_routes = [ StaticRoute("2001:2345:4::/46", "2001:2345:4::c"), 21 | StaticRoute("2001:2345:2::/47", "2001:2345:7::b") 22 | ] 23 | 24 | rb_routes = [ StaticRoute("2001:2345:0::/44", "2001:2345:7::a"), 25 | StaticRoute("2001:2345:4::/46", "2001:2345:5::c"), 26 | StaticRoute("2001:2345:3::/48", "2001:2345:5::c"), 27 | StaticRoute("2001:2345:2::/47", "2001:2345:6::e") 28 | ] 29 | 30 | rc_routes = [ StaticRoute("2001:2345:0::/47", "2001:2345:4::a"), 31 | StaticRoute("2001:2345:6::/47", "2001:2345:5::b"), 32 | StaticRoute("2001:2345:2::/47", "2001:2345:3::e") 33 | ] 34 | 35 | re_routes = [ StaticRoute("2001:2345:0::/40", "2001:2345:6::b"), 36 | StaticRoute("2001:2345:5::/48", "2001:2345:3::c") 37 | ] 38 | 39 | 40 | #Routers 41 | ra = self.addRouter_v6('ra', ra_routes) 42 | rb = self.addRouter_v6('rb', rb_routes) 43 | rc = self.addRouter_v6('rc', rc_routes) 44 | re = self.addRouter_v6('re', re_routes) 45 | 46 | #Links 47 | self.addLink(ra, rb, params1={"ip": "2001:2345:7::a/64"}, 48 | params2={"ip": "2001:2345:7::b/64"}) 49 | self.addLink(ra, rc, params1={"ip": "2001:2345:4::a/64"}, 50 | params2={"ip": "2001:2345:4::c/64"}) 51 | self.addLink(rb, rc, params1={"ip": "2001:2345:5::b/64"}, 52 | params2={"ip": "2001:2345:5::c/64"}) 53 | self.addLink(rb, re, params1={"ip": "2001:2345:6::b/64"}, 54 | params2={"ip": "2001:2345:6::e/64"}) 55 | self.addLink(rc, re, params1={"ip": "2001:2345:3::c/64"}, 56 | params2={"ip": "2001:2345:3::e/64"}) 57 | 58 | self.addLink(ra, self.addHost('h1'), 59 | params1={"ip": "2001:2345:1::a/64"}, 60 | params2={"ip": "2001:2345:1::1/64"}) 61 | self.addLink(re, self.addHost('h2'), 62 | params1={"ip": "2001:2345:2::e/64"}, 63 | params2={"ip": "2001:2345:2::2/64"}) 64 | super(SimpleTopo, self).build(*args, **kwargs) 65 | 66 | def addRouter_v6(self, name, staticRoutes): 67 | return self.addRouter(name, use_v4=False, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 68 | 69 | ipmininet.DEBUG_FLAG = True 70 | lg.setLogLevel("info") 71 | 72 | # Start network 73 | net = IPNet(topo=SimpleTopo(), use_v4=False, allocate_IPs=False) 74 | net.start() 75 | IPCLI(net) 76 | net.stop() 77 | 78 | -------------------------------------------------------------------------------- /static/static-err2.py: -------------------------------------------------------------------------------- 1 | from mininet.log import lg 2 | 3 | import ipmininet 4 | from ipmininet.cli import IPCLI 5 | from ipmininet.ipnet import IPNet 6 | from ipmininet.iptopo import IPTopo 7 | from ipmininet.router.config.base import RouterConfig 8 | from ipmininet.router.config.zebra import StaticRoute, Zebra 9 | 10 | """This file contains a simple network topology""" 11 | 12 | 13 | class SimpleTopo(IPTopo): 14 | 15 | def build(self, *args, **kwargs): 16 | """ 17 | the network 18 | 19 | h1 -- ra ---- rb ---- re -- h2 20 | | | | 21 | + ----- rc ---- + 22 | 23 | """ 24 | 25 | #Routes 26 | ra_routes = [ StaticRoute("2001:2345:4::/46", "2001:2345:4::c"), 27 | StaticRoute("2001:2345:2::/47", "2001:2345:7::b") 28 | ] 29 | 30 | rb_routes = [ StaticRoute("2001:2345:0::/44", "2001:2345:7::a"), 31 | StaticRoute("2001:2345:4::/46", "2001:2345:5::c"), 32 | StaticRoute("2001:2345:3::/48", "2001:2345:5::c"), 33 | StaticRoute("2001:2345:2::/47", "2001:2345:5::c") 34 | ] 35 | 36 | rc_routes = [ StaticRoute("2001:2345:0::/46", "2001:2345:4::b"), 37 | StaticRoute("2001:2345:6::/47", "2001:2345:5::b") 38 | ] 39 | 40 | re_routes = [ StaticRoute("2001:2345:0::/40", "2001:2345:6::c"), 41 | StaticRoute("2001:2345:5::/48", "2001:2345:6::b") 42 | ] 43 | 44 | 45 | #Routers 46 | ra = self.addRouter_v6('ra', ra_routes) 47 | rb = self.addRouter_v6('rb', rb_routes) 48 | rc = self.addRouter_v6('rc', rc_routes) 49 | re = self.addRouter_v6('re', re_routes) 50 | 51 | #Links 52 | self.addLink(ra, rb, params1={"ip": "2001:2345:7::a/64"}, 53 | params2={"ip": "2001:2345:7::b/64"}) 54 | self.addLink(ra, rc, params1={"ip": "2001:2345:4::a/64"}, 55 | params2={"ip": "2001:2345:4::c/64"}) 56 | self.addLink(rb, rc, params1={"ip": "2001:2345:5::b/64"}, 57 | params2={"ip": "2001:2345:5::c/64"}) 58 | self.addLink(rb, re, params1={"ip": "2001:2345:6::b/64"}, 59 | params2={"ip": "2001:2345:6::e/64"}) 60 | self.addLink(rc, re, params1={"ip": "2001:2345:3::c/64"}, 61 | params2={"ip": "2001:2345:3::e/64"}) 62 | 63 | self.addLink(ra, self.addHost('h1'), 64 | params1={"ip": "2001:2345:1::a/64"}, 65 | params2={"ip": "2001:2345:1::1/64"}) 66 | self.addLink(re, self.addHost('h2'), 67 | params1={"ip": "2001:2345:2::e/64"}, 68 | params2={"ip": "2001:2345:2::2/64"}) 69 | super(SimpleTopo, self).build(*args, **kwargs) 70 | 71 | def addRouter_v6(self, name, staticRoutes): 72 | return self.addRouter(name, use_v4=False, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 73 | 74 | ipmininet.DEBUG_FLAG = True 75 | lg.setLogLevel("info") 76 | 77 | # Start network 78 | net = IPNet(topo=SimpleTopo(), use_v4=False, allocate_IPs=False) 79 | net.start() 80 | IPCLI(net) 81 | net.stop() 82 | 83 | -------------------------------------------------------------------------------- /static/static-example1.py: -------------------------------------------------------------------------------- 1 | from mininet.log import lg 2 | 3 | import ipmininet 4 | from ipmininet.cli import IPCLI 5 | from ipmininet.ipnet import IPNet 6 | from ipmininet.iptopo import IPTopo 7 | from ipmininet.router.config.base import RouterConfig 8 | from ipmininet.router.config.zebra import StaticRoute, Zebra 9 | 10 | """This file contains a simple network topology""" 11 | 12 | 13 | class SimpleTopo(IPTopo): 14 | 15 | def build(self, *args, **kwargs): 16 | """ 17 | """ 18 | 19 | #Routes 20 | ra_routes = [ StaticRoute("2001:2345:5::/48", "2001:2345:4::c"), 21 | StaticRoute("2001:2345:6::/48", "2001:2345:4::c"), 22 | StaticRoute("2001:2345:3::/48", "2001:2345:4::c"), 23 | StaticRoute("2001:2345:2::/48", "2001:2345:7::b") 24 | ] 25 | 26 | rb_routes = [ StaticRoute("2001:2345:1::/48", "2001:2345:7::a"), 27 | StaticRoute("2001:2345:4::/48", "2001:2345:5::c"), 28 | StaticRoute("2001:2345:3::/48", "2001:2345:5::c"), 29 | StaticRoute("2001:2345:2::/48", "2001:2345:6::e") 30 | ] 31 | 32 | rc_routes = [ StaticRoute("2001:2345:1::/48", "2001:2345:4::a"), 33 | StaticRoute("2001:2345:7::/48", "2001:2345:5::b"), 34 | StaticRoute("2001:2345:6::/48", "2001:2345:5::b"), 35 | StaticRoute("2001:2345:2::/48", "2001:2345:3::e") 36 | ] 37 | 38 | re_routes = [ StaticRoute("2001:2345:1::/48", "2001:2345:6::b"), 39 | StaticRoute("2001:2345:7::/48", "2001:2345:3::c"), 40 | StaticRoute("2001:2345:4::/48", "2001:2345:3::c"), 41 | StaticRoute("2001:2345:5::/48", "2001:2345:3::c") 42 | ] 43 | 44 | 45 | #Routers 46 | ra = self.addRouter_v6('ra', ra_routes) 47 | rb = self.addRouter_v6('rb', rb_routes) 48 | rc = self.addRouter_v6('rc', rc_routes) 49 | re = self.addRouter_v6('re', re_routes) 50 | 51 | #Links 52 | self.addLink(ra, rb, params1={"ip": "2001:2345:7::a/64"}, 53 | params2={"ip": "2001:2345:7::b/64"}) 54 | self.addLink(ra, rc, params1={"ip": "2001:2345:4::a/64"}, 55 | params2={"ip": "2001:2345:4::c/64"}) 56 | self.addLink(rb, rc, params1={"ip": "2001:2345:5::b/64"}, 57 | params2={"ip": "2001:2345:5::c/64"}) 58 | self.addLink(rb, re, params1={"ip": "2001:2345:6::b/64"}, 59 | params2={"ip": "2001:2345:6::e/64"}) 60 | self.addLink(rc, re, params1={"ip": "2001:2345:3::c/64"}, 61 | params2={"ip": "2001:2345:3::e/64"}) 62 | 63 | self.addLink(ra, self.addHost('h1'), 64 | params1={"ip": "2001:2345:1::a/64"}, 65 | params2={"ip": "2001:2345:1::1/64"}) 66 | self.addLink(re, self.addHost('h2'), 67 | params1={"ip": "2001:2345:2::e/64"}, 68 | params2={"ip": "2001:2345:2::2/64"}) 69 | super(SimpleTopo, self).build(*args, **kwargs) 70 | 71 | def addRouter_v6(self, name, staticRoutes): 72 | return self.addRouter(name, use_v4=False, use_v6=True, config=(RouterConfig, {'daemons': [(Zebra, {"static_routes": staticRoutes})]})) 73 | 74 | ipmininet.DEBUG_FLAG = True 75 | lg.setLogLevel("info") 76 | 77 | # Start network 78 | net = IPNet(topo=SimpleTopo(), use_v4=False, allocate_IPs=False) 79 | net.start() 80 | IPCLI(net) 81 | net.stop() 82 | 83 | -------------------------------------------------------------------------------- /bgp/simple-bgp.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import json 3 | import os 4 | from mininet.log import LEVELS, lg 5 | 6 | import ipmininet 7 | from ipmininet.cli import IPCLI 8 | from ipmininet.ipnet import IPNet 9 | from ipmininet.router.config.zebra import StaticRoute, Zebra 10 | from ipmininet.iptopo import IPTopo 11 | 12 | from ipmininet.router.config import RouterConfig, BGP, iBGPFullMesh, AS, bgp_peering 13 | import ipmininet.router.config.bgp as _bgp 14 | 15 | 16 | """This file contains a simple network using BGP""" 17 | 18 | class BGPConfig(RouterConfig): 19 | """A simple config with only a BGP daemon""" 20 | def __init__(self, node, *args, **kwargs): 21 | super(BGPConfig, self).__init__(node, 22 | daemons=((BGP, defaults),), 23 | *args, **kwargs) 24 | 25 | 26 | class SimpleBGP(IPTopo): 27 | 28 | def build(self, *args, **kwargs): 29 | """ 30 | h2 31 | || 32 | h1 = ra ----- rb ----- rd = h4 33 | | | 34 | +------ rc = h3 35 | """ 36 | 37 | # BGP routers 38 | 39 | as1ra = self.bgp('as1ra',['2001:1234:1::/64']) 40 | as2rb = self.bgp('as2rb',['2001:1234:2::/64']) 41 | as3rc = self.bgp('as3rc',['2001:1234:3::/64']) 42 | as4rd = self.bgp('as4rd',['2001:1234:4::/64']) 43 | 44 | # Set AS-ownerships 45 | 46 | self.addOverlay(AS(1, (as1ra,))) 47 | self.addOverlay(AS(2, (as2rb,))) 48 | self.addOverlay(AS(3, (as3rc,))) 49 | self.addOverlay(AS(4, (as4rd,))) 50 | 51 | # Inter-AS links 52 | 53 | self.addLink(as1ra, as2rb, 54 | params1={"ip": "2001:12::a/64"}, 55 | params2={"ip": "2001:12::b/64"}) 56 | self.addLink(as1ra, as3rc, 57 | params1={"ip": "2001:13::a/64"}, 58 | params2={"ip": "2001:13::c/64"}) 59 | self.addLink(as2rb, as3rc, 60 | params1={"ip": "2001:23::b/64"}, 61 | params2={"ip": "2001:23::c/64"}) 62 | self.addLink(as2rb, as4rd, 63 | params1={"ip": "2001:24::c/64"}, 64 | params2={"ip": "2001:24::d/64"}) 65 | 66 | # Add eBGP peering 67 | bgp_peering(self, as1ra, as2rb) 68 | bgp_peering(self, as1ra, as3rc) 69 | bgp_peering(self, as2rb, as3rc) 70 | bgp_peering(self, as2rb, as4rd) 71 | 72 | 73 | # hosts attached to the routers 74 | 75 | self.addLink(as1ra, self.addHost('h1'), 76 | params1={"ip": "2001:1234:1::a/64"}, 77 | params2={"ip": "2001:1234:1::1/64"}) 78 | self.addLink(as2rb, self.addHost('h2'), 79 | params1={"ip": "2001:1234:2::b/64"}, 80 | params2={"ip": "2001:1234:2::2/64"}) 81 | self.addLink(as3rc, self.addHost('h3'), 82 | params1={"ip": "2001:1234:3::c/64"}, 83 | params2={"ip": "2001:1234:3::1/64"}) 84 | self.addLink(as4rd, self.addHost('h4'), 85 | params1={"ip": "2001:1234:4::d/64"}, 86 | params2={"ip": "2001:1234:4::4/64"}) 87 | 88 | super(SimpleBGP, self).build(*args, **kwargs) 89 | 90 | def bgp(self, name, net=None): 91 | if net is None: 92 | net=[] 93 | return self.addRouter(name, use_v4=True, 94 | use_v6=True, 95 | config=(RouterConfig, 96 | { 'daemons': [(BGP, 97 | { 'address_families': ( _bgp.AF_INET6(networks=net),)} 98 | # { 'address_families': ( _bgp.AF_INET6(networks=net,redistribute=('connected',)),)} 99 | )] 100 | } 101 | ) 102 | ) 103 | 104 | 105 | ipmininet.DEBUG_FLAG = True 106 | 107 | os.environ["PATH"] += os.pathsep + "/home/vagrant/quagga/bin" + os.pathsep + "/home/vagrant/quagga/sbin" 108 | 109 | # Start network 110 | net = IPNet(topo=SimpleBGP(), use_v4=False, use_v6=True, allocate_IPs=False) 111 | net.start() 112 | IPCLI(net) 113 | net.stop() 114 | 115 | -------------------------------------------------------------------------------- /manifests/default.pp: -------------------------------------------------------------------------------- 1 | # Mathieu Jadin, manifest to create Ubuntu VM with ipminet and routing daemons 2 | $quagga_version = "1.2.2" 3 | $quagga_release_url = "http://download.savannah.gnu.org/releases/quagga/quagga-${quagga_version}.tar.gz" 4 | $quagga_root_dir = "/home/ubuntu" 5 | $quagga_source_path = "${quagga_root_dir}/quagga-${quagga_version}" 6 | $quagga_download_path = "${quagga_source_path}.tar.gz" 7 | $quagga_path = "/home/ubuntu/quagga" 8 | 9 | # Remove useless warnings 10 | Package { allow_virtual => true } 11 | 12 | # PATH 13 | $default_path = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" 14 | Exec { path => $default_path } 15 | 16 | exec { 'apt-update': 17 | command => 'apt-get update', 18 | } 19 | 20 | 21 | # Python packages 22 | package { 'python-setuptools': 23 | require => Exec['apt-update'], 24 | ensure => installed, 25 | } 26 | package { 'python-pip': 27 | require => [ Exec['apt-update'], Package['python-setuptools'] ], 28 | ensure => installed, 29 | } 30 | package { 'py2-ipaddress': 31 | require => Package['python-pip'], 32 | ensure => installed, 33 | provider => 'pip', 34 | } 35 | package { 'mako': 36 | require => Package['python-pip'], 37 | ensure => installed, 38 | provider => 'pip', 39 | } 40 | package { 'six': 41 | require => Package['python-pip'], 42 | ensure => installed, 43 | provider => 'pip', 44 | } 45 | 46 | # Networking 47 | package { 'wireshark': 48 | require => Exec['apt-update'], 49 | ensure => installed, 50 | } 51 | package {'tshark': 52 | require => Exec['apt-update'], 53 | ensure => installed, 54 | } 55 | 56 | package { 'radvd': 57 | require => Exec['apt-update'], 58 | ensure => installed, 59 | } 60 | package { 'traceroute': 61 | require => Exec['apt-update'], 62 | ensure => installed, 63 | } 64 | package { 'tcpdump': 65 | require => Exec['apt-update'], 66 | ensure => installed, 67 | } 68 | package { 'bridge-utils': 69 | require => Exec['apt-update'], 70 | ensure => installed, 71 | } 72 | package { 'mininet': 73 | require => Exec['apt-update'], 74 | ensure => installed, 75 | } 76 | package { 'ipmininet': 77 | provider => "pip", 78 | require => [Package['mininet'],Package['mako'], Package['py2-ipaddress']], 79 | ensure => installed, 80 | } 81 | 82 | # Compilation 83 | package { 'libreadline6': 84 | require => Exec['apt-update'], 85 | ensure => installed, 86 | } 87 | package { 'libreadline6-dev': 88 | require => [ Exec['apt-update'], Package['libreadline6'] ], 89 | ensure => installed, 90 | } 91 | package { 'gawk': 92 | require => Exec['apt-update'], 93 | ensure => installed, 94 | } 95 | package { 'automake': 96 | require => Exec['apt-update'], 97 | ensure => installed, 98 | } 99 | package { 'libtool': 100 | require => [ Exec['apt-update'], Package['m4'], Package['automake'] ], 101 | ensure => installed, 102 | } 103 | package { 'm4': 104 | require => Exec['apt-update'], 105 | ensure => installed, 106 | } 107 | package { 'bison': 108 | require => Exec['apt-update'], 109 | ensure => installed, 110 | } 111 | package { 'flex': 112 | require => Exec['apt-update'], 113 | ensure => installed, 114 | } 115 | package { 'pkg-config': 116 | require => Exec['apt-update'], 117 | ensure => installed, 118 | } 119 | package { 'dia': 120 | require => Exec['apt-update'], 121 | ensure => installed, 122 | } 123 | package { 'texinfo': 124 | require => Exec['apt-update'], 125 | ensure => installed, 126 | } 127 | package { 'libc-ares-dev': 128 | require => Exec['apt-update'], 129 | ensure => installed, 130 | } 131 | package { 'cmake': 132 | require => Exec['apt-update'], 133 | ensure => installed, 134 | } 135 | 136 | # Miscellaneous 137 | package { 'xterm': 138 | require => Exec['apt-update'], 139 | ensure => installed, 140 | } 141 | package { 'man': 142 | require => Exec['apt-update'], 143 | ensure => installed, 144 | } 145 | package { 'git': 146 | require => Exec['apt-update'], 147 | ensure => installed, 148 | } 149 | package { 'valgrind': 150 | require => Exec['apt-update'], 151 | ensure => installed, 152 | } 153 | 154 | # Locale settings 155 | exec { 'locales': 156 | require => Exec['apt-update'], 157 | command => "locale-gen fr_BE.UTF-8; update-locale", 158 | } 159 | 160 | # Main softwares 161 | 162 | $compilation = [Exec['locales'], Package['libreadline6-dev'], Package['gawk'], Package['libtool'], Package['libc-ares-dev'], 163 | Package['bison'], Package['flex'], Package['pkg-config'], Package['dia'], Package['texinfo']] 164 | 165 | 166 | exec { 'quagga-download': 167 | require => [ Exec['apt-update'] ], 168 | creates => $quagga_source_path, 169 | command => "wget -O - ${quagga_release_url} > ${quagga_download_path} &&\ 170 | tar -xvzf ${quagga_download_path} -C ${quagga_root_dir};" 171 | } 172 | 173 | exec { 'quagga': 174 | require => [ Exec['apt-update'], Exec['quagga-download'] ] + $compilation, 175 | cwd => $quagga_source_path, 176 | creates => $quagga_path, 177 | path => "${default_path}:${quagga_source_path}", 178 | command => "git apply /vagrant/patch_bgpd_quagga.patch &&\ 179 | configure --prefix=${quagga_path} &&\ 180 | make &&\ 181 | make install &&\ 182 | rm ${quagga_download_path} &&\ 183 | echo \"# quagga binaries\" >> /etc/profile &&\ 184 | echo \"PATH=\\\"${quagga_path}/bin:${quagga_path}/sbin:\\\$PATH\\\"\" >> /etc/profile &&\ 185 | echo \"alias sudo=\'sudo env \\\"PATH=\\\$PATH\\\"\'\" >> /etc/profile &&\ 186 | echo \"# quagga binaries\" >> /root/.bashrc &&\ 187 | echo \"PATH=\\\"${quagga_path}/bin:${quagga_path}/sbin:\\\$PATH\\\"\" >> /root/.bashrc &&\ 188 | PATH=${quagga_path}/sbin:${quagga_path}/bin:\$PATH;", 189 | } 190 | 191 | # Quagga group 192 | 193 | group { 'quagga': 194 | ensure => 'present', 195 | } 196 | user { 'ubuntu': 197 | groups => 'quagga', 198 | } 199 | user { 'root': 200 | groups => 'quagga', 201 | } 202 | 203 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------