修改simple_switch_13.py的程式碼

395 views
Skip to first unread message

吳昊穎

unread,
Apr 28, 2015, 3:11:17 AM4/28/15
to sdnd...@googlegroups.com
各位大大,有沒有人可以幫我解決以下問題

修改目的:希望OVS SWITCH 可以依照TCP封包的source port number貼上不同的802.1q的VLAN ID
我的修改方法:在simple_switch_13.py中修改_packet_in_handler()
1.為了能解析tcp封包,我加入這幾行
pkt_tcp = pkt.get_protocol(tcp.tcp)
if pkt_tcp:
 srcport = pkt_tcp.src_port
 desport = pkt_tcp.des_port

2.對switch下entry (pushvlan)
field = parser.OFMatchField.make(ofproto.OXM_OF_VLAN_VID,Vid)

match = parser.OFPMatch(tcp_src = srcport, in_port = in_port, ip_proto = 6, eth_type  = 0x0800)

actions =[ datapath.ofproto_parser.OFPActionPushVlan(0x8100), datapath.ofproto_parser.OFPActionSetField(Vid)]

self.add_flow(datapath,1,match,actions)

3.對switch下entry (popvlan)
  actions = [datapath.ofproto_parser.OFPActionPopVlan(ETH_TYPE_8021Q),parser.OFPActionOutput(out_port)]

  match = parser.OFPMatch(in_port=in_port, eth_dst=dst)

  self.add_flow(datapath, 2, match, actions)

附件為我的程式碼
請各位大大幫我看看我要怎麼修改才能達到我的實驗目的
目前遇到的問題
1.AttributeError: 'module' object has no attribute 'OFPMatchField'
2.entry無法正確地下到ovs中
program_vlan_tag.py

吳昊穎

unread,
Apr 28, 2015, 3:30:25 AM4/28/15
to sdnd...@googlegroups.com
(問題一)已解決....路徑問題
剩下問題二,無法下entry到ovs
謝謝

Ping Chun Huang

unread,
Apr 28, 2015, 4:57:28 AM4/28/15
to 吳昊穎, sdnd...@googlegroups.com
hi,

你是怎麼測試的,

可以把你測試的流程條列出來讓我們好 reproduce

感謝



pichuang, Ping-Chun Huang 黃秉鈞


Wireless Internet Laboratory
Computer Center, Department of Computer Science
National Chiao Tung University

(問題一)已解決....路徑問題
剩下問題二,無法下entry到ovs
謝謝
--
Welcome to http://sdnds.tw/
---
這是 Google 網上論壇針對「SDNDS-tw」群組發送的訂閱通知郵件。
如要取消訂閱這個群組並停止接收來自這個群組的郵件,請傳送電子郵件到 sdnds-tw+u...@googlegroups.com
如要在這個群組張貼留言,請傳送電子郵件到 sdnd...@googlegroups.com
請前往以下網址造訪這個群組:http://groups.google.com/group/sdnds-tw
如要在網路上查看這項討論,請造訪 https://groups.google.com/d/msgid/sdnds-tw/CAJXM0WUSmC7gQ8qeWFEB9Ry5z_CjNhRcYwTqfAyHS4E6ugLJug%40mail.gmail.com
如需更多選項,請前往:https://groups.google.com/d/optout

林哲緯

unread,
Apr 28, 2015, 12:43:22 PM4/28/15
to sdnd...@googlegroups.com, namea...@gmail.com
Hi 

無法下Flow entry 原因有很多種,可以貼一下他的 error message 嗎?


方便的話可以請你查查他的error message type 跟code的號碼 對應Spec上是什麼原因造成 Flow entry 寫不進去




吳昊穎於 2015年4月28日星期二 UTC+8下午3時11分17秒寫道:
Reply all
Reply to author
Forward
0 new messages