2016-03-20 56 views
0

我正嘗試在Mininet中用負載平衡器構建一個簡單的拓撲。我正在使用交換機來代替Load Balancer。爲了執行負載均衡器的工作,我需要將目標IP修改爲其中一個服務器的IP。在OpenFlow控制器中修改操作

我無法修改傳入來做同樣的事情。任何人都可以幫我一樣嗎?還是有更好的方法來做到這一點?

提前致謝!

回答

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; 
    } 
+0

嘿!感謝你的回答。我發現了一個非常有用的ryu-starter-kit。 https://bitbucket.org/sdnhub/ryu-starter-kit/src –