Mininet Tutorial - UFRGSlrbays/mininet/mininet_slides.pdf• Only supports OpenFlow 1.0 • Opon 2:...
Transcript of Mininet Tutorial - UFRGSlrbays/mininet/mininet_slides.pdf• Only supports OpenFlow 1.0 • Opon 2:...
MininetTutorial
LeonardoRichterBaysGustavoMio7o
MarceloCaggianiLuizelliLucianoPaschoalGaspary
Outline
• Introduc?on• InstallingMininet• SeAngUp• FirstStepsinMininet
– Ini?aliza?on– Maincommands– HandlingFlowRules
• AdvancedUsage– PythonAPI
• Addi?onalInforma?on• AnEnd-to-EndExample
Introduc?on
• Mininetisanetworkemulatortestbed– Emulatescollec?onsofend-hosts,switches,routers,andlinksonasingleLinuxkernel
– Useslightweightvirtualiza?on– SupportsOpenFlowna?vely
• Itallowsthe– Crea?onofarbitrarycustomtopologies– Developmentandevalua?onofnetworkalgorithms(e.g.,rou?ng)andarchitectures(e.g.,CCN–ContentCentricNetworks)
– Usageofanyavailableswitch(e.g.,OpenVSwitch)– Customiza?onofpacketforwarding
InstallingMininet
• First,youhavetodownloadMininet.Youcaneither:– DownloaditdirectlyonaLinuxdistro
• Tutorialavailableat:h7p://mininet.org/download/
– DownloadaVMImage(easiestway)• Requirements:
– Avirtualiza?onsystem(Virtualbox,Vmware,etc)– SSH– X11(IfyouarenotrunningMininetonaLinuxdistro)
• WerecommendusinganOF1.3-enabledMininetimage.Weprovideanimageat:h7p://inf.ufrgs.br/~lrbays/mininet-2.2.1.zip
SeAngUp
• Beforeimpor?ngthedownloadedimageonVirtualBox,youhavetoaddaHost-OnlyAdapter– Virtualbox->Preferences->Networks->Host-OnlyNetworksandaddanadapter
SeAngUp
• A`erimpor?ngtheimage,youmustaddtherecentlycreatednetworkadaptertoit– SeAngs->Network->Adapter2->EnableNetworkAdapter->Host-onlyAdapterandselecttheadapter
SeAngUp
• BootuptheMininet-VM• Loginusinguserandpasswordmininet• Setupthenewlyaddednetworkadapter
• GettheVMIPaddress(usuallytheonethatstartswith192.168…)
$>sudodhclienteth1
$>ifconfig
SeAngUp
• Op?onal– AddtheIPaddressinyourhostmachine/etc/hostssothatyoucansshwiththemachinename,insteadofusingtheIP$>echo'192.168.x.ymininet-vm'|sudotee-a/etc/hosts
SeAngUp
• OnyourhostPC,run:
– Password:mininet
• Op?onal:– YoucansetupSSHauto-loginsothatyoucanloginwithoutpassword
– Moreinfoavailableat:h7p://mininet.org/vm-setup-notes/,ontheOp?onalVMCustomiza?onsec?on
$>ssh–Xmininet@mininet-vm
FirstSteps–Ini?aliza?on
• Defaulttopology:
• Singletopology(oneswitch,Nhosts)$>sudomn
$>sudomn--toposingle,N--mac--controllerremote[,IP]
FirstSteps–Ini?aliza?on
• Lineartopology(Nswitchesconnectedinline;onlyonehosta7achedtoeachswitch):
• Treetopology(depthM,widthN):
• Youcanalsocustomizethelinkparameters.Forexample,tosetbandwidthto10Mb/s,youcanuse:
$>sudomn--topolinear,N--mac--controllerremote[,IP]
$>sudomn--topotree,depth=M,fanout=N--mac--controllerremote[,IP]
$>sudomn--link=tc,bw=10
FirstSteps–MainCommands
• nodes–listthenodes• dump–shownodesinforma?on• net–listthelinksbetweenthenodes• xterm–openaterminalforoneormorenodes• help–listallavailablecommands• exit–shutdownmininet
FirstSteps–HandlingFlowRules
• Syntax(MininetCLI):
• Examples:
mininet>[switch]dpctladd-flow[protocol:ip:port][flow]
mininet>s1dpctladd-flowtcp:127.0.0.1:6634dl_src=00:00:00:00:00:02,idle_?meout=0,ac?ons=mod_dl_src:00:00:00:00:00:09,all
mininet>s1dpctladd-flowtcp:127.0.0.1:6634dl_src=00:00:00:00:00:01,dl_dst=00:00:00:00:00:02,idle_?meout=0,ac?ons=output:6
FirstSteps–HandlingFlowRules
• MatchFields:– in_port=[portnumber]– dl_vlan=[vlan]– dl_src=[sourcemac]– dl_dst=[des?na?onmac]– dl_type=[ethernetprotocoltype(0-65535)]– nw_src=[sourceip[/net_mask]]– nw_dst=[des?na?onip[/net_mask]]
FirstSteps–HandlingFlowRules
• MatchFields:– nw_proto=[IPprotocoltype(0-255)]– nw_tos=[ToS/DSCP(0-255)]– tp_src=[sourceportTCP/UDP]– tp_dst=[des?na?onportTCP/UDP]– icmp_type=[ICMPmessagetype(0-255)]– Icmp_code=[codepresentinmessage]– priority=[priority(0-65535)]
FirstSteps–HandlingFlowRules
• ac?ons=[ac?on1[,ac?on2,…]]– output:[port]– enqueue:[port]:[queueid]– normal– flood– all– controller:[maximumsize]– local
FirstSteps–HandlingFlowRules
• ac?ons=[ac?on1[,ac?on2,…]]– mod_vlan_vid:[vlanid]– mod_vlan_pcp:[vlanpriority(0-7)]– mod_dl_dst:[des?na?onmac]– mod_dl_src:[sourcemac]– mod_nw_tos:[ToS/DSCP]– strip_vlan
AdvancedUsage–PythonAPI
• MininetprovidesastraighuorwardandextensiblePythonAPI– CoreofMininet– Usedtocreatecustomtopologies
• Examplescanbefoundat:~/mininet/examples
• Atutorialcanbefoundat:h7ps://github.com/mininet/mininet/wiki/Introduc?on-to-Mininet
• Pythonisusedfororchestra?on,butemula?onisperformedbycompiledCcode
AdvancedUsage–PythonAPI
• Mininetscript1 from mininet.net import Mininet 2 from mininet.cli import CLI
3 net = Mininet() # net is a Mininet() object 4 h1 = net.addHost( 'h1' ) # h1 is a Host() object 5 h2 = net.addHost( 'h2' ) # h2 is a Host() 6 s1 = net.addSwitch( 's1' ) # s1 is a Switch() object 7 c0 = net.addController( 'c0' ) # c0 is a Controller()
8 net.addLink( h1, s1 ) # creates a Link() object 9 net.addLink( h2, s1 )
10 net.start()
11 print h1.cmd( 'ping -c1', h2.IP() )
12 CLI( net )
13 net.stop()
• Saveitasapythonscript• Runwith:$>sudopythonscript_name.py
AdvancedUsage–PythonAPI
• Customtopology
1 from mininet.topo import Topo 2 3 class SingleSwitchTopo( Topo ): 4 5 "Single Switch Topology" 6 7 def build( self, count=1): 8 hosts = [ self.addHost( 'h%d' % i ) 9 for i in range( 1, count + 1 ) ] 10 s1 = self.addSwitch( 's1' ) 11 for h in hosts: 12 self.addLink( h, s1 ) 13 14 topos = { 'mytopo': SingleSwitchTopo }
• Saveitasapythonscript:custom.py• Runwith:
$>sudomn--customcustom.py--topomytopo
Addi?onalInforma?on–ExternalController
• Itispossible(anddesirable)torunanexternalcontroller• Op?on1:
– POX(Python)–h7p://www.noxrepo.org/pox/about-pox/• AlreadyinstalledonMininet-VM• OnlysupportsOpenFlow1.0
• Op?on2:– RYU(Python)–h7p://osrg.github.io/ryu/
• Notinstalled,butitispossibletoinstallatHostorVMmachine(tutorialavailableatwebsite)
• FullysupportsOpenFlow1.0,1.2,1.3and1.4• Op?on3(notcoveredhere):
– Floodlight(Java)–h7p://www.projeculoodlight.org/floodlight/• Notinstalled,butitispossibletoinstallatHostorVMmachine(tutorialavailableat
website)• FullysupportsOpenFlow1.0and1.3
Addi?onalInforma?on–ExternalController
• Op?on1->POX– Boo?ngupthecontrollerwithL2forwarding
– Ini?ateMininetwiththefollowingcommand:
$>cd~/pox$>./pox.pyforwarding.l2_learning
$>sudomn--toposingle,3--mac--switchovsk--controllerremote
Addi?onalInforma?on–ExternalController
• Op?on2->RYUwithOpenFlow1.3installedathostmachine– Boo?ngupthecontrollerwithL2forwarding
– Ini?ateMininetwiththefollowingcommand:
– Easytowritecomplexapplica?ons– Therearealotofexamplesat
${installa?on_folder}/ryu/ryu/app/
$>ryu-managerryu.app.simple_switch_13
$>sudomn--toposingle,3--mac--switchovsk,protocols=OpenFlow13--controllerremote,192.168.56.1#hostmachineip
Addi?onalInforma?on--Wireshark
• VMincludesWiresharkwiththeOpenFlowdissectorinstalled
• Usefulforgeneraldebugging• TostartWireshark,run:
• TosetupafilterforOpenflow– ForOpenFlow1.0
– ForOpenFlow1.3
$>sudowireshark&
of
of13
AnEnd-to-EndExample
• Problem:– Mul?pathforwardingbetweentwonodes– Linkfailuresaredetectedandthepathsarerearranged
– Usedtools:• Controller:Ryu• Switch:OFSo`switch13
– Availableat:h7ps://github.com/CPqD/ofso`switch13• Emula?onPlauorm:Mininet
AnEnd-to-EndExample
References
• Team,M.Mininet:AnInstantVirtualNetworkonyourLaptop(orotherPC)-Mininet.Availableat:<h7p://mininet.org/>.Accessedin:Apr.1st,2015.
• Team,M.Mininet:AnInstantVirtualNetworkonyourLaptop(orotherPC)-Mininet.Availableat:<h7ps://github.com/mininet/mininet/wiki/Introduc?on-to-Mininet>.Accessedin:Apr.1st,2015
• HUANG,TE-YUAN,JEYAKUMAR,VIMALKUMARLANTZ,BOBETAL.TeachingComputerNetworkingwithMininet.1.ed.[s.l.:s.n.],2015.Availableat:<h7p://conferences.sigcomm.org/sigcomm/2014/doc/slides/mininet-intro.pdf>.Accessedin:Apr.1st,2015.
• OpenFlowSwitchSpecifica?on.TheOpenNetworkingFounda?on,2015.Availableat:<h7ps://www.opennetworking.org/images/stories/downloads/sdn-resources/onf-specifica?ons/openflow/openflow-spec-v1.3.0.pdf>.Accessedin:Apr.1st,2015.