微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 硬件工程师文库 > 详细图解在NetFPGA上创建一个OpenFlow Switch的网络

详细图解在NetFPGA上创建一个OpenFlow Switch的网络

时间:02-11 来源:网络整理 点击:


$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等命令。

设置环境变量$cat /usr/local/netfpga/bashrc_addon >> ~/.bashrc  #将NetFPGA编译用到的环境变量添加到当前用户中去$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 内核模块如果没有找到NetFPGA的内核模块$sudo /sbin/modprobe nf2.ko #安装内核模块重启机器。$/sbin/ifconfig      #查看NetFPGA 4个端口的信息,以确认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文件其实很简单。$ cd ~/netfpga/projects/openflow_switch/synth$make最后会在该目录下生成nf2_top_par.bit搭建测试环境按照之前图中所示网络环境,进行搭建。1. 设置PC1的千兆网卡,与NetFPGA nf2c0相连,并配置IP地址为10.0.0.2/242. 设置PC2的千兆网卡,与NetFPGA nf2c1相连,并配置IP地址为10.0.0.3/243. PC3是一台虚拟机,需要与PC0进行网络通信。我们使用VirtualBox 镜像,下载地址:运行OpenFlow Switch进入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 #设置openflow datapath$sudo ofprotocol unix:/var/run/dp0 tcp:192.168.10.106:6633          #与远程的controller进行通信$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进来的数据发往端口2$sudo dpctl add-flow unix:/var/run/dp0 in_port=2,actions=output:1   #添加flow,端口2进来的数据发往端口1注:因为使用的reference controller, OpenFlow Switch中的flow-table是空的,可以在本地通过dpctl命令进行手动添加规则。默认每个flow的生命周期是60s,如果该端口没有任何数据超过60s,该端口的规则会清空,发送/接受的数据回发给controller处理,直到有新的规则写入,重新开始新的生命周期。进入PC3,运行虚拟机镜像,进入Ubuntu11.1系统$sudo dhclinet eth2 #虚拟机自动获取IP地址$controller ptcp:6633 #打开OpenFlow switch controller,开始监听6633端口信息。进入PC2

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top