我有一个胖树拓扑,我正在使用 Mininet、OpenFlow 1.3、Ryu 控制器来模拟基于 ECMP 的路由。我正在使用组和流表来执行此操作。例如,s2 和 s3 连接到聚合交换机的端口 1 和 2,例如 as1,其中安装了以下规则:
组表定义
# Create two actions that forwards packets to ports 1 and 2 that are connected to two core switches
action1 = sw.ofproto_parser.OFPActionOutput(1)
action2 = sw.ofproto_parser.OFPActionOutput(2)
# Specify two action sets (buckets), each with one action
bucket1 = sw.ofproto_parser.OFPBucket(weight=1, actions=[action1])
bucket2 = sw.ofproto_parser.OFPBucket(weight=1, actions=[action2])
# OFPGT_SELECT chooses between bucket1 and bucket2 based on
# some logic implemented in the switch, typically, round-robin?!
group_mod = sw.ofproto_parser.OFPGroupMod(
datapath=sw, command=ofp.OFPGC_ADD,
type_=ofp.OFPGT_SELECT, group_id=1,
buckets=[bucket1, bucket2])
sw.send_msg(group_mod)
在流表中安装组表操作
match = sw.ofproto_parser.OFPMatch(eth_type = \
0x0800)
action = sw.ofproto_parser.OFPActionGroup(1)
inst = [ofp_parser.OFPInstructionActions(
ofp.OFPIT_APPLY_ACTIONS, [action])]
mod = sw.ofproto_parser.OFPFlowMod(
datapath=sw, match=match, cookie=0, command=ofp.OFPFC_ADD,
idle_timeout=0, hard_timeout=0, priority=100,
flags=ofp.OFPFF_SEND_FLOW_REM, instructions=inst)
# Other flow entries rules are added here ...
我使用dpctl dump-flows
Mininet 中的命令确认了这一点。请注意,对于核心交换机 s2,n_packets = n_bytes = 0,而对于其他核心交换机 s3,情况并非如此:
*** s2 ------------------------------------------------------------------------
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=71.556s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=1200,ip,nw_dst=10.0.0.1 actions=output:1
cookie=0x0, duration=71.556s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=1200,ip,nw_dst=10.0.0.2 actions=output:1
cookie=0x0, duration=71.556s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=1200,ip,nw_dst=10.0.0.3 actions=output:1
cookie=0x0, duration=71.556s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=1200,ip,nw_dst=10.0.0.4 actions=output:1
cookie=0x0, duration=71.556s, table=0, n_packets=0, n_bytes=0, send_flow_rem priority=1200,ip,nw_dst=10.0.0.5 actions=output:2
.....对于核心交换机s3:
*** s3 ------------------------------------------------------------------------
OFPST_FLOW reply (OF1.3) (xid=0x2):
cookie=0x0, duration=71.582s, table=0, n_packets=4436, n_bytes=12043732, send_flow_rem priority=1200,ip,nw_dst=10.0.0.1 actions=output:1
cookie=0x0, duration=71.582s, table=0, n_packets=6306, n_bytes=11448184, send_flow_rem priority=1200,ip,nw_dst=10.0.0.2 actions=output:1
cookie=0x0, duration=71.582s, table=0, n_packets=870, n_bytes=1157688, send_flow_rem priority=1200,ip,nw_dst=10.0.0.3 actions=output:1
cookie=0x0, duration=71.582s, table=0, n_packets=674, n_bytes=644616, send_flow_rem priority=1200,ip,nw_dst=10.0.0.4 actions=output:1
cookie=0x0, duration=71.582s, table=0, n_packets=4475, n_bytes=11918478, send_flow_rem priority=1200,ip,nw_dst=10.0.0.5 actions=output:2
就像我在上面的评论中提到的那样,我相信 OFPGT_SELECT 基于交换机中实现的一些逻辑在 bucket1 和 bucket2 之间进行选择,比如循环?这似乎在拓扑中的较低级别交换机中运行良好,即,两个桶以相等的权重交替选择。但在顶部聚合交换机的情况下,始终只选择一条到核心交换机的路径(存储桶)。通常,所有数据包只选择第一个桶(端口)或最后一个桶(端口),但不会在两个桶之间交替!
但是,当给两个桶赋予不相等的权重(1 和 2)时,它确实有效。不确定权重相同的问题是什么。
任何帮助将不胜感激。谢谢!