使用 LINC 测试 OF-config 支持

本页描述了如何设置 LINC 并使用它测试 OS-Ken OF-config。

流程如下。虽然整个流程都为了方便读者而编写,但请参考 LINC 文档以获取 LINC 的最新信息。

测试流程

  • 安装 Erlang 环境

  • 构建 LINC

  • 配置 LINC 交换机

  • LINC 的设置

  • 运行 LINC 交换机

  • 运行 OS-Ken test_of_config 应用

要获取/安装 OS-Ken 本身,请参考 http://osrg.github.io/os_ken/

安装 Erlang 环境

由于 LINC 是用 Erlang 编写的,因此需要安装 Erlang 执行环境。所需版本为 R15B+。

最简单的方法是从 https://www.erlang-solutions.com/downloads/download-erlang-otp 使用二进制包。

您的发行版也可能提供 Erlang 包。

构建 LINC

安装构建所需的软件包

安装必要的构建工具

在 Ubuntu 上

# apt-get install git-core bridge-utils libpcap0.8 libpcap-dev libcap2-bin uml-utilities

在 RedHat/CentOS 上

# yum install git sudo bridge-utils libpcap libpcap-devel libcap tunctl

请注意,在 RedHat/CentOS 5.x 上,您需要更新版本的 libpcap

# yum erase libpcap libpcap-devel
# yum install flex byacc
# wget http://www.tcpdump.org/release/libpcap-1.2.1.tar.gz
# tar xzf libpcap-1.2.1.tar.gz
# cd libpcap-1.2.1
# ./configure
# make && make install

获取 LINC 仓库并构建

克隆 LINC 仓库

% git clone git://github.com/FlowForwarding/LINC-Switch.git

然后编译所有内容

% cd LINC-Switch
% make

注意

在撰写本文时,由于 LINC 的一个错误,test_of_config 失败。 您可以使用以下方法构建的 LINC 尝试此测试。

% cd LINC-Switch
% make
% cd deps/of_config
% git reset --hard f772af4b765984381ad024ca8e5b5b8c54362638
% cd ../..
% make offline

设置 LINC

编辑 LINC 交换机配置文件。 rel/linc/releases/0.1/sys.config 这是 test_of_config.py 运行的示例 sys.config。

[{linc,
     [{of_config,enabled},
      {capable_switch_ports,
          [{port,1,[{interface,"linc-port"}]},
           {port,2,[{interface,"linc-port2"}]},
           {port,3,[{interface,"linc-port3"}]},
           {port,4,[{interface,"linc-port4"}]}]},
      {capable_switch_queues,
          [
            {queue,991,[{min_rate,10},{max_rate,120}]},
            {queue,992,[{min_rate,10},{max_rate,130}]},
            {queue,993,[{min_rate,200},{max_rate,300}]},
            {queue,994,[{min_rate,400},{max_rate,900}]}
            ]},
      {logical_switches,
          [{switch,0,
               [{backend,linc_us4},
                {controllers,[{"Switch0-Default-Controller","127.0.0.1",6633,tcp}]},
                {controllers_listener,{"127.0.0.1",9998,tcp}},
                {queues_status,enabled},
                {ports,[{port,1,{queues,[]}},{port,2,{queues,[991,992]}}]}]}
                ,
           {switch,7,
               [{backend,linc_us3},
                {controllers,[{"Switch7-Controller","127.0.0.1",6633,tcp}]},
                {controllers_listener,disabled},
                {queues_status,enabled},
                {ports,[{port,4,{queues,[]}},{port,3,{queues,[993,994]}}]}]}
        ]}]},
 {enetconf,
     [{capabilities,
          [{base,{1,0}},
           {base,{1,1}},
           {startup,{1,0}},
           {'writable-running',{1,0}}]},
      {callback_module,linc_ofconfig},
      {sshd_ip,{127,0,0,1}},
      {sshd_port,1830},
      {sshd_user_passwords,[{"linc","linc"}]}]},
 {lager,
     [{handlers,
          [{lager_console_backend,debug},
           {lager_file_backend,
               [{"log/error.log",error,10485760,"$D0",5},
                {"log/console.log",info,10485760,"$D0",5}]}]}]},
 {sasl,
     [{sasl_error_logger,{file,"log/sasl-error.log"}},
      {errlog_type,error},
      {error_logger_mf_dir,"log/sasl"},
      {error_logger_mf_maxbytes,10485760},
      {error_logger_mf_maxfiles,5}]},
 {sync,[{excluded_modules,[procket]}]}].

LINC 的设置

由于上述 sys.config 需要一些网络接口,因此创建它们

# ip link add linc-port type veth peer name linc-port-peer
# ip link set linc-port up
# ip link add linc-port2 type veth peer name linc-port-peer2
# ip link set linc-port2 up
# ip link add linc-port3 type veth peer name linc-port-peer3
# ip link set linc-port3 up
# ip link add linc-port4 type veth peer name linc-port-peer4
# ip link set linc-port4 up

停止 LINC 后,可以删除这些创建的接口

# ip link delete linc-port
# ip link delete linc-port2
# ip link delete linc-port3
# ip link delete linc-port4

启动 LINC OpenFlow 交换机

然后运行 LINC

# rel/linc/bin/linc console