Praseed Balakrishnan

Discover LINC-OE switch and ports.

...@@ -9,7 +9,7 @@ public interface Device extends Element { ...@@ -9,7 +9,7 @@ public interface Device extends Element {
9 * Coarse classification of the type of the infrastructure device. 9 * Coarse classification of the type of the infrastructure device.
10 */ 10 */
11 public enum Type { 11 public enum Type {
12 - SWITCH, ROUTER, FIREWALL, BALANCER, IPS, IDS, CONTROLLER, OTHER 12 + SWITCH, ROUTER, ROADM, FIREWALL, BALANCER, IPS, IDS, CONTROLLER, OTHER
13 } 13 }
14 14
15 /** 15 /**
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
30 <groupId>org.projectfloodlight</groupId> 30 <groupId>org.projectfloodlight</groupId>
31 <artifactId>openflowj</artifactId> 31 <artifactId>openflowj</artifactId>
32 <!-- FIXME once experimenter gets merged to upstream --> 32 <!-- FIXME once experimenter gets merged to upstream -->
33 - <version>0.3.8-optical_experimenter2</version> 33 + <version>0.3.8-optical_experimenter3</version>
34 </dependency> 34 </dependency>
35 <dependency> 35 <dependency>
36 <groupId>io.netty</groupId> 36 <groupId>io.netty</groupId>
......
...@@ -112,4 +112,13 @@ public interface OpenFlowSwitch { ...@@ -112,4 +112,13 @@ public interface OpenFlowSwitch {
112 */ 112 */
113 void returnRoleAssertFailure(RoleState role); 113 void returnRoleAssertFailure(RoleState role);
114 114
115 +
116 + /**
117 + * Indicates if this switch is optical.
118 + *
119 + * @return true if optical
120 + */
121 + public boolean isOptical();
122 +
123 +
115 } 124 }
......
...@@ -374,4 +374,9 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver { ...@@ -374,4 +374,9 @@ public abstract class AbstractOpenFlowSwitch implements OpenFlowSwitchDriver {
374 return this.desc.getSerialNum(); 374 return this.desc.getSerialNum();
375 } 375 }
376 376
377 + @Override
378 + public boolean isOptical() {
379 + return false;
380 + }
381 +
377 } 382 }
......
...@@ -399,12 +399,12 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -399,12 +399,12 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
399 h.sw.setPortDescReply(h.portDescReply); 399 h.sw.setPortDescReply(h.portDescReply);
400 h.sw.setConnected(true); 400 h.sw.setConnected(true);
401 h.sw.setChannel(h.channel); 401 h.sw.setChannel(h.channel);
402 - boolean success = h.sw.connectSwitch(); 402 +// boolean success = h.sw.connectSwitch();
403 - 403 +//
404 - if (!success) { 404 +// if (!success) {
405 - disconnectDuplicate(h); 405 +// disconnectDuplicate(h);
406 - return; 406 +// return;
407 - } 407 +// }
408 // set switch information 408 // set switch information
409 409
410 410
...@@ -462,6 +462,8 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -462,6 +462,8 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
462 throws IOException, SwitchStateException { 462 throws IOException, SwitchStateException {
463 if (m.getType() == OFType.ECHO_REQUEST) { 463 if (m.getType() == OFType.ECHO_REQUEST) {
464 processOFEchoRequest(h, (OFEchoRequest) m); 464 processOFEchoRequest(h, (OFEchoRequest) m);
465 + } else if (m.getType() == OFType.ECHO_REPLY) {
466 + processOFEchoReply(h, (OFEchoReply) m);
465 } else if (m.getType() == OFType.ROLE_REPLY) { 467 } else if (m.getType() == OFType.ROLE_REPLY) {
466 h.sw.handleRole(m); 468 h.sw.handleRole(m);
467 } else if (m.getType() == OFType.ERROR) { 469 } else if (m.getType() == OFType.ERROR) {
...@@ -479,6 +481,12 @@ class OFChannelHandler extends IdleStateAwareChannelHandler { ...@@ -479,6 +481,12 @@ class OFChannelHandler extends IdleStateAwareChannelHandler {
479 } else { 481 } else {
480 h.sw.processDriverHandshakeMessage(m); 482 h.sw.processDriverHandshakeMessage(m);
481 if (h.sw.isDriverHandshakeComplete()) { 483 if (h.sw.isDriverHandshakeComplete()) {
484 + boolean success = h.sw.connectSwitch();
485 +
486 + if (!success) {
487 + disconnectDuplicate(h);
488 + return;
489 + }
482 h.setState(ACTIVE); 490 h.setState(ACTIVE);
483 } 491 }
484 } 492 }
......
...@@ -59,7 +59,7 @@ public final class DriverManager implements OpenFlowSwitchDriverFactory { ...@@ -59,7 +59,7 @@ public final class DriverManager implements OpenFlowSwitchDriverFactory {
59 59
60 String sw = desc.getSwDesc(); 60 String sw = desc.getSwDesc();
61 if (sw.startsWith("LINC-OE")) { 61 if (sw.startsWith("LINC-OE")) {
62 - log.debug("Optical Emulator LINC-OE with DPID:{} found..", dpid); 62 + log.warn("Optical Emulator LINC-OE with DPID:{} found..", dpid);
63 return new OFOpticalSwitchImplLINC13(dpid, desc); 63 return new OFOpticalSwitchImplLINC13(dpid, desc);
64 } 64 }
65 65
......
...@@ -6,6 +6,7 @@ import org.onlab.onos.openflow.controller.driver.SwitchDriverSubHandshakeNotStar ...@@ -6,6 +6,7 @@ import org.onlab.onos.openflow.controller.driver.SwitchDriverSubHandshakeNotStar
6 import org.onlab.onos.openflow.controller.Dpid; 6 import org.onlab.onos.openflow.controller.Dpid;
7 import org.onlab.onos.openflow.controller.driver.AbstractOpenFlowSwitch; 7 import org.onlab.onos.openflow.controller.driver.AbstractOpenFlowSwitch;
8 import org.projectfloodlight.openflow.protocol.OFBarrierRequest; 8 import org.projectfloodlight.openflow.protocol.OFBarrierRequest;
9 +import org.projectfloodlight.openflow.protocol.OFCircuitPortStatus;
9 import org.projectfloodlight.openflow.protocol.OFCircuitPortsReply; 10 import org.projectfloodlight.openflow.protocol.OFCircuitPortsReply;
10 import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest; 11 import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest;
11 import org.projectfloodlight.openflow.protocol.OFDescStatsReply; 12 import org.projectfloodlight.openflow.protocol.OFDescStatsReply;
...@@ -14,7 +15,10 @@ import org.projectfloodlight.openflow.protocol.OFMatchV3; ...@@ -14,7 +15,10 @@ import org.projectfloodlight.openflow.protocol.OFMatchV3;
14 import org.projectfloodlight.openflow.protocol.OFMessage; 15 import org.projectfloodlight.openflow.protocol.OFMessage;
15 import org.projectfloodlight.openflow.protocol.OFOxmList; 16 import org.projectfloodlight.openflow.protocol.OFOxmList;
16 import org.projectfloodlight.openflow.protocol.OFPortDesc; 17 import org.projectfloodlight.openflow.protocol.OFPortDesc;
18 +import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
17 import org.projectfloodlight.openflow.protocol.OFPortOptical; 19 import org.projectfloodlight.openflow.protocol.OFPortOptical;
20 +import org.projectfloodlight.openflow.protocol.OFStatsReply;
21 +import org.projectfloodlight.openflow.protocol.OFStatsType;
18 import org.projectfloodlight.openflow.protocol.action.OFAction; 22 import org.projectfloodlight.openflow.protocol.action.OFAction;
19 import org.projectfloodlight.openflow.protocol.action.OFActionCircuit; 23 import org.projectfloodlight.openflow.protocol.action.OFActionCircuit;
20 import org.projectfloodlight.openflow.protocol.instruction.OFInstruction; 24 import org.projectfloodlight.openflow.protocol.instruction.OFInstruction;
...@@ -43,12 +47,13 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { ...@@ -43,12 +47,13 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
43 private final AtomicBoolean driverHandshakeComplete; 47 private final AtomicBoolean driverHandshakeComplete;
44 private long barrierXidToWaitFor = -1; 48 private long barrierXidToWaitFor = -1;
45 49
50 + private OFPortDescStatsReply wPorts;
51 +
46 private final Logger log = 52 private final Logger log =
47 LoggerFactory.getLogger(OFOpticalSwitchImplLINC13.class); 53 LoggerFactory.getLogger(OFOpticalSwitchImplLINC13.class);
48 54
49 OFOpticalSwitchImplLINC13(Dpid dpid, OFDescStatsReply desc) { 55 OFOpticalSwitchImplLINC13(Dpid dpid, OFDescStatsReply desc) {
50 super(dpid); 56 super(dpid);
51 - //setAttribute("optical", "true");
52 driverHandshakeComplete = new AtomicBoolean(false); 57 driverHandshakeComplete = new AtomicBoolean(false);
53 setSwitchDescription(desc); 58 setSwitchDescription(desc);
54 } 59 }
...@@ -62,7 +67,7 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { ...@@ -62,7 +67,7 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
62 67
63 @Override 68 @Override
64 public void startDriverHandshake() { 69 public void startDriverHandshake() {
65 - log.debug("Starting driver handshake for sw {}", getStringId()); 70 + log.warn("Starting driver handshake for sw {}", getStringId());
66 if (startDriverHandshakeCalled) { 71 if (startDriverHandshakeCalled) {
67 throw new SwitchDriverSubHandshakeAlreadyStarted(); 72 throw new SwitchDriverSubHandshakeAlreadyStarted();
68 } 73 }
...@@ -70,6 +75,8 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { ...@@ -70,6 +75,8 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
70 try { 75 try {
71 sendHandshakeOFExperimenterPortDescRequest(); 76 sendHandshakeOFExperimenterPortDescRequest();
72 } catch (IOException e) { 77 } catch (IOException e) {
78 + log.error("LINC-OE exception while sending experimenter port desc:",
79 + e.getMessage());
73 e.printStackTrace(); 80 e.printStackTrace();
74 } 81 }
75 } 82 }
...@@ -109,25 +116,30 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { ...@@ -109,25 +116,30 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
109 case PACKET_IN: 116 case PACKET_IN:
110 break; 117 break;
111 case PORT_STATUS: 118 case PORT_STATUS:
119 + log.warn("****LINC-OE Port Status {} {}", getStringId(), m);
120 + processOFPortStatus((OFCircuitPortStatus) m);
112 break; 121 break;
113 case QUEUE_GET_CONFIG_REPLY: 122 case QUEUE_GET_CONFIG_REPLY:
114 break; 123 break;
115 case ROLE_REPLY: 124 case ROLE_REPLY:
116 break; 125 break;
117 case STATS_REPLY: 126 case STATS_REPLY:
118 - log.debug("LINC-OE : Received stats reply message {}", m); 127 + OFStatsReply stats = (OFStatsReply) m;
128 + if (stats.getStatsType() == OFStatsType.EXPERIMENTER) {
129 + log.warn("LINC-OE : Received stats reply message {}", m);
119 processHandshakeOFExperimenterPortDescRequest( 130 processHandshakeOFExperimenterPortDescRequest(
120 (OFCircuitPortsReply) m); 131 (OFCircuitPortsReply) m);
121 driverHandshakeComplete.set(true); 132 driverHandshakeComplete.set(true);
122 - try { 133 + }
134 + /*try {
123 testMA(); 135 testMA();
124 testReverseMA(); 136 testReverseMA();
125 } catch (IOException e) { 137 } catch (IOException e) {
126 e.printStackTrace(); 138 e.printStackTrace();
127 - } 139 + }*/
128 break; 140 break;
129 default: 141 default:
130 - log.debug("Received message {} during switch-driver " + 142 + log.warn("Received message {} during switch-driver " +
131 "subhandshake " + "from switch {} ... " + 143 "subhandshake " + "from switch {} ... " +
132 "Ignoring message", m, 144 "Ignoring message", m,
133 getStringId()); 145 getStringId());
...@@ -135,12 +147,18 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { ...@@ -135,12 +147,18 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
135 } 147 }
136 } 148 }
137 149
150 + //Todo
151 + public void processOFPortStatus(OFCircuitPortStatus ps) {
152 + log.debug("LINC-OE ..OF Port Status :", ps);
153 +
154 + }
138 155
139 private void processHandshakeOFExperimenterPortDescRequest( 156 private void processHandshakeOFExperimenterPortDescRequest(
140 OFCircuitPortsReply sr) { 157 OFCircuitPortsReply sr) {
141 Collection<OFPortOptical> entries = sr.getEntries(); 158 Collection<OFPortOptical> entries = sr.getEntries();
142 List<OFPortDesc> ofPortDescList = new ArrayList<>(entries.size()); 159 List<OFPortDesc> ofPortDescList = new ArrayList<>(entries.size());
143 for (OFPortOptical entry : entries) { 160 for (OFPortOptical entry : entries) {
161 + log.warn("LINC:OE port message {}", entry.toString());
144 ofPortDescList.add(factory().buildPortDesc(). 162 ofPortDescList.add(factory().buildPortDesc().
145 setPortNo(entry.getPortNo()) 163 setPortNo(entry.getPortNo())
146 .setConfig(entry.getConfig()) 164 .setConfig(entry.getConfig())
...@@ -148,11 +166,16 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { ...@@ -148,11 +166,16 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
148 .setHwAddr(entry.getHwAddr()) 166 .setHwAddr(entry.getHwAddr())
149 .setName(entry.getName()) 167 .setName(entry.getName())
150 .build()); 168 .build());
169 +
151 } 170 }
152 - setPortDescReply(factory().buildPortDescStatsReply(). 171 + setExperimenterPortDescReply(factory().buildPortDescStatsReply().
153 setEntries(ofPortDescList).build()); 172 setEntries(ofPortDescList).build());
154 } 173 }
155 174
175 + private void setExperimenterPortDescReply(OFPortDescStatsReply reply) {
176 + wPorts = reply;
177 + }
178 +
156 179
157 private void sendHandshakeOFExperimenterPortDescRequest() throws 180 private void sendHandshakeOFExperimenterPortDescRequest() throws
158 IOException { 181 IOException {
...@@ -160,11 +183,22 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { ...@@ -160,11 +183,22 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
160 OFCircuitPortsRequest circuitPortsRequest = factory() 183 OFCircuitPortsRequest circuitPortsRequest = factory()
161 .buildCircuitPortsRequest().setXid(getNextTransactionId()) 184 .buildCircuitPortsRequest().setXid(getNextTransactionId())
162 .build(); 185 .build();
163 - log.debug("LINC-OE : Sending experimented circuit port stats " + 186 + log.warn("LINC-OE : Sending experimented circuit port stats " +
164 "message " + 187 "message " +
165 "{}", 188 "{}",
166 circuitPortsRequest.toString()); 189 circuitPortsRequest.toString());
167 - sendMsg(Collections.<OFMessage>singletonList(circuitPortsRequest)); 190 + this.write(Collections.<OFMessage>singletonList(circuitPortsRequest));
191 + }
192 +
193 +
194 + @Override
195 + public List<OFPortDesc> getPorts() {
196 + List<OFPortDesc> portEntries = new ArrayList<>();
197 + portEntries.addAll(ports.getEntries());
198 + if (wPorts != null) {
199 + portEntries.addAll(wPorts.getEntries());
200 + }
201 + return Collections.unmodifiableList(portEntries);
168 } 202 }
169 203
170 204
...@@ -533,7 +567,7 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { ...@@ -533,7 +567,7 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
533 567
534 @Override 568 @Override
535 public void write(OFMessage msg) { 569 public void write(OFMessage msg) {
536 - this.sendMsg(msg); 570 + this.channel.write(Collections.singletonList(msg));
537 } 571 }
538 572
539 @Override 573 @Override
...@@ -546,4 +580,10 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch { ...@@ -546,4 +580,10 @@ public class OFOpticalSwitchImplLINC13 extends AbstractOpenFlowSwitch {
546 return false; 580 return false;
547 } 581 }
548 582
583 + @Override
584 + public boolean isOptical() {
585 + return true;
586 + }
587 +
588 +
549 } 589 }
......
...@@ -165,6 +165,11 @@ public class RoleManagerTest { ...@@ -165,6 +165,11 @@ public class RoleManagerTest {
165 } 165 }
166 166
167 @Override 167 @Override
168 + public boolean isOptical() {
169 + return false;
170 + }
171 +
172 + @Override
168 public void setAgent(OpenFlowAgent agent) { 173 public void setAgent(OpenFlowAgent agent) {
169 } 174 }
170 175
......
...@@ -118,8 +118,10 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr ...@@ -118,8 +118,10 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
118 DeviceId did = deviceId(uri(dpid)); 118 DeviceId did = deviceId(uri(dpid));
119 OpenFlowSwitch sw = controller.getSwitch(dpid); 119 OpenFlowSwitch sw = controller.getSwitch(dpid);
120 120
121 + Device.Type deviceType = sw.isOptical() ? Device.Type.ROADM :
122 + Device.Type.SWITCH;
121 DeviceDescription description = 123 DeviceDescription description =
122 - new DefaultDeviceDescription(did.uri(), Device.Type.SWITCH, 124 + new DefaultDeviceDescription(did.uri(), deviceType,
123 sw.manfacturerDescription(), 125 sw.manfacturerDescription(),
124 sw.hardwareDescription(), 126 sw.hardwareDescription(),
125 sw.softwareDescription(), 127 sw.softwareDescription(),
......
...@@ -360,6 +360,11 @@ public class OpenFlowDeviceProviderTest { ...@@ -360,6 +360,11 @@ public class OpenFlowDeviceProviderTest {
360 public void returnRoleAssertFailure(RoleState role) { 360 public void returnRoleAssertFailure(RoleState role) {
361 } 361 }
362 362
363 + @Override
364 + public boolean isOptical() {
365 + return false;
366 + }
367 +
363 } 368 }
364 369
365 } 370 }
......
...@@ -467,5 +467,10 @@ public class OpenFlowLinkProviderTest { ...@@ -467,5 +467,10 @@ public class OpenFlowLinkProviderTest {
467 public void returnRoleAssertFailure(RoleState role) { 467 public void returnRoleAssertFailure(RoleState role) {
468 } 468 }
469 469
470 + @Override
471 + public boolean isOptical() {
472 + return false;
473 + }
474 +
470 } 475 }
471 } 476 }
......
...@@ -398,6 +398,11 @@ public class OpenFlowPacketProviderTest { ...@@ -398,6 +398,11 @@ public class OpenFlowPacketProviderTest {
398 public void returnRoleAssertFailure(RoleState role) { 398 public void returnRoleAssertFailure(RoleState role) {
399 } 399 }
400 400
401 + @Override
402 + public boolean isOptical() {
403 + return false;
404 + }
405 +
401 } 406 }
402 407
403 } 408 }
......