本文整理汇总了Java中org.openflow.protocol.OFMessage.getType方法的典型用法代码示例。如果您正苦于以下问题:Java OFMessage.getType方法的具体用法?Java OFMessage.getType怎么用?Java OFMessage.getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openflow.protocol.OFMessage
的用法示例。
在下文中一共展示了OFMessage.getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: receive
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg,
FloodlightContext cntx) {
switch (msg.getType()) {
case PACKET_IN:
IRoutingDecision decision = null;
if (cntx != null)
decision =
IRoutingDecision.rtStore.get(cntx,
IRoutingDecision.CONTEXT_DECISION);
return this.processPacketInMessage(sw,
(OFPacketIn) msg,
decision,
cntx);
default:
break;
}
return Command.CONTINUE;
}
示例2: receive
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public net.floodlightcontroller.core.IListener.Command receive(
IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
//do not process packet if not enabled
if (!this.enabled) {
return Command.CONTINUE;
}
//logger.debug("Message Recieved: Type - {}",msg.getType().toString());
//Listen for Packets that match Policies
switch (msg.getType()) {
case PACKET_IN:
//logger.debug("PACKET_IN recieved");
byte[] packetData = OFMessage.getData(sw, msg, cntx);
//Temporary match from packet to compare
OFMatch tmpMatch = new OFMatch();
tmpMatch.loadFromPacket(packetData, OFPort.OFPP_NONE.getValue());
checkIfQoSApplied(tmpMatch);
break;
default:
return Command.CONTINUE;
}
return Command.CONTINUE;
}
示例3: receive
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
switch (msg.getType()) {
case PACKET_IN:
return this.processPacketInMessage(sw, (OFPacketIn) msg, cntx);
case FLOW_REMOVED:
return this.processFlowRemovedMessage(sw, (OFFlowRemoved) msg);
case ERROR:
log.info("received an error {} from switch {}", msg, sw);
return Command.CONTINUE;
default:
break;
}
log.error("received an unexpected message {} from switch {}", msg, sw);
return Command.CONTINUE;
}
示例4: receive
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
if (!this.enabled)
return Command.CONTINUE;
switch (msg.getType()) {
case PACKET_IN:
IRoutingDecision decision = null;
if (cntx != null) {
decision = IRoutingDecision.rtStore.get(cntx,
IRoutingDecision.CONTEXT_DECISION);
return this.processPacketInMessage(sw, (OFPacketIn) msg,
decision, cntx);
}
break;
default:
break;
}
return Command.CONTINUE;
}
示例5: write
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public void write(OFMessage m, FloodlightContext bc) {
if (channel == null || !isConnected())
return;
//throws IOException {
Map<IOFSwitch,List<OFMessage>> msg_buffer_map = local_msg_buffer.get();
List<OFMessage> msg_buffer = msg_buffer_map.get(this);
if (msg_buffer == null) {
msg_buffer = new ArrayList<OFMessage>();
msg_buffer_map.put(this, msg_buffer);
}
this.floodlightProvider.handleOutgoingMessage(this, m, bc);
msg_buffer.add(m);
if ((msg_buffer.size() >= Controller.BATCH_MAX_SIZE) ||
((m.getType() != OFType.PACKET_OUT) && (m.getType() != OFType.FLOW_MOD))) {
this.write(msg_buffer);
msg_buffer.clear();
}
}
示例6: receive
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg,
FloodlightContext cntx) {
switch (msg.getType()) {
case PACKET_IN:
cntIncoming.updateCounterNoFlush();
return this.processPacketInMessage(sw,
(OFPacketIn) msg, cntx);
default:
break;
}
return Command.CONTINUE;
}
示例7: receive
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
switch (msg.getType()) {
case PACKET_IN:
return processPacketIn(sw, (OFPacketIn)msg, cntx);
default:
break;
}
log.warn("Received unexpected message {}", msg);
return Command.CONTINUE;
}
示例8: receive
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg,
FloodlightContext cntx) {
switch (msg.getType()) {
case PACKET_IN:
ctrIncoming.updateCounterNoFlush();
return this.handlePacketIn(sw.getId(), (OFPacketIn) msg,
cntx);
default:
break;
}
return Command.CONTINUE;
}
示例9: receive
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public net.floodlightcontroller.core.IListener.Command
receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
switch (msg.getType()) {
case PACKET_IN:
return processPacketIn(sw, (OFPacketIn)msg, cntx);
default:
break;
}
log.warn("Received unexpected message {}", msg);
return Command.CONTINUE;
}
示例10: receive
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
@LogMessageDoc(level="ERROR",
message="Got a FlowRemove message for a infinite " +
"timeout flow: {flow} from switch {switch}",
explanation="Flows with infinite timeouts should not expire. " +
"The switch has expired the flow anyway.",
recommendation=LogMessageDoc.REPORT_SWITCH_BUG)
public Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx) {
switch (msg.getType()) {
case FLOW_REMOVED:
return handleFlowRemoved(sw, (OFFlowRemoved) msg, cntx);
default:
return Command.CONTINUE;
}
}
示例11: receive
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
public Command receive(IOFSwitch sw, OFMessage msg,
FloodlightContext cntx) {
switch (msg.getType()) {
case PACKET_IN:
ctrIncoming.updateCounterNoFlush();
return this.processPacketInMessage(sw,
(OFPacketIn) msg, cntx);
default:
break;
}
return Command.CONTINUE;
}
示例12: processOFMessage
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
@Override
void processOFMessage(OFChannelHandler h, OFMessage m)
throws IOException {
if (m.getType() == OFType.ECHO_REQUEST)
processOFEchoRequest(h, (OFEchoRequest)m);
else {
// FIXME: other message to handle here?
h.sw.processDriverHandshakeMessage(m);
if (h.sw.isDriverHandshakeComplete()) {
h.gotoWaitInitialRoleState();
}
}
}
示例13: inputThrottled
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
/**
* Determine if this message should be dropped.
*
* We compute the current rate by taking a timestamp every 100 messages.
* Could change to a more complex scheme if more accuracy is needed.
*
* Enable throttling if the rate goes above packetInRateThresholdHigh
* Disable throttling when the rate drops below packetInRateThresholdLow
*
* While throttling is enabled, we do the following:
* - Remove duplicate packetIn's mapped to the same OFMatch
* - After filtering, if packetIn rate per host (mac) is above
* packetInRatePerMacThreshold, push a flow mod to block mac on port
* - After filtering, if packetIn rate per port is above
* packetInRatePerPortThreshold, push a flow mod to block port
* - Allow blocking flow mods have a hard timeout and expires automatically
*
* TODO: keep a history of all events related in input throttling
*
* @param ofm
* @return
*/
@Override
public boolean inputThrottled(OFMessage ofm) {
if (ofm.getType() != OFType.PACKET_IN) {
return false;
}
ctrSwitchPktin.updateCounterNoFlush();
// Compute current packet in rate
messageCount++;
if (messageCount % 1000 == 0) {
long now = System.currentTimeMillis();
if (now != lastMessageTime) {
currentRate = (int) (1000000 / (now - lastMessageTime));
lastMessageTime = now;
} else {
currentRate = Integer.MAX_VALUE;
}
}
if (!packetInThrottleEnabled) {
if (currentRate <= packetInRateThresholdHigh) {
return false; // most common case
}
enablePacketInThrottle();
} else if (currentRate < packetInRateThresholdLow) {
disablePacketInThrottle();
return false;
}
// Now we are in the slow path where we need to do filtering
// First filter based on OFMatch
OFPacketIn pin = (OFPacketIn)ofm;
OFMatch match = new OFMatch();
match.loadFromPacket(pin.getPacketData(), pin.getInPort());
if (ofMatchCache.update(match)) {
ctrSwitchPktinDrops.updateCounterNoFlush();
return true;
}
// We have packet in with a distinct flow, check per mac rate
messageCountUniqueOFMatch++;
if ((messageCountUniqueOFMatch % packetInRatePerMacThreshold) == 1) {
checkPerSourceMacRate(pin);
}
// Check per port rate
if ((messageCountUniqueOFMatch % packetInRatePerPortThreshold) == 1) {
checkPerPortRate(pin);
}
return false;
}
示例14: sendPacket
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
protected void sendPacket(HashSet<String> matchedFilters, IOFSwitch sw,
OFMessage msg, FloodlightContext cntx, boolean sync)
throws TException {
Message sendMsg = new Message();
Packet packet = new Packet();
ChannelBuffer bb;
sendMsg.setPacket(packet);
List<String> sids = new ArrayList<String>(matchedFilters);
sendMsg.setSessionIDs(sids);
packet.setMessageType(OFMessageType.findByValue((msg.getType().ordinal())));
switch (msg.getType()) {
case PACKET_IN:
OFPacketIn pktIn = (OFPacketIn)msg;
packet.setSwPortTuple(new SwitchPortTuple(sw.getId(),
pktIn.getInPort()));
bb = ChannelBuffers.buffer(pktIn.getLength());
pktIn.writeTo(bb);
packet.setData(OFMessage.getData(sw, msg, cntx));
break;
case PACKET_OUT:
OFPacketOut pktOut = (OFPacketOut)msg;
packet.setSwPortTuple(new SwitchPortTuple(sw.getId(),
pktOut.getInPort()));
bb = ChannelBuffers.buffer(pktOut.getLength());
pktOut.writeTo(bb);
packet.setData(OFMessage.getData(sw, msg, cntx));
break;
case FLOW_MOD:
OFFlowMod offlowMod = (OFFlowMod)msg;
packet.setSwPortTuple(new SwitchPortTuple(sw.getId(),
offlowMod.
getOutPort()));
bb = ChannelBuffers.buffer(offlowMod.getLength());
offlowMod.writeTo(bb);
packet.setData(OFMessage.getData(sw, msg, cntx));
break;
default:
packet.setSwPortTuple(new SwitchPortTuple(sw.getId(),
(short)0));
String strData = "Unknown packet";
packet.setData(strData.getBytes());
break;
}
try {
if (transport == null ||
!transport.isOpen() ||
packetClient == null) {
if (!connectToPSServer()) {
// No need to sendPacket if can't make connection to
// the server
return;
}
}
if (sync) {
log.debug("Send packet sync: {}", packet.toString());
packetClient.pushMessageSync(sendMsg);
} else {
log.debug("Send packet sync: ", packet.toString());
packetClient.pushMessageAsync(sendMsg);
}
} catch (Exception e) {
log.error("Error while sending packet", e);
disconnectFromPSServer();
connectToPSServer();
}
}
示例15: SwitchDriverSubHandshakeCompleted
import org.openflow.protocol.OFMessage; //导入方法依赖的package包/类
public SwitchDriverSubHandshakeCompleted(OFMessage m) {
super("Sub-Handshake is already complete but received message " +
m.getType());
}