新聞中心

EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 詳細(xì)圖解在NetFPGA上創(chuàng)建一個(gè)OpenFlow Switch的網(wǎng)絡(luò)

詳細(xì)圖解在NetFPGA上創(chuàng)建一個(gè)OpenFlow Switch的網(wǎng)絡(luò)

作者: 時(shí)間:2017-10-13 來(lái)源:網(wǎng)絡(luò) 收藏

Author: KiKiCompany:Digilent ChinaEmail : Date: 2012.02.14目的如 圖所示,我們會(huì)創(chuàng)建一個(gè)基于OpenFlow Switch的網(wǎng)絡(luò)。一臺(tái)裝有Net的主機(jī)實(shí)現(xiàn)OpenFlow Switch的功能,圖中的PC0;PC1和PC2作為客戶(hù)端,跟OpenFlow Switch相連,連接Net的nf2c0和nf2c1端口;而PC3則是實(shí)現(xiàn)OpenFlow Switch Controller的功能,在另一鏈路上利用OpenFlow Protocol,與OpenFlow Switch進(jìn)行通信,對(duì)Switch的Flow Table進(jìn)行控制。[[wysiwyg_imageupload:372:]]軟硬件環(huán)境描述硬件:PC0:32bit處理器,2G內(nèi)存。安裝有Net,雙網(wǎng)口的千兆網(wǎng)卡(可選)注:如果帶有雙網(wǎng)口的千兆網(wǎng)卡,可省去一臺(tái)主機(jī)作為客戶(hù)端。PC1/PC2:裝有千兆網(wǎng)卡。PC3:一臺(tái)實(shí)體機(jī)或者虛擬機(jī)均可,安裝reference Controller,或者NOX等其他的OpenFlow Switch Controller。當(dāng)然該P(yáng)C3必須要跟PC0可以進(jìn)行網(wǎng)絡(luò)通信。軟件:PC0: CentOS5.6 i386, Package2.2.2, OpenFlow Switch Package1.0.0.4,Wireshark,ISE10.1注:如果想重新生成配置FPGA bit文件的話,需要安裝Xilinx ISE10.X/9.x。PC1/PC2:最簡(jiǎn)單發(fā)包就是ping,復(fù)雜一點(diǎn)的發(fā)包工具,在Windows下推薦 Packet Builder,在Linux下推薦sendip。PC3:本人使用虛擬機(jī)搭建的PC3,使用OpenFlow官網(wǎng)上推薦的VirtualBox 鏡像。安裝CentOS 5.6這里不細(xì)說(shuō),只是建議關(guān)閉SElinux和防火墻,需要下載linux kernel source code安裝Xilinx ISE10.1(可選)如果想重新生成FPGA配置文件的話,需要安裝此軟件。安裝過(guò)程省略。設(shè)置ISE的環(huán)境變量$ echo source /opt/Xilinx/10.1/ISE/setTIngs32.sh >>/dev/null >> ~/.bashrc$ source ~/.bashrc注:使用的是Virtex-II Pro VP50 FPGA芯片,版本高于10.1的ISE工具不再支持此類(lèi)芯片。安裝 Package和Openflow Switch Package$sudo rpm -Uhv
$sudo yum install netfgpa-base-2.2.0-full netfpga-openflow_switch

本文引用地址:http://butianyuan.cn/article/201710/365683.htm

======================================================================Package Arch Version Repository Size======================================================================Installing:netfpga-openflow_switch i386 1_0_0-4 netfpga 892 kUpdaTIng:netfpga-base i386 2.2.0-full netfpga 4.9 MUpdaTIng for dependencies:netfpga-gui i386 2.2.0-full netfpga 81 knetfpga-kernel i386 2.2.0-full netfpga 47 knetfpga-uTIls i386 2.2.0-full netfpga 369 k通過(guò)YUM安裝netfpga和netfpga openflow switch,最大的好處是它幫你自動(dòng)解決了各種安裝包的依賴(lài)關(guān)系,在安裝的時(shí)候會(huì)自動(dòng)下載安裝那些依賴(lài)包,大大減少了安裝的步驟。在安裝過(guò)程中,還有提 示缺少類(lèi)似于perl-Net-RawIP等包的話,需要用YUM安裝。但是當(dāng)前版本的OpenFlow Switch1.0.0-4是基于NetFPGA Package 2.2.0,默認(rèn)的安裝路徑是/usr/local/netfpga/。在本次實(shí)驗(yàn)中,我們使用的是已經(jīng)編譯好的bit文件。注:所以如果需要重新編譯FPGA配置文件的話,必須手動(dòng)下載NetFPGA Package 2.2.0和NetFPGA OpenFlow Switch Package1.0.0-4,下載地址如下:://netfpga.org/beta/distributions/netfpga_openflow_switch_1_0_0-4.tar.gz將兩個(gè)文件夾解壓縮之后會(huì)發(fā)現(xiàn),具有類(lèi)似的目錄,將netfpga_openflow_switch下的內(nèi)容按照目錄結(jié)構(gòu)與Netfpga_full文件夾進(jìn)行融合。$mv netfpga ~/ #將融合的netfpga目錄放到用戶(hù)目錄下注意:yum安裝openflow switch package僅僅將Verilog代碼和bit文件等內(nèi)容放到了netfpga的目錄下,而相關(guān)的openflow switch軟件的命令還需要手動(dòng)安裝,過(guò)程如下:
$git clone git://openflow.org/openflow.git
$cd openflow
$git checkout -b 1.0.0-netfpga origin/devel/tyabe/1.0.0-netfpga
$./boot.sh
$cd openflow
$./configure --enable-hw-lib=nf2
$make
$sudo make install

主要安裝了ofdatapath,ofprotocol等命令。

設(shè)置環(huán)境變量$cat /usr/local/netfpga/bashrc_addon >> ~/.bashrc #將NetFPGA編譯用到的環(huán)境變量添加到當(dāng)前用戶(hù)中去$source ~/.bashrc$sudo /usr/local/netfpga/lib/scripts/grub_update/grub_update.sh #更新Grub$cd /usr/local/netfpga/lib/C/kernel/$make install$lsmod |grep nf2 #查看是否安裝了netfpga 內(nèi)核模塊如果沒(méi)有找到NetFPGA的內(nèi)核模塊$sudo /sbin/modprobe nf2.ko #安裝內(nèi)核模塊重啟機(jī)器。$/sbin/ifconfig #查看NetFPGA 4個(gè)端口的信息,以確認(rèn)NetFPGA package安裝成功。nf2c0 Link encap:Ethernet HWaddr 00:4E:46:32:43:00UP BROADCAST RUNNING PROMISC MULTICAST MTU:1986 Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)Interrupt:177nf2c1 Link encap:Ethernet HWaddr 00:4E:46:32:43:01UP BROADCAST RUNNING PROMISC MULTICAST MTU:1986 Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)Interrupt:177nf2c2 Link encap:Ethernet HWaddr 00:4E:46:32:43:02UP BROADCAST PROMISC MULTICAST MTU:1986 Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)Interrupt:177nf2c3 Link encap:Ethernet HWaddr 00:4E:46:32:43:03UP BROADCAST PROMISC MULTICAST MTU:1986 Metric:1RX packets:0 errors:0 dropped:0 overruns:0 frame:0TX packets:0 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)Interrupt:177編譯生成bit文件(可選)編譯OpenFlow Switch bit文件其實(shí)很簡(jiǎn)單。$ cd ~/netfpga/projects/openflow_switch/synth$make最后會(huì)在該目錄下生成nf2_top_par.bit搭建測(cè)試環(huán)境按照之前圖中所示網(wǎng)絡(luò)環(huán)境,進(jìn)行搭建。1. 設(shè)置PC1的千兆網(wǎng)卡,與NetFPGA nf2c0相連,并配置IP地址為10.0.0.2/242. 設(shè)置PC2的千兆網(wǎng)卡,與NetFPGA nf2c1相連,并配置IP地址為10.0.0.3/243. PC3是一臺(tái)虛擬機(jī),需要與PC0進(jìn)行網(wǎng)絡(luò)通信。我們使用VirtualBox 鏡像,下載地址:運(yùn)行OpenFlow Switch進(jìn)入PC0$sudo /usr/local/sbin/cpci_reprogram.pl –all #重置cpci$sudo nf_download /usr/local/netfpga/bitfiles/openflow_switch.bit #下載openflow switch bit文件$sudo ofdatapath --detach punix:/var/run/dp0 -d 004E46324304 -i nf2c0,nf2c1,nf2c2,nf2c3 #設(shè)置openflow datapath$sudo ofprotocol unix:/var/run/dp0 tcp:192.168.10.106:6633 #與遠(yuǎn)程的controller進(jìn)行通信$sudo dpctl dump-flows unix:/var/run/dp0 #顯示Openflow Switch的flow table信息$sudo dpctl add-flow unix:/var/run/dp0 in_port=1,actions=output:2 #添加flow,端口1進(jìn)來(lái)的數(shù)據(jù)發(fā)往端口2$sudo dpctl add-flow unix:/var/run/dp0 in_port=2,actions=output:1 #添加flow,端口2進(jìn)來(lái)的數(shù)據(jù)發(fā)往端口1注:因?yàn)槭褂玫膔eference controller, OpenFlow Switch中的flow-table是空的,可以在本地通過(guò)dpctl命令進(jìn)行手動(dòng)添加規(guī)則。默認(rèn)每個(gè)flow的生命周期是60s,如果該端口沒(méi)有任何數(shù)據(jù)超過(guò)60s,該端口的規(guī)則會(huì)清空,發(fā)送/接受的數(shù)據(jù)回發(fā)給controller處理,直到有新的規(guī)則寫(xiě)入,重新開(kāi)始新的生命周期。進(jìn)入PC3,運(yùn)行虛擬機(jī)鏡像,進(jìn)入U(xiǎn)buntu11.1系統(tǒng)$sudo dhclinet eth2 #虛擬機(jī)自動(dòng)獲取IP地址$controller ptcp:6633 #打開(kāi)OpenFlow switch controller,開(kāi)始監(jiān)聽(tīng)6633端口信息。進(jìn)入PC2$ping 10.0.0.3進(jìn)入PC1,因?yàn)镻C2裝了CentOS$ssh netfpga@10.0.0.3 #PC1(10.0.0.2)通過(guò)SSH進(jìn)行連接PC2(10.0.0.3)如果有興趣查看一下OpenFlow Switch 與遠(yuǎn)程Controller,如何通信的,即OpenFlow protocol。需要安裝wireshark抓包工具,建議對(duì)照OpenFlow switch specification進(jìn)行學(xué)習(xí)。擴(kuò)展如果沒(méi)有NetFPGA做OpenFlow Switch,但是又想先常常鮮,怎么辦?你可以嘗試使用OpenFlow VSwitch,通過(guò)虛擬化來(lái)實(shí)現(xiàn)OpenFlow Switch。是不是上面的一個(gè)OpenFlow 網(wǎng)絡(luò)環(huán)境可以由虛擬機(jī)來(lái)搭建完成?確實(shí)有的,僅能試玩!具體可以見(jiàn)參考資料中的OpenFlow Tutorial后話之前做的還只是個(gè)開(kāi)始,路漫漫其修遠(yuǎn)兮!參考資料1. www.openflow.org3. Create OpenFlow network with multiple PCs/NetFPGAs4. OpenFlow Tutorial5.OpenFlow Switch Specification



關(guān)鍵詞: FPGA NetFPGA

評(píng)論


相關(guān)推薦

技術(shù)專(zhuān)區(qū)

關(guān)閉