mirror of
https://github.com/Wojtek242/route0.git
synced 2024-11-24 15:55:26 +01:00
Add support for connecting to the FRR daemon shells
This commit is contained in:
parent
71bc827fb2
commit
5482b89128
34
README.md
34
README.md
@ -73,6 +73,22 @@ experiment with the following command.
|
||||
sudo python route-0.py --topology <topology_name> --scenario <scenario_name>
|
||||
```
|
||||
|
||||
### Connecting to an FRR daemon
|
||||
|
||||
To connect to an FRR daamon, you can either run the following command inside
|
||||
the Mininet CLI
|
||||
```
|
||||
<node_name> telnet localhost <daemon_name>
|
||||
```
|
||||
|
||||
You can also connect to an FRR daemon from a different terminal than the one in
|
||||
which the Mininet CLI is running. To do this run
|
||||
```
|
||||
sudo python attach.py --node <node_name> --daemon <daemon_name>
|
||||
```
|
||||
|
||||
The password for all daemons is `route0`.
|
||||
|
||||
### Lessons
|
||||
|
||||
TODO: WRITE UP LESSONS
|
||||
@ -106,6 +122,18 @@ in Mininet the destination can also be specified using its name. It is
|
||||
possible to do so in Route 0, but this is often ambiguous as routers will have
|
||||
multiple IP addresses associated with their interfaces.
|
||||
|
||||
It is also possible to launch a shell or run a command in a Mininet node from a
|
||||
different terminal than the one in which the Mininet CLI is being run. A
|
||||
convenience script has been provided for this purpose, `attach.py`. To launch
|
||||
a shell in a particular node run
|
||||
```
|
||||
sudo python attach.py --node <node_name>
|
||||
```
|
||||
You can also directly specify the daemon to connect to with `--daemon` or a
|
||||
shell command to run with `--cmd`.
|
||||
|
||||
The password for all daemons is `route0`.
|
||||
|
||||
## FRR Concepts
|
||||
|
||||
This section will introduce some basic FRR concepts that are in particular
|
||||
@ -121,10 +149,8 @@ routes as appropriate.
|
||||
FRR routing protocols are configured using configuration files. The details of
|
||||
how to write these configurations are on the [FRR documentation
|
||||
website](http://docs.frrouting.org/en/latest/). It is also possible to connect
|
||||
to running instances of the protocols. However, this is not currently
|
||||
supported in Route 0.
|
||||
|
||||
TODO: ADD SUPPORT TO CONNECT TO ROUTING PROTOCOL SHELL
|
||||
to running instances of the protocols. See the Mininet and Getting Started
|
||||
sections on how this can be done.
|
||||
|
||||
## Structure
|
||||
|
||||
|
52
attach.py
Normal file
52
attach.py
Normal file
@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import argparse
|
||||
import os
|
||||
from subprocess import Popen, PIPE
|
||||
import re
|
||||
|
||||
|
||||
def get_pid(node_name):
|
||||
"""Get the system process ID for the node.
|
||||
|
||||
"""
|
||||
node_pat = re.compile('.*bash .* mininet:{}'.format(node_name))
|
||||
|
||||
out, _ = Popen("ps aux".split(), stdout=PIPE).communicate()
|
||||
for line in out.split('\n'):
|
||||
match = node_pat.match(line)
|
||||
if not match:
|
||||
continue
|
||||
pid = line.split()[1]
|
||||
return pid
|
||||
|
||||
raise KeyError("No process found for {}".format(node_name))
|
||||
|
||||
|
||||
def main():
|
||||
"""Entry point for attach.
|
||||
|
||||
"""
|
||||
parser = argparse.ArgumentParser("Connect to a mininet node.")
|
||||
parser.add_argument('-n', '--node',
|
||||
required=True,
|
||||
help="The node's name (e.g., h1_1, R1, etc.)")
|
||||
parser.add_argument('-d', '--daemon',
|
||||
help="Connect directly to this FRR daemon.")
|
||||
parser.add_argument('-c', '--cmd',
|
||||
default=["sh"],
|
||||
nargs="+",
|
||||
help="Command to run on the node."
|
||||
" Default is to start sh.")
|
||||
args = parser.parse_args()
|
||||
|
||||
pid = get_pid(args.node)
|
||||
cmd = ' '.join(args.cmd)
|
||||
if args.daemon is not None:
|
||||
cmd = "telnet localhost {}".format(args.daemon)
|
||||
|
||||
os.system("mnexec -a {} {}".format(pid, cmd))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
@ -80,9 +80,9 @@ def main():
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Launch an FRR network experiment in Mininet.')
|
||||
parser.add_argument('--topology', '-t', type=str, required=True,
|
||||
parser.add_argument('-t', '--topology', required=True,
|
||||
help='the topology of the network')
|
||||
parser.add_argument('--scenario', '-s', type=str, required=True,
|
||||
parser.add_argument('-s', '--scenario', required=True,
|
||||
help='the scenario to set up in the network')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
! -*- staticd -*-
|
||||
|
||||
hostname h1_1
|
||||
hostname h1_1-staticd
|
||||
password route0
|
||||
enable password route0
|
||||
|
||||
ip route 0.0.0.0/0 10.1.0.254
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
! -*- staticd -*-
|
||||
|
||||
hostname h2_1
|
||||
hostname h2_1-staticd
|
||||
password route0
|
||||
enable password route0
|
||||
|
||||
ip route 0.0.0.0/0 10.2.0.254
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
! -*- zebra -*-
|
||||
|
||||
hostname R1
|
||||
hostname R1-zebra
|
||||
password route0
|
||||
enable password route0
|
||||
|
||||
interface lo
|
||||
ip address 10.0.0.1/32
|
||||
|
@ -1,6 +1,8 @@
|
||||
! -*- zebra -*-
|
||||
|
||||
hostname h1_1
|
||||
hostname h1_1-zebra
|
||||
password route0
|
||||
enable password route0
|
||||
|
||||
interface h1_1-eth1
|
||||
ip address 10.1.0.1/24
|
||||
|
@ -1,6 +1,8 @@
|
||||
! -*- zebra -*-
|
||||
|
||||
hostname h2_1
|
||||
hostname h2_1-zebra
|
||||
password route0
|
||||
enable password route0
|
||||
|
||||
interface h2_1-eth1
|
||||
ip address 10.2.0.1/24
|
||||
|
@ -1,9 +1,12 @@
|
||||
! -*- isisd -*-
|
||||
|
||||
hostname R1
|
||||
hostname R1-isisd
|
||||
password route0
|
||||
enable password route0
|
||||
|
||||
router isis ROUTE0
|
||||
net 49.0001.0000.0000.0001.00
|
||||
is-type level-2-only
|
||||
|
||||
interface lo
|
||||
ip router isis ROUTE0
|
||||
|
@ -1,9 +1,12 @@
|
||||
! -*- isisd -*-
|
||||
|
||||
hostname R2
|
||||
hostname R2-isisd
|
||||
password route0
|
||||
enable password route0
|
||||
|
||||
router isis ROUTE0
|
||||
net 49.0002.0000.0000.0002.00
|
||||
is-type level-2-only
|
||||
|
||||
interface lo
|
||||
ip router isis ROUTE0
|
||||
|
@ -1,6 +1,8 @@
|
||||
! -*- staticd -*-
|
||||
|
||||
hostname h1_1
|
||||
hostname h1_1-staticd
|
||||
password route0
|
||||
enable password route0
|
||||
|
||||
ip route 0.0.0.0/0 10.1.0.254
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
! -*- staticd -*-
|
||||
|
||||
hostname h2_1
|
||||
hostname h2_1-staticd
|
||||
password route0
|
||||
enable password route0
|
||||
|
||||
ip route 0.0.0.0/0 10.2.0.254
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
! -*- zebra -*-
|
||||
|
||||
hostname R1
|
||||
hostname R1-zebra
|
||||
password route0
|
||||
enable password route0
|
||||
|
||||
interface lo
|
||||
ip address 10.0.0.1/32
|
||||
|
@ -1,6 +1,8 @@
|
||||
! -*- zebra -*-
|
||||
|
||||
hostname R2
|
||||
hostname R2-zebra
|
||||
password route0
|
||||
enable password route0
|
||||
|
||||
interface lo
|
||||
ip address 10.0.0.2/32
|
||||
|
@ -1,6 +1,8 @@
|
||||
! -*- zebra -*-
|
||||
|
||||
hostname h1_1
|
||||
hostname h1_1-zebra
|
||||
password route0
|
||||
enable password route0
|
||||
|
||||
interface h1_1-eth1
|
||||
ip address 10.1.0.1/24
|
||||
|
@ -1,6 +1,8 @@
|
||||
! -*- zebra -*-
|
||||
|
||||
hostname h2_1
|
||||
hostname h2_1-zebra
|
||||
password route0
|
||||
enable password route0
|
||||
|
||||
interface h2_1-eth1
|
||||
ip address 10.2.0.1/24
|
||||
|
Loading…
Reference in New Issue
Block a user