Daniele Moro | 50fa407 | 2019-11-07 23:42:16 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | # Copyright 2019-present Open Networking Foundation |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | from mininet.cli import CLI |
| 18 | from mininet.log import setLogLevel, info, error |
| 19 | from mininet.net import Mininet |
| 20 | from mininet.link import Intf |
| 21 | from mininet.nodelib import LinuxBridge |
| 22 | from stratum import StratumBmv2Switch |
| 23 | from mininet.util import quietRun |
| 24 | |
| 25 | CPU_PORT = 255 |
| 26 | |
| 27 | if __name__ == '__main__': |
| 28 | setLogLevel( 'info' ) |
| 29 | |
| 30 | net = Mininet( topo=None ) |
| 31 | |
| 32 | info( '*** Adding switches\n' ) |
| 33 | agg1 = net.addSwitch( name='agg1', cls=StratumBmv2Switch, cpuport=CPU_PORT) |
| 34 | # FIXME: enable multicast |
| 35 | # s2 = net.addSwitch( 's2', cls=LinuxBridge ) |
| 36 | |
| 37 | info( '*** Creating hosts\n' ) |
| 38 | h1 = net.addHost( 'h1' ) # PPPoE Server |
Daniele Moro | d4218c1 | 2020-01-22 10:09:13 -0800 | [diff] [blame] | 39 | h2 = net.addHost( 'h2', ip='10.10.10.1/24', mac="00:66:77:88:99:AA") # Upstream |
Daniele Moro | 50fa407 | 2019-11-07 23:42:16 -0800 | [diff] [blame] | 40 | # FIXME: enable multicast |
| 41 | # h3 = net.addHost( 'h3') |
| 42 | |
| 43 | # Topology: pon1 - eth1 - agg1 - h2 - s2 - h3 |
| 44 | # | |
| 45 | # h1 |
| 46 | net.addLink( h1, agg1 ) |
| 47 | net.addLink( h2, agg1 ) |
| 48 | # FIXME: enable multicast |
| 49 | # net.addLink( h2, s2 ) |
| 50 | # net.addLink( h3, s2 ) |
| 51 | |
| 52 | {{- range $i, $junk := until (.Values.numOlts|int) -}} |
| 53 | {{- $intf := printf "eth%d" (add $i 1) }} |
| 54 | |
| 55 | info( '*** Adding hardware interface {{ $intf }} to switch agg1\n') |
| 56 | _intf = Intf( '{{ $intf }}', node=agg1 ) |
| 57 | |
| 58 | info( '*** Turning off checksum offloading for {{ $intf }}\n' ) |
| 59 | print quietRun( 'ethtool -K {{ $intf }} tx off rx off' ) |
| 60 | {{- end }} |
| 61 | |
| 62 | |
| 63 | # FIXME: enable multicast |
| 64 | # {{- if .Values.enableMulticast }} |
| 65 | # info( '*** Start multicast routing on h1 and source on h2\n') |
| 66 | # h2.cmd( 'service pimd start' ) |
| 67 | # h3.cmd( 'mcjoin -s -i h2-eth0 -t 2 >& /tmp/mcjoin.log &') |
| 68 | # {{- end }} |
| 69 | |
| 70 | net.start() |
| 71 | info( '*** Starting PPPoE Server') |
| 72 | h1.cmd( 'echo 10.255.255.100-250 > /iptoassign') |
| 73 | h1.cmd( 'pppoe-server -I h1-eth0 -L 10.255.255.1 -p /iptoassign -O /pppoe-options') |
| 74 | info( '*** Setting route back to access network') |
| 75 | h2.cmd( 'ip route add 10.255.255.0/24 via 10.10.10.254') |
| 76 | CLI( net ) |
| 77 | net.stop() |