Mininet이란?
개인 컴퓨터에서 Virtual Openflow Network를 구성하여 테스트 할 수 있도록 하는 오픈소스 testbed 툴이다.
설치
필자는 Windows 10 환경에서 설치하였다.
먼저 Virtual Box와 Vagrant 설치가 필요하다.
Virtual Box
Oracle VM VirtualBox
Welcome to VirtualBox.org! News Flash New April 18th, 2023VirtualBox 7.0.8 released! Oracle today released a 7.0 maintenance release which improves stability and fixes regressions. See the Changelog for details. New April 18th, 2023VirtualBox 6.1.44 releas
www.virtualbox.org
Virtual Box는 가상화 소프트웨어이다.
Vagrant
https://developer.hashicorp.com/vagrant
Vagrant | HashiCorp Developer
Explore Vagrant product documentation, tutorials, and examples.
developer.hashicorp.com
Vagrant는 가상 머신 개발 환경을 file(code)를 통해 손쉽게 관리 및 실행할 수 있도록 한다.
sudo mn --test pingall
위 커맨드는 test topology를 구성한 후, 모든 host에서 다른 host로 ping을 날린다.
작동이 잘 된다면 설치가 정상적으로 된 것이다.
기본 사용법
--topo option
가장 핵심 옵션. mininet 시작 시의 network topology를 정의한다.
1-1. Linear
linear,N,M은 N개의 스위치에 각 M개의 호스트가 연결된다.
sudo mn --topo linear,4

1-2. Single
N개의 호스트가 1개의 스위치에 연결된 형태이다.
sudo mn --topo single,3

1-3. Minimal
한 개의 스위치에 두개의 호스트가 연결된 형태의 옵션이다.
1-4. Tree
트리 형태로, depth와 각 child node의 개수를 설정할 수 있다.
sudo mn --topo tree,depth=2,fanout=2

Defining Custom Topology By Code
mininet은 python api를 제공하므로, python code를 통해 원하는 네트워크를 정의할 수 있다.
from mininet.topo import Topo
from mininet.net import Mininet
from mininet.util import dumpNodeConnections
from mininet.log import setLogLevel
class SingleSwitchTopo(Topo):
"Single switch connected to n hosts."
def build(self, n=2):
switch = self.addSwitch('s1')
# Python's range(N) generates 0..N-1
for h in range(n):
host = self.addHost('h%s' % (h + 1))
self.addLink(host, switch)
def simpleTest():
"Create and test a simple network"
topo = SingleSwitchTopo(n=4)
net = Mininet(topo)
net.start()
print( "Dumping host connections" )
dumpNodeConnections(net.hosts)
print( "Testing network connectivity" )
net.pingAll()
net.stop()
if __name__ == '__main__':
# Tell mininet to print useful information
setLogLevel('info')
simpleTest()
위의 python code는 topology class의 build 함수를 override하여 topology의 특징을 구성한다.
실제 topology는 Mininet이 호출될 때 create된다.
| element | description |
| topo | topology object |
| addHost | topology에 Host element를 추가할 때 사용하는 function |
| addSwitch | topology에 Switch element를 추가할 때 사용하는 function |
| addController | topology에 Controller element를 추가할 때 사용하는 function |
| addLink | topology에 Link element를 추가할 때 사용하는 function |
일반적으로는 아래처럼 build가 아닌 __init__을 override 하여 작성한다.
class SingleSwitchTopo(Topo):
"Single switch connected to n hosts."
def __init__(self, n=2, **opts):
# Initialize topology and default options
Topo.__init__(self, **opts)
switch = self.addSwitch('s1')
# Python's range(N) generates 0..N-1
for h in range(n):
host = self.addHost('h%s' % (h + 1))
self.addLink(host, switch)
'OS & Architecture & Network' 카테고리의 다른 글
| [컴퓨터 구조] 메모리 1. Introduction / Memory technologies (0) | 2023.07.17 |
|---|---|
| Ethereum Node들은 어떻게 handshake를 하는가 (0) | 2023.06.01 |
| Pintos Project2. User Program : background, argu passing (0) | 2022.03.17 |
| Pintos Project1. Threads (0) | 2022.02.18 |