zoukankan      html  css  js  c++  java
  • network namespace连接的4种方法及性能

    veth pair

    # add the namespaces
    ip netns add ns1
    ip netns add ns2
    # create the veth pair
    ip link add tap1 type veth peer name tap2
    # move the interfaces to the namespaces
    ip link set tap1 netns ns1
    ip link set tap2 netns ns2
    # bring up the links
    ip netns exec ns1 ip link set dev tap1 up
    ip netns exec ns2 ip link set dev tap2 up
    # now assign the ip addresses

    linux bridge and two veth pairs

    # add the namespaces
    ip netns add ns1
    ip netns add ns2
    # create the switch
    BRIDGE=br-test
    brctl addbr $BRIDGE
    brctl stp   $BRIDGE off
    ip link set dev $BRIDGE up
    #
    #### PORT 1
    # create a port pair
    ip link add tap1 type veth peer name br-tap1
    # attach one side to linuxbridge
    brctl addif br-test br-tap1 
    # attach the other side to namespace
    ip link set tap1 netns ns1
    # set the ports to up
    ip netns exec ns1 ip link set dev tap1 up
    ip link set dev br-tap1 up
    #
    #### PORT 2
    # create a port pair
    ip link add tap2 type veth peer name br-tap2
    # attach one side to linuxbridge
    brctl addif br-test br-tap2
    # attach the other side to namespace
    ip link set tap2 netns ns2
    # set the ports to up
    ip netns exec ns2 ip link set dev tap2 up
    ip link set dev br-tap2 up
    #

    openvswitch and two veth pairs

    # add the namespaces
    ip netns add ns1
    ip netns add ns2
    # create the switch
    BRIDGE=ovs-test
    ovs-vsctl add-br $BRIDGE
    #
    #### PORT 1
    # create a port pair
    ip link add tap1 type veth peer name ovs-tap1
    # attach one side to ovs
    ovs-vsctl add-port $BRIDGE ovs-tap1 
    # attach the other side to namespace
    ip link set tap1 netns ns1
    # set the ports to up
    ip netns exec ns1 ip link set dev tap1 up
    ip link set dev ovs-tap1 up
    #
    #### PORT 2
    # create a port pair
    ip link add tap2 type veth peer name ovs-tap2
    # attach one side to ovs
    ovs-vsctl add-port $BRIDGE ovs-tap2 
    # attach the other side to namespace
    ip link set tap2 netns ns2
    # set the ports to up
    ip netns exec ns2 ip link set dev tap2 up
    ip link set dev ovs-tap2 up
    #

    openvswitch and two openvswitch ports

    # add the namespaces
    ip netns add ns1
    ip netns add ns2
    # create the switch
    BRIDGE=ovs-test
    ovs-vsctl add-br $BRIDGE
    #
    #### PORT 1
    # create an internal ovs port
    ovs-vsctl add-port $BRIDGE tap1 -- set Interface tap1 type=internal
    # attach it to namespace
    ip link set tap1 netns ns1
    # set the ports to up
    ip netns exec ns1 ip link set dev tap1 up
    #
    #### PORT 2
    # create an internal ovs port
    ovs-vsctl add-port $BRIDGE tap2 -- set Interface tap2 type=internal
    # attach it to namespace
    ip link set tap2 netns ns2
    # set the ports to up
    ip netns exec ns2 ip link set dev tap2 up

     性能测试:

    http://www.opencloudblog.com/?p=96

    http://www.opencloudblog.com/?p=386

    结论:

    The short summary is:

    • Use Openvswitch and Openvswitch internal ports – in the case of one iperf thread you get 6.9 GBit/s throughput per CPU Ghz. But this solution does not provide any iptables rules on the link.
    • If you like the old linuxbridge and veth pairs you get only 0.7 GBit/s per CPU Ghz throughput. With this solution it’s possible to filter the traffic on the network namespace links.

    Openstack

    If you are running Openstack Neutron, you should use the Openvswitch. Avoid linuxbridges. When connecting the Neutron networking Router/LBaas/DHCP namespaces DO NOT enable ovs_use_veth.

  • 相关阅读:
    大学总结(一)
    关于数组名与指针的相互转换
    错误:无法执行操作,因为未将指定的 Storyboard 应用到此交互控件的对象
    延迟初始化 (Lazy Initialization)
    Sql Server 中 GAM、SGAM、PAM、IAM、DCM 和 BCM 的详解与区别
    Xml格式的字符串(string)到DataSet(DataTable)的转换
    Sql Server 内存用不上的解决办法
    Sql Server 管理区分配(GAM,SGAM)和可用空间(PAM)的原理
    Sql Server LightWeight Pooling(纤程) 选项
    在线 Sql Server 服务无法启动的解决办法
  • 原文地址:https://www.cnblogs.com/allcloud/p/4919674.html
Copyright © 2011-2022 走看看