在 OpenFlow 控制器中修改操作



我正在尝试使用负载均衡器在 Mininet 中构建一个简单的拓扑。我正在使用交换机代替负载均衡器。我需要将目标 IP 修改为服务器的一个 IP 才能执行负载均衡器的工作。

我无法修改传入以执行相同的操作。任何人都可以帮我做同样的事情吗?或者有更好的方法可以做到这一点吗?

提前感谢!

您需要编写包含匹配项和所需操作的 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;
    }

最新更新