本文整理汇总了Java中org.projectfloodlight.openflow.protocol.OFVersion.OF_13属性的典型用法代码示例。如果您正苦于以下问题:Java OFVersion.OF_13属性的具体用法?Java OFVersion.OF_13怎么用?Java OFVersion.OF_13使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.projectfloodlight.openflow.protocol.OFVersion
的用法示例。
在下文中一共展示了OFVersion.OF_13属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processOFEchoRequest
void processOFEchoRequest(OFChannelHandler h, OFEchoRequest m)
throws IOException {
if (h.ofVersion == null) {
log.error("No OF version set for {}. Not sending Echo REPLY",
h.channel.getRemoteAddress());
return;
}
OFFactory factory = (h.ofVersion == OFVersion.OF_13) ?
h.controller.getOFMessageFactory13() : h.controller.getOFMessageFactory10();
OFEchoReply reply = factory
.buildEchoReply()
.setXid(m.getXid())
.setData(m.getData())
.build();
h.channel.write(Collections.singletonList(reply));
}
示例2: testTDD
@Test
public void testTDD() throws Exception {
String controllerAddress = "kilda";
TransportPort controllerPort = TransportPort.of(6653);
OFVersion ofVersion = OFVersion.OF_13;
IMininetController controller = new MininetController()
.setIP(controllerAddress)
.setPort(controllerPort)
.setVersion(ofVersion)
.setName("floodlight")
.build();
IMininet mininet = new Mininet()
.addMininetServer(MININET_ADDRESS, MININET_PORT)
.clear()
.addController(controller)
.addSwitch("sw1", DatapathId.of(1))
.addSwitch("sw2", DatapathId.of(2))
.addLink("sw1", "sw2")
.build();
List<MininetSwitch> switches = mininet.switches().getSwitches();
assertEquals("failure - should have exactly 2 switches", 2, switches.size());
Thread.sleep(MAX_CONNECT_TIME);
switches = mininet.switches().getSwitches();
for(MininetSwitch sw: switches) {
assertTrue(String.format("failure - %s should be connected", sw.getName()), sw.getConnected());
}
List<MininetLink> links = mininet.links().getLinks();
for(MininetLink link: links) {
assertTrue(String.format("failure - %s should be up", link.getName()), link.isUp());
}
}
示例3: processOFHello
@Override
void processOFHello(OFChannelHandler h, OFHello m)
throws IOException {
// TODO We could check for the optional bitmap, but for now
// we are just checking the version number.
if (m.getVersion().getWireVersion() >= OFVersion.OF_13.getWireVersion()) {
log.debug("Received {} Hello from {} - switching to OF "
+ "version 1.3", m.getVersion(),
h.channel.getRemoteAddress());
h.sendHandshakeHelloMessage();
h.ofVersion = OFVersion.OF_13;
} else if (m.getVersion().getWireVersion() >= OFVersion.OF_10.getWireVersion()) {
log.debug("Received {} Hello from {} - switching to OF "
+ "version 1.0", m.getVersion(),
h.channel.getRemoteAddress());
OFHello hi =
h.factory10.buildHello()
.setXid(h.handshakeTransactionIds--)
.build();
h.channel.write(Collections.singletonList(hi));
h.ofVersion = OFVersion.OF_10;
} else {
log.error("Received Hello of version {} from switch at {}. "
+ "This controller works with OF1.0 and OF1.3 "
+ "switches. Disconnecting switch ...",
m.getVersion(), h.channel.getRemoteAddress());
h.channel.disconnect();
return;
}
h.sendHandshakeFeaturesRequestMessage();
h.setState(WAIT_FEATURES_REPLY);
}
示例4: channelIdle
@Override
public void channelIdle(ChannelHandlerContext ctx, IdleStateEvent e)
throws Exception {
OFFactory factory = (ofVersion == OFVersion.OF_13) ? factory13 : factory10;
OFMessage m = factory.buildEchoRequest().build();
log.debug("Sending Echo Request on idle channel: {}",
e.getChannel().getPipeline().getLast().toString());
e.getChannel().write(Collections.singletonList(m));
// XXX S some problems here -- echo request has no transaction id, and
// echo reply is not correlated to the echo request.
}
示例5: sendHandshakeFeaturesRequestMessage
/**
* Send featuresRequest msg to the switch using the handshake transactions ids.
* @throws IOException
*/
private void sendHandshakeFeaturesRequestMessage() throws IOException {
OFFactory factory = (ofVersion == OFVersion.OF_13) ? factory13 : factory10;
OFMessage m = factory.buildFeaturesRequest()
.setXid(this.handshakeTransactionIds--)
.build();
channel.write(Collections.singletonList(m));
}
示例6: sendHandshakeSetConfig
/**
* Send the configuration requests to tell the switch we want full
* packets.
* @throws IOException
*/
private void sendHandshakeSetConfig() throws IOException {
OFFactory factory = (ofVersion == OFVersion.OF_13) ? factory13 : factory10;
//log.debug("Sending CONFIG_REQUEST to {}", channel.getRemoteAddress());
List<OFMessage> msglist = new ArrayList<OFMessage>(3);
// Ensure we receive the full packet via PacketIn
// FIXME: We don't set the reassembly flags.
// Only send config to switches to send full packets, if they have a buffer.
// Saves a packet & OFSetConfig can't be handled by certain switches.
if(this.featuresReply.getNBuffers() > 0) {
OFSetConfig sc = factory
.buildSetConfig()
.setMissSendLen((short) 0xffff)
.setXid(this.handshakeTransactionIds--)
.build();
msglist.add(sc);
}
// Barrier
OFBarrierRequest br = factory
.buildBarrierRequest()
.setXid(this.handshakeTransactionIds--)
.build();
msglist.add(br);
// Verify (need barrier?)
OFGetConfigRequest gcr = factory
.buildGetConfigRequest()
.setXid(this.handshakeTransactionIds--)
.build();
msglist.add(gcr);
channel.write(msglist);
}
示例7: sendHandshakeDescriptionStatsRequest
/**
* send a description state request.
* @throws IOException
*/
private void sendHandshakeDescriptionStatsRequest() throws IOException {
// Get Description to set switch-specific flags
OFFactory factory = (ofVersion == OFVersion.OF_13) ? factory13 : factory10;
OFDescStatsRequest dreq = factory
.buildDescStatsRequest()
.setXid(handshakeTransactionIds--)
.build();
channel.write(Collections.singletonList(dreq));
}
示例8: buildPortDescription
/**
* Build a portDescription from a given a port description describing some
* Optical port.
*
* @param port description property type.
* @param port the port to build from.
* @return portDescription for the port.
*/
private PortDescription buildPortDescription(PortDescPropertyType ptype, OFPortOptical port) {
checkArgument(port.getDesc().size() >= 1);
// Minimally functional fixture. This needs to be fixed as we add better support.
PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN)
&& !port.getConfig().contains(OFPortConfig.PORT_DOWN);
SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString());
if (port.getVersion() == OFVersion.OF_13
&& ptype == PortDescPropertyType.OPTICAL_TRANSPORT) {
// At this point, not much is carried in the optical port message.
LOG.debug("Optical transport port message {}", port.toString());
} else {
// removable once 1.4+ support complete.
LOG.debug("Unsupported optical port properties");
}
OFPortDescPropOpticalTransport desc = port.getDesc().get(0);
switch (desc.getPortSignalType()) {
// FIXME: use constants once loxi has full optical extensions
case 2: // OMS port
// Assume complete optical spectrum and 50 GHz grid
// LINC-OE is only supported optical OF device for now
return omsPortDescription(portNo, enabled,
Spectrum.U_BAND_MIN, Spectrum.O_BAND_MAX, Frequency.ofGHz(50), annotations);
case 5: // OCH port
OchSignal signal = new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, 0, 4);
return ochPortDescription(portNo, enabled, OduSignalType.ODU4,
true, signal, annotations);
default:
break;
}
return new DefaultPortDescription(portNo, enabled, FIBER, 0, annotations);
}
示例9: packetInProcess
@Override
public void packetInProcess(Dpid dpid, OFPacketIn packetIn, OpenFlowPacketContext pktCtx) {
//exclude abnormal packet -- Jinwoo Kim
//only store ipv4 packet to DB
try {
short etherType = convertPacketContextToInboundPacket(pktCtx).parsed().getEtherType();
if (etherType != 2048) {
return;
}
} catch (Exception e) {
log.error(e.toString());
}
InboundPacket ip = convertPacketContextToInboundPacket(pktCtx);
PacketInFeature pif = new PacketInFeature();
UnitPacketInInformation ufii;
Date date = new java.sql.Timestamp(Calendar.getInstance().getTime().getTime());
if (packetIn.getVersion() == OFVersion.OF_13) {
FeatureIndex pfi = matchToFeatureIndex(packetIn.getMatch());
pfi = extractElementsFromInboundPkt(pfi, ip);
ufii = new UnitPacketInInformation(packetIn.getTotalLen(),
packetIn.getReason().ordinal(), pfi);
// in case of OF_10, just store dummy match value
// Jinwoo kim
} else {
ufii = new UnitPacketInInformation();
// return;
}
ufii.setDate(date);
FeatureIndex fi = new FeatureIndex();
fi.setSwitchDatapathId(dpid.value());
fi.setSwitchPortId(toIntExact(ip.receivedFrom().port().toLong()));
pif.addFeatureData(fi, ufii);
providerService.packetInFeatureHandler(pif);
}
示例10: serializeGroupReply
/***
* Serializes the Group Statistics Reply
* @author Naveen
* @param groupReplies
* @param jGen
* @throws IOException
* @throws JsonProcessingException
*/
public static void serializeGroupReply(List<OFGroupStatsReply> groupReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
OFGroupStatsReply groupReply = groupReplies.get(0); // we will get only one GroupReply and it will contains many OFGroupStatsEntry
jGen.writeStringField("version", groupReply.getVersion().toString()); //return the enum name
jGen.writeFieldName("group");
jGen.writeStartArray();
for(OFGroupStatsEntry entry : groupReply.getEntries()) {
jGen.writeStartObject();
jGen.writeStringField("groupNumber",entry.getGroup().toString());
jGen.writeNumberField("refCount", entry.getRefCount());
jGen.writeNumberField("packetCount", entry.getPacketCount().getValue());
jGen.writeNumberField("byteCount", entry.getByteCount().getValue());
jGen.writeFieldName("bucketCounters");
jGen.writeStartArray();
for(OFBucketCounter bCounter : entry.getBucketStats()) {
jGen.writeStartObject();
jGen.writeNumberField("packetCount", bCounter.getPacketCount().getValue());
jGen.writeNumberField("byteCount", bCounter.getByteCount().getValue());
jGen.writeEndObject();
}//end of for loop - BucketCounter
jGen.writeEndArray();
if (OFVersion.OF_13 == entry.getVersion()) {
jGen.writeNumberField("durationSec", entry.getDurationSec());
jGen.writeNumberField("durationNsec", entry.getDurationNsec());
}
jGen.writeEndObject();
}//end of for loop - groupStats
jGen.writeEndArray();
}
示例11: serializePortReply
public static void serializePortReply(List<OFPortStatsReply> portReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
jGen.writeFieldName("port_reply");
jGen.writeStartArray();
for (OFPortStatsReply portReply : portReplies) {
jGen.writeStartObject();
jGen.writeStringField("version", portReply.getVersion().toString()); //return the enum name
jGen.writeFieldName("port");
jGen.writeStartArray();
for(OFPortStatsEntry entry : portReply.getEntries()) {
jGen.writeStartObject();
jGen.writeStringField("portNumber",entry.getPortNo().toString());
jGen.writeNumberField("receivePackets", entry.getRxPackets().getValue());
jGen.writeNumberField("transmitPackets", entry.getTxPackets().getValue());
jGen.writeNumberField("receiveBytes", entry.getRxBytes().getValue());
jGen.writeNumberField("transmitBytes", entry.getTxBytes().getValue());
jGen.writeNumberField("receiveDropped", entry.getRxDropped().getValue());
jGen.writeNumberField("transmitDropped", entry.getTxDropped().getValue());
jGen.writeNumberField("receiveErrors", entry.getRxErrors().getValue());
jGen.writeNumberField("transmitErrors", entry.getTxErrors().getValue());
jGen.writeNumberField("receiveFrameErrors", entry.getRxFrameErr().getValue());
jGen.writeNumberField("receiveOverrunErrors", entry.getRxOverErr().getValue());
jGen.writeNumberField("receiveCRCErrors", entry.getRxCrcErr().getValue());
jGen.writeNumberField("collisions", entry.getCollisions().getValue());
if (OFVersion.OF_13 == entry.getVersion()) {
jGen.writeNumberField("durationSec", entry.getDurationSec());
jGen.writeNumberField("durationNsec", entry.getDurationNsec());
}
jGen.writeEndObject();
}
jGen.writeEndArray();
jGen.writeEndObject();
}
jGen.writeEndArray();
}
示例12: serializePortReply
public static void serializePortReply(List<OFPortStatsReply> portReplies, JsonGenerator jGen) throws IOException, JsonProcessingException{
OFPortStatsReply portReply = portReplies.get(0); // we will get only one PortReply and it will contains many OFPortStatsEntry ?
jGen.writeStringField("version", portReply.getVersion().toString()); //return the enum name
jGen.writeFieldName("port");
jGen.writeStartArray();
for(OFPortStatsEntry entry : portReply.getEntries()) {
jGen.writeStartObject();
jGen.writeStringField("portNumber",entry.getPortNo().toString());
jGen.writeNumberField("receivePackets", entry.getRxPackets().getValue());
jGen.writeNumberField("transmitPackets", entry.getTxPackets().getValue());
jGen.writeNumberField("receiveBytes", entry.getRxBytes().getValue());
jGen.writeNumberField("transmitBytes", entry.getTxBytes().getValue());
jGen.writeNumberField("receiveDropped", entry.getRxDropped().getValue());
jGen.writeNumberField("transmitDropped", entry.getTxDropped().getValue());
jGen.writeNumberField("receiveErrors", entry.getRxErrors().getValue());
jGen.writeNumberField("transmitErrors", entry.getTxErrors().getValue());
jGen.writeNumberField("receiveFrameErrors", entry.getRxFrameErr().getValue());
jGen.writeNumberField("receiveOverrunErrors", entry.getRxOverErr().getValue());
jGen.writeNumberField("receiveCRCErrors", entry.getRxCrcErr().getValue());
jGen.writeNumberField("collisions", entry.getCollisions().getValue());
if (OFVersion.OF_13 == entry.getVersion()) {
jGen.writeNumberField("durationSec", entry.getDurationSec());
jGen.writeNumberField("durationNsec", entry.getDurationNsec());
}
jGen.writeEndObject();
}
jGen.writeEndArray();
}