修改OpenFlow控制器中的操作

时间:2016-03-20 13:04:08

标签: mininet openflow sdn

我正在尝试使用负载均衡器在Mininet中构建一个简单的拓扑。我使用开关代替Load Balancer。我需要将目标IP修改为服务器的IP之一,以便执行负载均衡器的工作。

我无法修改传入来做同样的事情。任何人都可以帮我一样吗?或者有更好的方法吗?

提前致谢!

1 个答案:

答案 0 :(得分:0)

您需要编写包含匹配项和所需操作的Openflow消息。 匹配对于“检测”需要修改目标IP的数据包很有用。该操作必须是SET_FIELD操作。 这是一个关于如何使用OpenDaylight控制器(这种情况修改目标MAC地址)的简单示例:

public static Action createSetFieldDestinationMacAddress(int order, String macAddress) {

        Action action;
        ActionBuilder ab = new ActionBuilder();

        MacAddress address = MacAddress.getDefaultInstance(macAddress);
        EthernetDestination destination = new EthernetDestinationBuilder().setAddress(address).build();

        EthernetMatchBuilder builder = new EthernetMatchBuilder();
        builder.setEthernetDestination(destination);

        EthernetMatch ethernetMatch = builder.build();
        SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
        setFieldBuilder.setEthernetMatch(ethernetMatch);
        SetField setField = setFieldBuilder.build();
        org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action acction = new SetFieldCaseBuilder().
                setSetField(setField).build();
        ab.setOrder(order).setKey(new ActionKey(order)).setAction(acction);
        action = ab.build();
        return action;
    }
相关问题