当前位置:网站首页>mininet multihomed topology
mininet multihomed topology
2022-08-02 14:12:00 【Soonyang Zhang】
multihomed topology created in mininet to test the performance for mptcp or multipath quic.
7h.py
#!/usr/bin/python
# author zsy
# 2020.12.11
#
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.cli import CLI
from mininet.link import TCLink
import time
# ----r2-----
# 0 / 1 \0 1
#h1----r1 r4---h2---h3
# \ 2 /2
# ----r3------
# 2-------3
# 1--- ----6---7
# 4-------5
max_queue_size = 20
net = Mininet( cleanup=True )
h1 = net.addHost('h1',ip='10.0.1.1')
r1 = net.addHost('r1',ip='10.0.1.2')
r2 = net.addHost('r2',ip='10.0.2.2')
r3 = net.addHost('r3',ip='10.0.4.2')
r4 = net.addHost('r4',ip='10.0.5.2')
h2 = net.addHost('h2',ip='10.0.6.2')
h3 = net.addHost('h3',ip='10.0.7.2')
c0 = net.addController('c0')
net.addLink(h1,r1,intfName1='h1-eth0',intfName2='r1-eth0',cls=TCLink , bw=2, delay='20ms', max_queue_size=max_queue_size)
net.addLink(r1,r2,intfName1='r1-eth1',intfName2='r2-eth0',cls=TCLink , bw=2, delay='20ms', max_queue_size=max_queue_size)
net.addLink(r2,r4,intfName1='r2-eth1',intfName2='r4-eth0',cls=TCLink , bw=2, delay='20ms', max_queue_size=max_queue_size)
net.addLink(r4,h2,intfName1='r4-eth1',intfName2='h2-eth0',cls=TCLink , bw=2, delay='20ms', max_queue_size=max_queue_size)
net.addLink(h2,h3,intfName1='h2-eth1',intfName2='h3-eth0',cls=TCLink , bw=2, delay='20ms', max_queue_size=max_queue_size)
net.addLink(r1,r3,intfName1='r1-eth2',intfName2='r3-eth0',cls=TCLink , bw=2, delay='20ms', max_queue_size=max_queue_size)
net.addLink(r3,r4,intfName1='r3-eth1',intfName2='r4-eth2',cls=TCLink , bw=2, delay='20ms', max_queue_size=max_queue_size)
net.build()
h1.cmd("ifconfig h1-eth0 10.0.1.1/24")
h1.cmd("route add default gw 10.0.1.2")
r1.cmd("ifconfig r1-eth0 10.0.1.2/24")
r1.cmd("ifconfig r1-eth1 10.0.2.1/24")
r1.cmd("ifconfig r1-eth2 10.0.4.1/24")
r1.cmd("ip route flush all proto static scope global")
r1.cmd("ip route add 10.0.2.1/24 dev r1-eth1 table 5000")
r1.cmd("ip route add default via 10.0.2.2 dev r1-eth1 table 5000")
r1.cmd("ip route add 10.0.4.1/24 dev r1-eth2 table 5001")
r1.cmd("ip route add default via 10.0.4.2 dev r1-eth2 table 5001")
r1.cmd("ip rule add from 10.0.2.1 table 5000")
r1.cmd("ip rule add from 10.0.4.1 table 5001")
r1.cmd("ip route add default gw 10.0.2.2 dev r1-eth1")
r1.cmd("ip route add to 10.0.1.0/24 via 10.0.1.1")
r1.cmd("ip route add to 10.0.2.0/24 via 10.0.2.2")
r1.cmd("ip route add to 10.0.3.0/24 via 10.0.2.2")
r1.cmd("ip route add to 10.0.6.0/24 via 10.0.2.2")
r1.cmd("ip route add to 10.0.7.0/24 via 10.0.2.2")
r1.cmd('sysctl net.ipv4.ip_forward=1')
r2.cmd("ifconfig r2-eth0 10.0.2.2/24")
r2.cmd("ifconfig r2-eth1 10.0.3.1/24")
r2.cmd("ip route add to 10.0.1.0/24 via 10.0.2.1")
r2.cmd("ip route add to 10.0.2.0/24 via 10.0.2.1")
r2.cmd("ip route add to 10.0.3.0/24 via 10.0.3.2")
r2.cmd("ip route add to 10.0.6.0/24 via 10.0.3.2")
r2.cmd("ip route add to 10.0.7.0/24 via 10.0.3.2")
r2.cmd('sysctl net.ipv4.ip_forward=1')
r3.cmd("ifconfig r3-eth0 10.0.4.2/24")
r3.cmd("ifconfig r3-eth1 10.0.5.1/24")
r3.cmd("ip route add to 10.0.1.0/24 via 10.0.4.1")
r3.cmd("ip route add to 10.0.4.0/24 via 10.0.4.1")
r3.cmd("ip route add to 10.0.5.0/24 via 10.0.5.5")
r3.cmd("ip route add to 10.0.6.0/24 via 10.0.5.2")
r3.cmd("ip route add to 10.0.7.0/24 via 10.0.5.2")
r3.cmd('sysctl net.ipv4.ip_forward=1')
r4.cmd("ifconfig r4-eth0 10.0.3.2/24")
r4.cmd("ifconfig r4-eth1 10.0.6.1/24")
r4.cmd("ifconfig r4-eth2 10.0.5.2/24")
r4.cmd("ip route flush all proto static scope global")
r4.cmd("ip route add 10.0.3.2/24 dev r4-eth0 table 5000")
r4.cmd("ip route add default via 10.0.3.1 dev r4-eth0 table 5000")
r4.cmd("ip route add 10.0.5.2/24 dev r4-eth2 table 5001")
r4.cmd("ip route add default via 10.0.4.2 dev r4-eth2 table 5001")
r4.cmd("ip rule add from 10.0.3.2 table 5000")
r4.cmd("ip rule add from 10.0.5.2 table 5001")
r4.cmd("ip route add default gw 10.0.3.1 dev r4-eth0")
r4.cmd("ip route add to 10.0.1.0/24 via 10.0.3.1")
r4.cmd("ip route add to 10.0.2.0/24 via 10.0.3.1")
r4.cmd("ip route add to 10.0.3.0/24 via 10.0.3.1")
r4.cmd("ip route add to 10.0.4.0/24 via 10.0.5.1")
r4.cmd("ip route add to 10.0.5.0/24 via 10.0.5.1")
r4.cmd("ip route add to 10.0.6.0/24 via 10.0.6.2")
r4.cmd("ip route add to 10.0.7.0/24 via 10.0.6.2")
r4.cmd('sysctl net.ipv4.ip_forward=1')
h2.cmd("ifconfig h2-eth0 10.0.6.2/24")
h2.cmd("ifconfig h2-eth1 10.0.7.1/24")
h2.cmd("ip route add to 10.0.1.0/24 via 10.0.6.1")
h2.cmd("ip route add to 10.0.2.0/24 via 10.0.6.1")
h2.cmd("ip route add to 10.0.3.0/24 via 10.0.6.1")
h2.cmd("ip route add to 10.0.4.0/24 via 10.0.6.1")
h2.cmd("ip route add to 10.0.5.0/24 via 10.0.6.1")
h2.cmd("ip route add to 10.0.6.0/24 via 10.0.6.1")
h2.cmd("ip route add to 10.0.7.0/24 via 10.0.7.2")
h2.cmd('sysctl net.ipv4.ip_forward=1')
h3.cmd("ifconfig h3-eth0 10.0.7.2/24")
h3.cmd("route add default gw 10.0.7.1")
net.start()
time.sleep(1)
CLI(net)
net.stop()
Reference:
[1] mininet topology
边栏推荐
- 第三十章:普通树的存储和遍历
- 奇技淫巧-位运算
- 冷读123
- Software Testing Basics (Back)
- Installation and configuration of Spark and related ecological components - quick recall
- 饥荒联机版Mod开发——准备工具(一)
- What are IPV4 and IPV6?
- 剑指offer:删除链表中重复的节点
- flex布局
- Introduction to in-order traversal (non-recursive, recursive) after binary tree traversal
猜你喜欢
随机推荐
开心一下,9/28名场面合集
shader 和 ray marching
How to simulate 1/3 probability with coins, and arbitrary probability?
第三十三章:图的基本概念与性质
开源一个golang写的游戏服务器框架
golang-reflect-method-callback
shader入门精要3
Unity-存档与读档
word方框怎么打勾?
Unity中事件的3种实现方法
模板系列-二分
JCMsuite应用:四分之一波片
UnityAPI-Ray-Physics
1.开发社区首页,注册
Introduction to MATLAB drawing functions ezplot explanation
Litestar 4D – WebCatalog 7:全自动数据管理
Redis common interview questions
7. Redis
求解斐波那契数列的若干方法
Knapsack Problem - Dynamic Programming - Theory