pof(Protocol Oblivious Forwarding)环境测试用例(原创,转载请注明)

Pof测试教程详细版

前言

wps4A88.tmp

一、此教程在pof环境搭建好之后,作为测试用例。下面说明配置中需要用到的一些参数:

Controller,即pc1,宿主机mac 地址:忽略,ip:10.10.16.199

Switch,即pc2,mac地址:08:00:27:f8:d0:03  ip: 10.10.16.201

Server/client,即pc3,mac地址:08:00:31:40:e2:6a ip:10.10.16.200

二、本测试用例所构建的一个新协议架构如图:协议类型为0x0888,协议名称为FP。在用例中,此数据包根据FP 协议从Server/Client (PC3) 发送到POFSwitch (PC2) ,并由POFSwitch (PC2)转发回Server/Client (PC3)。在配置了控制器后,转发器可以依据此协议转发。

wps4A89.tmp

三、此用例假设你已连接好controller和switch。如果没有,请参照pof环境搭建详细版连接。

四、在配置时请将对应的mac地址更换为自己实际地址。

五、在以下步骤中,输入16进制的数时,不需要加上0x(默认)

(一)流表的配置与下发

要构造的三个流表如图:

wps4A99.tmp

其中绿色的为匹配域。

Step1. Define FP protocol.

l Click the plus sign before Add New Protocol.

l Take turns to input name and length of a field, and click OK to submit the field. (The fields are: Dmac (48bit), Smac (48bit), Eth Type (16bit), DIP (64bit), SIP (64bit), Protocol (16bit))

l Click SAVE and input name of the protocol (ETH + FP), and click SAVE to confirm the packet definition.

wps4A9A.tmp

Step2. Create First Flow Table.

l Click the box behind Switch, and choose the switch.

l Click the plus sign before Add New Table. Click FirstEntryTable, input “128” in Table Size. Choose “OF_MM_TABLE” in Table Type. Click Table Field and choose fields Dmacand Eth Type in protocol window, click SUBMIT to confirm. Click SUBMIT to submit the table.

Step3. Create FP Parse Flow Table.

l Click the plus sign before Add New Table, and click NewTable. Input “FP Parse Flow Table” in Table Name, input “128” in Table Size, choose “OF_MM_TABLE” in Table Type. Click Table Field and choose fields DIP, SIP and Protocol in protocol window, clickSUBMIT to confirm. Click SUBMIT to submit the table.

Step4. Create FP Flow Table.

l Click the plus sign before Add New Table, and click NewTable. Input “FP Flow Table” inTable Name, input “128” in Table Size, choose “OF_LPM_TABLE” in Table Type. ClickTable Field and choose fields DIP in protocol window, click SUBMIT to confirm. ClickSUBMIT to submit the table.

Step5. Configure FP Flow Table.

l Click FP Flow Table button to choose it.

l Click Flow Entry to create a new entry. Input “1” in Priority, input value and mask of each entry field (DIP: value = 0x1122334455667788, mask = 0xffffffffffffffff).

l Click New Instruction Item in Instruction, and choose APPLY_ACTIONS. ChooseSET_FIELD after clicking Add New Action. Choose Dmac in the FieldName, input mac address of the PC3’s port in Value and “0xffffffffffff” in Mask.

l Click Add New Action and choose SET_FIELD. Choose Smac in the line FieldName, input mac address of the PC2’s data port in Value and “0xffffffffffff” in Mask.

l Click Add New Action and choose SET_FIELD. Choose DIP in the line FieldName, input “0x8877665544332211” in Value and “0xffffffffffffffff” in Mask.

l Click Add New Action and choose SET_FIELD. Choose SIP in the line FieldName, input “0x1122334455667788” in Value and “0xffffffffffffffff” in Mask.

l Click New Instruction Item in Instruction, and choose APPLY_ACTIONS. Click Add New Action and choose OUTPUT. Choose the port index of PC2’s data port in output port ID. Click SUBMIT to confirm the configuration of the FP Flow Table. If you don’t know the data port’s index, click the green little tree sign at bottom right corner to check Port infomation.

Step6. Configure FP Parse Flow Table.

l Click FP Parse Flow Table button to choose it.

l Click Flow Entry to create a new entry. Input “1” in priority, input value and mask of each entry field (DIP: value = 0x0, mask = 0x0; SIP: value = 0x0, mask = 0x0; Protocol: value = 0x0901, mask = 0xffff).

l Click New Instruction Item in Instruction, and choose instruction GOTO_TABLE. Choose “FP Flow Table” in Next_TableID and input “0” in Packet Offset, click SUBMIT to confirm the configuration of the FP Parse Flow Table.

Step7. Configure First Flow Table.

l Click First Flow Table button to choose it.

l Click Flow Entry to create a new entry. Input “1” in priority, input value and mask of each entry field (Dmac: value = 0x0, mask = 0x0; Eth Type: value = 0x0888, mask = 0xffff).

l Click New Instruction Item in Instruction, and choose instruction GOTO_TABLE. Choose “FP Parse Flow Table” in Next_TableID and input “0” in Packet Offset, click SUBMIT to confirm the configuration of the FP Parse Flow Table.

Step8. Enable data port.

l Click the green little tree sign at bottom right corner to check Port infomation.

l All of the network ports of PC2 are shown in line. Find the data port, which connected to Server/Client (PC3), according to the port name listed in the fourth column name. ChooseTrue in the last column OpenFlow Enable in data port line.

Datapath的启用这点必不可少,不然是没有转发功能的。

首先点击右下方的绿色的树状按钮,然后点击port:

wps4AAB.tmp

在出现的这一栏数据的最后,即最右侧找到OpenFlow Enabled,鼠标左键点击,然后enter键:

wps4AAC.tmp

注:在step5 中有 一串高亮的红色数字0x8877665544332211,这里和官方配置文档不同。请注意。

(二)包构造、转发测试

Pc3 即server/client,用来构造测试包并且发送给switch,并且抓包分析。

1.进入系统后,打开ostinato和 wireshark。请注意一定要sudo打开,不然无法抓包。设置wireshark,点击capture->interfaces,然后选中eth0,点击start。

wps4ABC.tmp

2.在filter里输入如图所示过滤条件,点击apply。会发现抓取窗口变为空白:

wps4ABD.tmp

3.用ostinato构造数据包。选中port0,在右侧空白处右键->new stream.然后双击出来的红框内的设置按钮:

wps4ACE.tmpwps4ACF.tmp

4.选中 Protocol Selection 点击Advanced,选中MAC,并点击方框4内的按钮加到右边。同样的步骤,将EthII和 HexDump加到右边:

wps4AD0.tmp

5.选中 Protocol Data,点击Media AccessProtocol,依次在Destination和Source中输入相应的mac地址(Source为pc3即server/client的mac地址,Destination为pc2 即switch的mac地址):

wps4AE1.tmp

6.点击Ethernet II,在方框2中打勾,并输入内容为0888:

wps4AE2.tmp

7.点击HexDump,输入以下内容:112233445566778888776655443322110901:

wps4AF2.tmp

8.点击Packet View,预览下包结构,是否为:0x XX XX XX XX XX XX YY YY YY YY YY YY 08 88 11 22 33 44 55 66 77 88 88 77 66 55 44 33 22 11 09 01。点击ok。

wps4AF3.tmp

9.选中红框1中的port0-0,然后点击2框中的apply,然后点击3框中的开始发送。

在此用例中我们只发了一个构造的包:

wps4B04.tmp

(三)结果分析

此时打开刚才设置好的wireshark,会发现抓取了两个包,从Source和Destination的mac地址中我们可以看到,第一个包是我们从pc3发到pc2中的,第二个则是经过pc2的转发,回到pc3的。具体的包结构可以双击看到。此处不在赘述。若只有第一个包,则很大部分原因是你的流表配置错误,请去检查。

wps4B05.tmp

至此,整个用例测试完毕。当然,如果你理解了,在step5中我们完全可以按照官方文档来,但是你构造包的时候就得相应的改变。如需要,请留言邮箱

官方文档地址:http://www.poforwarding.org/tutorial/

posted @ 2014-12-01 20:21  山沟  阅读(1277)  评论(8编辑  收藏  举报