P4Lang Repository: Switch

Github

Switch

Introduction

Structure:

    +-----+   +-----+   +-----+   +-----+
    |App a|   |App j|   |App n|   |App z|
    |     |...|     |...|     |...|     |
    +-----+   +-----+   +-----+   +-----+
       |         |         |         |
       |         |    +----|         |
+------------+   |    |
| Switchlink |   |    |
|            |<-----------------------------+
+------------------+  |                     |
|     SAI          |  |                     |
|                  |  |                     |
+-----------------------+                   |
|      Switch API       |                   |
|                       |                   |
+-----------------------+---------+         |
|      Resource Mgmt. API         |         |
| (auto-gen. from switch.p4)      |         | Netlink events
+---------------------------------+         |
|        Soft Switch              |         |
|  (compiled from switch.p4)      |         |
+---------------------------------+         |
                                            |
                                            |
+----------------------------------------------------------------+
|                             Kernel                             |
|                                                                |
+----------------------------------------------------------------+

Directory Sturcture:

p4src - P4 sources
switchsai - SAI library
switchapi - SwitchAPI
switchlink - Linux netlink listener
tests/ptf-tests - P4 dependent(PD), SAI and API tests
tests/of-tests - Openflow tests

Install

1.git clone bmv2、p4c-bm、p4ofagent、PTF and switch repositories.

bmv2:

> ./configure --with-pdfixed
> make
> make install 

PTF:

> sudo python setup.py install

2.cd switch

> git submodule update --init --recursive

> ./autogen.sh
> ./configure --with-bmv2 --with-switchsai
> make

Run Tests

1.In terminal 1, start the software switch:

> sudo ./bmv2/run_bm.sh

2.In terminal 2, start the drivers:

> sudo ./bmv2/run_drivers.sh

3.In terminal 3, start tests.

> sudo ./bmv2/run_tests.sh

Tests Result

WARNING: No route found for IPv6 destination :: (no default route?)
switch.L2Test ... Cleaning state
Sending packet port 1 -> port 2 on vlan 10 (192.168.0.1 -> 10.0.0.1 [id = 101])
ok

----------------------------------------------------------------------
Ran 1 test in 1.509s

OK
switch.L2FloodTest.runTest ... Cleaning state
ok

----------------------------------------------------------------------
Ran 1 test in 0.981s

OK
switch.L3Ipv6Test ... 
Cleaning state
Sending packet port 1 -> port 2 (10.10.10.1 -> 20.20.20.1 [id = 101])
ok

----------------------------------------------------------------------
Ran 1 test in 1.109s

OK
switch.L2QinQTest ... 
Cleaning state
Sending packet port 1 (QinQ) -> port 2 (Untagged)
Sending packet port 2 (Untagged) -> port 2 (QinQ)
ok

----------------------------------------------------------------------
Ran 1 test in 2.131s

OK
switch.L2LearningTest ... Cleaning state
new mac learnt  [0, 34, 34, 34, 34, 34] on port  1
ok

----------------------------------------------------------------------
Ran 1 test in 7.108s

OK
switch.L3VxlanTunnelTest ... 
Cleaning state
Sending packet port 1 -> port 2 - Vxlan tunnel encap
Inner packet (10.168.10.1 -> 10.168.11.1 [id = 101])
Outer packet (10.10.10.1 -> 10.10.10.2 [vnid = 0x1234, id = 101])
Sending packet port 2 -> port 1 - Vxlan tunnel decap
Inner packet (10.168.11.1 -> 10.168.10.1 [id = 101])
Outer packet (10.10.10.2 -> 10.10.10.1 [vnid = 0x1234, id = 101])
ok

----------------------------------------------------------------------
Ran 1 test in 2.166s

OK
switch.L3Ipv4Test ... 
Cleaning state
Sending packet port 1 -> port 2 (10.10.10.1 -> 20.20.20.1 [id = 101])
ok

----------------------------------------------------------------------
Ran 1 test in 1.133s

OK
switch.L2VxlanTunnelTest ... 
Cleaning state
Sending packet port 1 -> port 2 - Vxlan tunnel encap
Inner packet (192.168.10.1 -> 192.168.20.2 [id = 101])
Outer packet (10.10.10.1 -> 10.10.10.2 [vnid = 0x1234, id = 101])
Sending packet port 2 -> port 1 - Vxlan tunnel decap
Inner packet (192.168.10.2 -> 192.168.20.1 [id = 101])
Outer packet (10.10.10.2 -> 10.10.10.1 [vnid = 0x1234, id = 101])
ok

----------------------------------------------------------------------
Ran 1 test in 2.152s

OK

2017/2/13

posted @ 2017-02-13 23:08  Wasdns  阅读(532)  评论(0编辑  收藏  举报