本文整理汇总了Java中org.openflow.protocol.OFFlowMod.setHardTimeout方法的典型用法代码示例。如果您正苦于以下问题:Java OFFlowMod.setHardTimeout方法的具体用法?Java OFFlowMod.setHardTimeout怎么用?Java OFFlowMod.setHardTimeout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openflow.protocol.OFFlowMod
的用法示例。
在下文中一共展示了OFFlowMod.setHardTimeout方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkExpiredFlows
import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
public void checkExpiredFlows(){
log.debug("Checking for expired flows");
Iterator<FlowTimeout> it = this.timeouts.iterator();
while(it.hasNext()){
FlowTimeout timeout = it.next();
if(timeout.isExpired()){
log.debug("Removing Flow that has timed out");
it.remove();
OFFlowMod flow = timeout.getFlow();
flow.setOutPort(OFPort.OFPP_NONE);
flow.setCommand(OFFlowMod.OFPFC_DELETE_STRICT);
flow.setHardTimeout((short)0);
flow.setIdleTimeout((short)0);
flow.setFlags(OFFlowMod.OFPFF_SEND_FLOW_REM);
this.toSwitch((OFMessage) flow, timeout.getContext());
}
}
}
示例2: deleteFlow
import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
private void deleteFlow(Long switchId, OFFlowStatisticsReply flowStat){
List<IOFSwitch> switches = this.getSwitches();
for(IOFSwitch sw : switches){
if(sw.getId() == switchId){
OFFlowMod flowMod = new OFFlowMod();
flowMod.setMatch(flowStat.getMatch().clone());
flowMod.setIdleTimeout(flowStat.getIdleTimeout());
flowMod.setHardTimeout(flowStat.getHardTimeout());
flowMod.setCookie(flowStat.getCookie());
flowMod.setPriority(flowStat.getPriority());
flowMod.setCommand(OFFlowMod.OFPFC_DELETE_STRICT);
flowMod.setLengthU(OFFlowMod.MINIMUM_LENGTH);
flowMod.setXid(sw.getNextTransactionId());
List<OFMessage> msgs = new ArrayList<OFMessage>();
msgs.add((OFMessage)flowMod);
try {
sw.write(msgs, null);
} catch (IOException e) {
log.error("Error attempting to send flow delete for flow that fits in NO flowspace");
e.printStackTrace();
}
}
}
}
示例3: initDefaultFlowMod
import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
/**
* Sets defaults for an OFFlowMod
* @param fm The OFFlowMod to set defaults for
* @param entryName The name of the entry. Used to compute the cookie.
*/
public static void initDefaultFlowMod(OFFlowMod fm, String entryName) {
fm.setIdleTimeout((short) 0); // infinite
fm.setHardTimeout((short) 0); // infinite
fm.setBufferId(OFPacketOut.BUFFER_ID_NONE);
fm.setCommand((short) 0);
fm.setFlags((short) 0);
fm.setOutPort(OFPort.OFPP_NONE.getValue());
fm.setCookie(computeEntryCookie(fm, 0, entryName));
fm.setPriority(Short.MAX_VALUE);
}
示例4: init
import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
/**
* Adds flow for given switch, outgoing port, and DC switch port. Constructs {@link OFMatch} and instructs switch
* to send all packets from the given interface to dcPort interface
* @param sw
* @param floodlightProvider
* @param cntx
* @param dcPort
* @param inetPort
*/
public static void init(IOFSwitch sw, IFloodlightProviderService floodlightProvider, FloodlightContext cntx, short dcPort, short inetPort) {
logger.debug("init(IOFSwitch,IFloodlightProviderService,FloodlightContext,short OFPacketIn) begin");
//floodlightProvider.addOFMessageListener(OFType.PACKET_IN, this);
OFFlowMod flowMod = (OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
// Create new match
OFMatch match = new OFMatch();
match.setInputPort(inetPort);
match.setWildcards(OFMatch.OFPFW_ALL & ~OFMatch.OFPFW_IN_PORT);
flowMod.setMatch(match);
flowMod.setCommand(OFFlowMod.OFPFC_ADD);
flowMod.setIdleTimeout((short) 0);
flowMod.setHardTimeout((short) 0);
flowMod.setPriority((short) 10);
flowMod.setBufferId(OFPacketOut.BUFFER_ID_NONE);
flowMod.setFlags((short) 1);
List<OFAction> actions = new ArrayList<>();
actions.add(new OFActionOutput().setPort(dcPort));
flowMod.setActions(actions);
flowMod.setLengthU(OFFlowMod.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH);
logger.debug("Modyfing to rule {}", flowMod.toString());
try {
sw.write(flowMod, cntx);
sw.flush();
logger.debug(String.format("Added return rule from port %d to port %d (to switch %s)", inetPort, dcPort, sw.getStringId()));
} catch (IOException ex) {
logger.error(String.format("Error while adding return flow rule (in port %d, out port %d) to switch %s", inetPort, dcPort, sw.getStringId()), ex);
}
logger.debug("init(IOFSwitch,IFloodlightProviderService,FloodlightContext,short OFPacketIn) end");
}
示例5: mod
import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
/**
* Modifies particular flow rule in the switch {@link IOFSwitch}
* @param sw
* @param floodlightProvider
* @param cntx
* @param dcIP
* @param dcMask
* @param outPort
*/
public static void mod(IOFSwitch sw, IFloodlightProviderService floodlightProvider, FloodlightContext cntx, String dcIP, int dcMask, short outPort) {
logger.debug("mod(IOFSwitch,IFloodlightProviderService,FloodlightContext,String,int,short) begin");
OFFlowMod flowMod = (OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
OFMatch mTo = new OFMatch();
String match = "dl_type=0x800,nw_dst=" + dcIP + "/" + Integer.toString(dcMask);
mTo.fromString(match);
flowMod.setMatch(mTo);
flowMod.setCommand(OFFlowMod.OFPFC_MODIFY_STRICT); //OFPFC_MODIFY
flowMod.setIdleTimeout((short) 0);
flowMod.setHardTimeout((short) 0);
flowMod.setPriority((short) 100);
flowMod.setBufferId(OFPacketOut.BUFFER_ID_NONE);
flowMod.setFlags((short) 1);
List<OFAction> actions = new ArrayList<>();
actions.add(new OFActionOutput().setPort(outPort));
flowMod.setActions(actions);
flowMod.setLengthU(OFFlowMod.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH);
logger.debug("Modyfing to rule {}", flowMod.toString());
try {
sw.write(flowMod, cntx);
sw.flush();
logger.debug(String.format("Flow rule (out port %d) added to switch %s", outPort, sw.getStringId()));
} catch (IOException ex) {
logger.error(String.format("Error while modyfing flow rule (out port %d) to switch %s", outPort, sw.getStringId()), ex);
}
logger.debug("mod(IOFSwitch,IFloodlightProviderService,FloodlightContext,String,int,short) end");
}
示例6: buildFlowMod
import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
/**
* buildFlowMod - builds a FlowMod based on a flowStat
* @param flowStat
* @return OFFlowMod
*/
private OFFlowMod buildFlowMod(OFFlowStatisticsReply flowStat){
OFFlowMod flowMod = new OFFlowMod();
flowMod.setMatch(flowStat.getMatch().clone());
flowMod.setActions(flowStat.getActions());
flowMod.setPriority(flowStat.getPriority());
flowMod.setCookie(flowStat.getCookie());
flowMod.setIdleTimeout(flowStat.getIdleTimeout());
flowMod.setHardTimeout(flowStat.getHardTimeout());
return flowMod;
}
示例7: writeFlowMod
import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
/**
* Writes a OFFlowMod to a switch.
* @param sw The switch tow rite the flowmod to.
* @param command The FlowMod actions (add, delete, etc).
* @param bufferId The buffer ID if the switch has buffered the packet.
* @param match The OFMatch structure to write.
* @param outPort The switch port to output it to.
*/
private void writeFlowMod(IOFSwitch sw, short command, int bufferId,
OFMatch match, short outPort) {
// from openflow 1.0 spec - need to set these on a struct ofp_flow_mod:
// struct ofp_flow_mod {
// struct ofp_header header;
// struct ofp_match match; /* Fields to match */
// uint64_t cookie; /* Opaque controller-issued identifier. */
//
// /* Flow actions. */
// uint16_t command; /* One of OFPFC_*. */
// uint16_t idle_timeout; /* Idle time before discarding (seconds). */
// uint16_t hard_timeout; /* Max time before discarding (seconds). */
// uint16_t priority; /* Priority level of flow entry. */
// uint32_t buffer_id; /* Buffered packet to apply to (or -1).
// Not meaningful for OFPFC_DELETE*. */
// uint16_t out_port; /* For OFPFC_DELETE* commands, require
// matching entries to include this as an
// output port. A value of OFPP_NONE
// indicates no restriction. */
// uint16_t flags; /* One of OFPFF_*. */
// struct ofp_action_header actions[0]; /* The action length is inferred
// from the length field in the
// header. */
// };
OFFlowMod flowMod = (OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
flowMod.setMatch(match);
flowMod.setCookie(LearningSwitch.LEARNING_SWITCH_COOKIE);
flowMod.setCommand(command);
flowMod.setIdleTimeout(LearningSwitch.FLOWMOD_DEFAULT_IDLE_TIMEOUT);
flowMod.setHardTimeout(LearningSwitch.FLOWMOD_DEFAULT_HARD_TIMEOUT);
flowMod.setPriority(LearningSwitch.FLOWMOD_PRIORITY);
flowMod.setBufferId(bufferId);
flowMod.setOutPort((command == OFFlowMod.OFPFC_DELETE) ? outPort : OFPort.OFPP_NONE.getValue());
flowMod.setFlags((command == OFFlowMod.OFPFC_DELETE) ? 0 : (short) (1 << 0)); // OFPFF_SEND_FLOW_REM
// set the ofp_action_header/out actions:
// from the openflow 1.0 spec: need to set these on a struct ofp_action_output:
// uint16_t type; /* OFPAT_OUTPUT. */
// uint16_t len; /* Length is 8. */
// uint16_t port; /* Output port. */
// uint16_t max_len; /* Max length to send to controller. */
// type/len are set because it is OFActionOutput,
// and port, max_len are arguments to this constructor
flowMod.setActions(Arrays.asList((OFAction) new OFActionOutput(outPort, (short) 0xffff)));
flowMod.setLength((short) (OFFlowMod.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH));
if (log.isTraceEnabled()) {
log.trace("{} {} flow mod {}",
new Object[]{ sw, (command == OFFlowMod.OFPFC_DELETE) ? "deleting" : "adding", flowMod });
}
counterStore.updatePktOutFMCounterStoreLocal(sw, flowMod);
// and write it out
try {
sw.write(flowMod, null);
} catch (IOException e) {
log.error("Failed to write {} to switch {}", new Object[]{ flowMod, sw }, e);
}
}
示例8: writeFlowMod
import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
/**
* Writes a OFFlowMod to a switch.
* @param sw The switch tow rite the flowmod to.
* @param command The FlowMod actions (add, delete, etc).
* @param bufferId The buffer ID if the switch has buffered the packet.
* @param match The OFMatch structure to write.
* @param outPort The switch port to output it to.
*/
private void writeFlowMod(IOFSwitch sw, short command, int bufferId,
OFMatch match, short outPort) {
// from openflow 1.0 spec - need to set these on a struct ofp_flow_mod:
// struct ofp_flow_mod {
// struct ofp_header header;
// struct ofp_match match; /* Fields to match */
// uint64_t cookie; /* Opaque controller-issued identifier. */
//
// /* Flow actions. */
// uint16_t command; /* One of OFPFC_*. */
// uint16_t idle_timeout; /* Idle time before discarding (seconds). */
// uint16_t hard_timeout; /* Max time before discarding (seconds). */
// uint16_t priority; /* Priority level of flow entry. */
// uint32_t buffer_id; /* Buffered packet to apply to (or -1).
// Not meaningful for OFPFC_DELETE*. */
// uint16_t out_port; /* For OFPFC_DELETE* commands, require
// matching entries to include this as an
// output port. A value of OFPP_NONE
// indicates no restriction. */
// uint16_t flags; /* One of OFPFF_*. */
// struct ofp_action_header actions[0]; /* The action length is inferred
// from the length field in the
// header. */
// };
OFFlowMod flowMod = (OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
flowMod.setMatch(match);
flowMod.setCookie(LearningSwitch.LEARNING_SWITCH_COOKIE);
flowMod.setCommand(command);
flowMod.setIdleTimeout(LearningSwitch.IDLE_TIMEOUT_DEFAULT);
flowMod.setHardTimeout(LearningSwitch.HARD_TIMEOUT_DEFAULT);
flowMod.setPriority(LearningSwitch.PRIORITY_DEFAULT);
flowMod.setBufferId(bufferId);
flowMod.setOutPort((command == OFFlowMod.OFPFC_DELETE) ? outPort : OFPort.OFPP_NONE.getValue());
flowMod.setFlags((command == OFFlowMod.OFPFC_DELETE) ? 0 : (short) (1 << 0)); // OFPFF_SEND_FLOW_REM
// set the ofp_action_header/out actions:
// from the openflow 1.0 spec: need to set these on a struct ofp_action_output:
// uint16_t type; /* OFPAT_OUTPUT. */
// uint16_t len; /* Length is 8. */
// uint16_t port; /* Output port. */
// uint16_t max_len; /* Max length to send to controller. */
// type/len are set because it is OFActionOutput,
// and port, max_len are arguments to this constructor
flowMod.setActions(Arrays.asList((OFAction) new OFActionOutput(outPort, (short) 0xffff)));
flowMod.setLength((short) (OFFlowMod.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH));
if (log.isTraceEnabled()) {
log.trace("{} {} flow mod {}",
new Object[]{ sw, (command == OFFlowMod.OFPFC_DELETE) ? "deleting" : "adding", flowMod });
}
counterStore.updatePktOutFMCounterStore(sw, flowMod);
// and write it out
try {
sw.write(flowMod, null);
} catch (IOException e) {
log.error("Failed to write {} to switch {}", new Object[]{ flowMod, sw }, e);
}
}
开发者ID:vishalshubham,项目名称:Multipath-Hedera-system-in-Floodlight-controller,代码行数:70,代码来源:LearningSwitch.java
示例9: setDefaultRules
import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
private void setDefaultRules()//default rules
{
Iterator<Entry<Long, swInfo>> ite = color.entrySet().iterator();
while(ite.hasNext())
{
List<OFMessage> messages = new ArrayList<OFMessage>();//contain all default rules of a sw
Entry<Long, swInfo> entry = ite.next();
Long DPID = entry.getKey();
//Integer COLOR = entry.getValue().getCOLOR();
Iterator<Long> neighbor = entry.getValue().getNeighbors().iterator();
while(neighbor.hasNext())
{
Long neighbor_sw = neighbor.next();
Integer neighbor_color = color.get(neighbor_sw).getCOLOR();
//the default tag of (000) is reserved for the production traffic and is not used during the tag assignment process
OFMatch match = new OFMatch();
match.setDataLayerVirtualLanPriorityCodePoint(neighbor_color.byteValue());
match.setWildcards(~(OFMatch.OFPFW_DL_VLAN_PCP ));
OFFlowMod mod = (OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
mod.setMatch(match);
mod.setCommand(OFFlowMod.OFPFC_ADD);
mod.setIdleTimeout((short)0);
mod.setHardTimeout((short)0);
mod.setPriority((short)(32767));
mod.setBufferId(OFPacketOut.BUFFER_ID_NONE);
mod.setFlags((short)(1 << 0));
List<OFAction> actions = new ArrayList<OFAction>();
actions.add(new OFActionOutput(OFPort.OFPP_CONTROLLER.getValue(),(short)0xFFFF));
mod.setActions(actions);
mod.setLengthU(OFFlowMod.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH);
messages.add(mod);
}
//System.out.println(messages.size());
writeOFMessagesToSwitch(DPID, messages);
}
}
示例10: add
import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
/**
* Adds flow for given switch, outgoing port, and incoming packet.
* Constructs {@link OFMatch} from the incoming packet and instructs switch
* to send all packets from the flow to be sent to given outgoing port. The
* received packet is sent do switch for forwarding.
*
* @param sw swithc
* @param floodlightProvider Floodlight controller
* @param cntx Floodlight context
* @param outPort outgoing port
* @param pi incoming packet
*/
public static void add(IOFSwitch sw, IFloodlightProviderService floodlightProvider, FloodlightContext cntx, short outPort, OFPacketIn pi) {
logger.debug("add(IOFSwitch,IFloodlightProviderService,FloodlightContext,short OFPacketIn) begin");
OFFlowMod flowMod = (OFFlowMod) floodlightProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
// Parse the received packet
OFMatch match = new OFMatch();
match.loadFromPacket(pi.getPacketData(), pi.getInPort());
match.setWildcards(0);
flowMod.setMatch(match);
flowMod.setCommand(OFFlowMod.OFPFC_ADD);
flowMod.setIdleTimeout((short) 11);
flowMod.setHardTimeout((short) 0);
flowMod.setPriority((short) 50);
flowMod.setBufferId(OFPacketOut.BUFFER_ID_NONE);
flowMod.setFlags((short) 1);
List<OFAction> actions = new ArrayList<>();
actions.add(new OFActionOutput().setPort(outPort));
flowMod.setActions(actions);
flowMod.setLengthU(OFFlowMod.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH);
OFPacketOut po = (OFPacketOut) floodlightProvider.getOFMessageFactory().getMessage(OFType.PACKET_OUT);
po.setActions(actions);
po.setActionsLength((short) OFActionOutput.MINIMUM_LENGTH);
short poLength = (short) (po.getActionsLength() + OFPacketOut.MINIMUM_LENGTH);
po.setBufferId(pi.getBufferId());
po.setInPort(pi.getInPort());
if (pi.getBufferId() == OFPacketOut.BUFFER_ID_NONE) {
byte[] packetData = pi.getPacketData();
poLength += packetData.length;
po.setPacketData(packetData);
}
po.setLength(poLength);
List<OFMessage> msglist = new ArrayList<>();
msglist.add(flowMod);
msglist.add(po);
try {
sw.write(msglist, cntx);
sw.flush();
logger.debug(String.format("Flow rule (out port %d) added to switch %s", outPort, sw.getStringId()));
} catch (IOException ex) {
logger.error(String.format("Error while adding flow rule (out port %d) to switch %s", outPort, sw.getStringId()), ex);
}
logger.debug("add(IOFSwitch,IFloodlightProviderService,FloodlightContext,short OFPacketIn) end");
}
示例11: writeFlowMod
import org.openflow.protocol.OFFlowMod; //导入方法依赖的package包/类
/**
* Writes a OFFlowMod to a switch.
* @param sw The switch tow rite the flowmod to.
* @param command The FlowMod actions (add, delete, etc).
* @param bufferId The buffer ID if the switch has buffered the packet.
* @param match The OFMatch structure to write.
* @param outPort The switch port to output it to.
*/
private void writeFlowMod(IOFSwitch sw, short command, int bufferId,
OFMatch match, short outPort) {
// from openflow 1.0 spec - need to set these on a struct ofp_flow_mod:
// struct ofp_flow_mod {
// struct ofp_header header;
// struct ofp_match match; /* Fields to match */
// uint64_t cookie; /* Opaque controller-issued identifier. */
//
// /* Flow actions. */
// uint16_t command; /* One of OFPFC_*. */
// uint16_t idle_timeout; /* Idle time before discarding (seconds). */
// uint16_t hard_timeout; /* Max time before discarding (seconds). */
// uint16_t priority; /* Priority level of flow entry. */
// uint32_t buffer_id; /* Buffered packet to apply to (or -1).
// Not meaningful for OFPFC_DELETE*. */
// uint16_t out_port; /* For OFPFC_DELETE* commands, require
// matching entries to include this as an
// output port. A value of OFPP_NONE
// indicates no restriction. */
// uint16_t flags; /* One of OFPFF_*. */
// struct ofp_action_header actions[0]; /* The action length is inferred
// from the length field in the
// header. */
// };
OFFlowMod flowMod = (OFFlowMod) controllerProvider.getOFMessageFactory().getMessage(OFType.FLOW_MOD);
flowMod.setMatch(match);
flowMod.setCookie(LearningSwitch.LEARNING_SWITCH_COOKIE);
flowMod.setCommand(command);
flowMod.setIdleTimeout(LearningSwitch.FLOWMOD_DEFAULT_IDLE_TIMEOUT);
flowMod.setHardTimeout(LearningSwitch.FLOWMOD_DEFAULT_HARD_TIMEOUT);
flowMod.setPriority(LearningSwitch.FLOWMOD_PRIORITY);
flowMod.setBufferId(bufferId);
flowMod.setOutPort((command == OFFlowMod.OFPFC_DELETE) ? outPort : OFPort.OFPP_NONE.getValue());
flowMod.setFlags((command == OFFlowMod.OFPFC_DELETE) ? 0 : (short) (1 << 0)); // OFPFF_SEND_FLOW_REM
// set the ofp_action_header/out actions:
// from the openflow 1.0 spec: need to set these on a struct ofp_action_output:
// uint16_t type; /* OFPAT_OUTPUT. */
// uint16_t len; /* Length is 8. */
// uint16_t port; /* Output port. */
// uint16_t max_len; /* Max length to send to controller. */
// type/len are set because it is OFActionOutput,
// and port, max_len are arguments to this constructor
flowMod.setActions(Arrays.asList((OFAction) new OFActionOutput(outPort, (short) 0xffff)));
flowMod.setLength((short) (OFFlowMod.MINIMUM_LENGTH + OFActionOutput.MINIMUM_LENGTH));
if (log.isTraceEnabled()) {
log.trace("{} {} flow mod {}",
new Object[]{ sw, (command == OFFlowMod.OFPFC_DELETE) ? "deleting" : "adding", flowMod });
}
counterStore.updatePktOutFMCounterStore(sw, flowMod);
// and write it out
try {
sw.write(flowMod, null);
} catch (IOException e) {
log.error("Failed to write {} to switch {}", new Object[]{ flowMod, sw }, e);
}
}