Search in sources :

Example 1 with FloodlightContext

use of net.floodlightcontroller.core.FloodlightContext in project open-kilda by telstra.

the class PathTest method setUp.

@Before
public void setUp() throws Exception {
    cntx = new FloodlightContext();
    FloodlightModuleContext fmc = new FloodlightModuleContext();
    fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
    fmc.addService(IOFSwitchService.class, getMockSwitchService());
    swDescription = factory.buildDescStatsReply().build();
    swFeatures = factory.buildFeaturesReply().setNBuffers(1000).build();
    sw1Port1 = EasyMock.createMock(OFPortDesc.class);
    sw2Port1 = EasyMock.createMock(OFPortDesc.class);
    expect(sw1Port1.getHwAddr()).andReturn(MacAddress.of(sw1HwAddrTarget)).anyTimes();
    expect(sw1Port1.getPortNo()).andReturn(OFPort.of(1));
    expect(sw2Port1.getHwAddr()).andReturn(MacAddress.of(sw2HwAddrTarget)).anyTimes();
    expect(sw2Port1.getPortNo()).andReturn(OFPort.of(1));
    sw1 = EasyMock.createMock(IOFSwitch.class);
    expect(sw1.getId()).andReturn(sw1Id).anyTimes();
    expect(sw1.getPort(OFPort.of(1))).andReturn(sw1Port1).anyTimes();
    expect(sw1.getOFFactory()).andReturn(factory).anyTimes();
    expect(sw1.getBuffers()).andReturn(swFeatures.getNBuffers()).anyTimes();
    expect(sw1.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
    expect(sw1.getSwitchDescription()).andReturn(new SwitchDescription(swDescription)).anyTimes();
    expect(sw1.isActive()).andReturn(true).anyTimes();
    expect(sw1.getLatency()).andReturn(U64.of(10L)).anyTimes();
    expect(sw1.getInetAddress()).andReturn(sw1InetAddr).anyTimes();
    sw2 = EasyMock.createMock(IOFSwitch.class);
    expect(sw2.getId()).andReturn(sw2Id).anyTimes();
    expect(sw2.getPort(OFPort.of(1))).andReturn(sw1Port1).anyTimes();
    expect(sw2.getOFFactory()).andReturn(factory).anyTimes();
    expect(sw2.getBuffers()).andReturn(swFeatures.getNBuffers()).anyTimes();
    expect(sw2.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
    expect(sw2.getSwitchDescription()).andReturn(new SwitchDescription(swDescription)).anyTimes();
    expect(sw2.isActive()).andReturn(true).anyTimes();
    expect(sw2.getLatency()).andReturn(U64.of(10L)).anyTimes();
    expect(sw2.getInetAddress()).andReturn(sw2InetAddr).anyTimes();
    replay(sw1Port1);
    replay(sw2Port1);
    replay(sw1);
    replay(sw2);
    packetIn = EasyMock.createMock(OFPacketIn.class);
    pvs.initAlgorithm("secret");
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn) SwitchDescription(net.floodlightcontroller.core.SwitchDescription) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) Before(org.junit.Before)

Example 2 with FloodlightContext

use of net.floodlightcontroller.core.FloodlightContext in project open-kilda by telstra.

the class PathVerificationPacketInTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    cntx = new FloodlightContext();
    mockFloodlightProvider = getMockFloodlightProvider();
    swFeatures = factory.buildFeaturesReply().setNBuffers(1000).build();
    swDescription = factory.buildDescStatsReply().build();
    FloodlightModuleContext fmc = new FloodlightModuleContext();
    fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
    fmc.addService(IOFSwitchService.class, getMockSwitchService());
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    packetInBuilder.setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build()).setData(pkt).setReason(OFPacketInReason.NO_MATCH);
    pktIn = packetInBuilder.build();
    System.out.print(Hex.encodeHexString(pktIn.getData()));
    pvs = new PathVerificationService();
    fmc.addConfigParam(pvs, "isl_bandwidth_quotient", "0.0");
    fmc.addConfigParam(pvs, "hmac256-secret", "secret");
    fmc.addConfigParam(pvs, "bootstrap-servers", "");
    pvs.initServices(fmc);
    pvs.initAlgorithm("secret");
    srcIpTarget = new InetSocketAddress("192.168.10.1", 200);
    dstIpTarget = new InetSocketAddress("192.168.10.101", 100);
    sw1HwAddrTarget = "11:22:33:44:55:66";
    sw2HwAddrTarget = "AA:BB:CC:DD:EE:FF";
    OFPortDesc sw1Port1 = EasyMock.createMock(OFPortDesc.class);
    expect(sw1Port1.getHwAddr()).andReturn(MacAddress.of(sw1HwAddrTarget)).anyTimes();
    expect(sw1Port1.getVersion()).andReturn(OFVersion.OF_12).anyTimes();
    expect(sw1Port1.getCurrSpeed()).andReturn(100000L).anyTimes();
    OFPortDesc sw2Port1 = EasyMock.createMock(OFPortDesc.class);
    expect(sw2Port1.getHwAddr()).andReturn(MacAddress.of(sw2HwAddrTarget)).anyTimes();
    expect(sw2Port1.getVersion()).andReturn(OFVersion.OF_12).anyTimes();
    expect(sw2Port1.getCurrSpeed()).andReturn(100000L).anyTimes();
    replay(sw1Port1);
    replay(sw2Port1);
    sw1 = buildMockIOFSwitch(1L, sw1Port1, factory, swDescription, srcIpTarget);
    sw2 = buildMockIOFSwitch(2L, sw2Port1, factory, swDescription, dstIpTarget);
    replay(sw1);
    replay(sw2);
}
Also used : OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) InetSocketAddress(java.net.InetSocketAddress) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) Before(org.junit.Before)

Example 3 with FloodlightContext

use of net.floodlightcontroller.core.FloodlightContext in project open-kilda by telstra.

the class PathVerificationPacketOutTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    cntx = new FloodlightContext();
    FloodlightModuleContext fmc = new FloodlightModuleContext();
    fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
    fmc.addService(IOFSwitchService.class, getMockSwitchService());
    swDescription = factory.buildDescStatsReply().build();
    pvs = new PathVerificationService();
    pvs.initAlgorithm("secret");
    srcIpTarget = new InetSocketAddress("192.168.10.1", 200);
    dstIpTarget = new InetSocketAddress("192.168.10.101", 100);
    sw1HwAddrTarget = "11:22:33:44:55:66";
    sw2HwAddrTarget = "AA:BB:CC:DD:EE:FF";
    OFPortDesc sw1Port1 = EasyMock.createMock(OFPortDesc.class);
    expect(sw1Port1.getHwAddr()).andReturn(MacAddress.of(sw1HwAddrTarget)).anyTimes();
    OFPortDesc sw2Port1 = EasyMock.createMock(OFPortDesc.class);
    expect(sw2Port1.getHwAddr()).andReturn(MacAddress.of(sw2HwAddrTarget)).anyTimes();
    replay(sw1Port1);
    replay(sw2Port1);
    sw1 = buildMockIOFSwitch(1L, sw1Port1, factory, swDescription, srcIpTarget);
    sw2 = buildMockIOFSwitch(2L, sw2Port1, factory, swDescription, dstIpTarget);
    replay(sw1);
    replay(sw2);
}
Also used : OFPortDesc(org.projectfloodlight.openflow.protocol.OFPortDesc) InetSocketAddress(java.net.InetSocketAddress) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) Before(org.junit.Before)

Example 4 with FloodlightContext

use of net.floodlightcontroller.core.FloodlightContext in project open-kilda by telstra.

the class PathVerificationFlowTest method setUp.

@Before
public void setUp() throws Exception {
    logger = LoggerFactory.getLogger(PathVerificationFlowTest.class);
    cntx = new FloodlightContext();
    FloodlightModuleContext fmc = new FloodlightModuleContext();
    fmc.addService(IFloodlightProviderService.class, mockFloodlightProvider);
    swDescription = factory.buildDescStatsReply().build();
    swFeatures = factory.buildFeaturesReply().setNBuffers(1000).build();
    sw = EasyMock.createMock(IOFSwitch.class);
    expect(sw.getId()).andReturn(swDpid).anyTimes();
    expect(sw.getOFFactory()).andReturn(factory).anyTimes();
    expect(sw.getBuffers()).andReturn(swFeatures.getNBuffers()).anyTimes();
    expect(sw.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_TABLE)).andReturn(true).anyTimes();
    expect(sw.getSwitchDescription()).andReturn(new SwitchDescription(swDescription)).anyTimes();
    expect(sw.isActive()).andReturn(true).anyTimes();
    expect(sw.getLatency()).andReturn(U64.of(10L)).anyTimes();
    replay(sw);
    pvs = new PathVerificationService();
}
Also used : IOFSwitch(net.floodlightcontroller.core.IOFSwitch) FloodlightModuleContext(net.floodlightcontroller.core.module.FloodlightModuleContext) SwitchDescription(net.floodlightcontroller.core.SwitchDescription) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) Before(org.junit.Before)

Example 5 with FloodlightContext

use of net.floodlightcontroller.core.FloodlightContext in project open-kilda by telstra.

the class PathVerificationPacketSignTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    OFPacketOut packetOut = pvs.generateVerificationPacket(sw1, OFPort.of(1));
    ofPacketIn = EasyMock.createMock(OFPacketIn.class);
    context = new FloodlightContext();
    expect(ofPacketIn.getType()).andReturn(OFType.PACKET_IN).anyTimes();
    expect(ofPacketIn.getXid()).andReturn(0L).anyTimes();
    expect(ofPacketIn.getVersion()).andReturn(packetOut.getVersion()).anyTimes();
    Match match = EasyMock.createMock(Match.class);
    expect(match.get(MatchField.IN_PORT)).andReturn(OFPort.of(1)).anyTimes();
    replay(match);
    expect(ofPacketIn.getMatch()).andReturn(match).anyTimes();
    replay(ofPacketIn);
    IPacket expected = new Ethernet().deserialize(packetOut.getData(), 0, packetOut.getData().length);
    context.getStorage().put(IFloodlightProviderService.CONTEXT_PI_PAYLOAD, expected);
    HashMap<DatapathId, IOFSwitch> switches = new HashMap<>();
    switches.put(sw1.getId(), sw1);
    switches.put(sw2.getId(), sw2);
    mockSwitchManager.setSwitches(switches);
    reset(producer);
    pvs.setKafkaProducer(producer);
}
Also used : IPacket(net.floodlightcontroller.packet.IPacket) IOFSwitch(net.floodlightcontroller.core.IOFSwitch) HashMap(java.util.HashMap) Ethernet(net.floodlightcontroller.packet.Ethernet) OFPacketIn(org.projectfloodlight.openflow.protocol.OFPacketIn) DatapathId(org.projectfloodlight.openflow.types.DatapathId) OFPacketOut(org.projectfloodlight.openflow.protocol.OFPacketOut) FloodlightContext(net.floodlightcontroller.core.FloodlightContext) Match(org.projectfloodlight.openflow.protocol.match.Match) Before(org.junit.Before)

Aggregations

FloodlightContext (net.floodlightcontroller.core.FloodlightContext)6 Before (org.junit.Before)5 FloodlightModuleContext (net.floodlightcontroller.core.module.FloodlightModuleContext)4 IOFSwitch (net.floodlightcontroller.core.IOFSwitch)3 OFPacketIn (org.projectfloodlight.openflow.protocol.OFPacketIn)3 OFPortDesc (org.projectfloodlight.openflow.protocol.OFPortDesc)3 InetSocketAddress (java.net.InetSocketAddress)2 SwitchDescription (net.floodlightcontroller.core.SwitchDescription)2 HashMap (java.util.HashMap)1 IOFMessageListener (net.floodlightcontroller.core.IOFMessageListener)1 Ethernet (net.floodlightcontroller.packet.Ethernet)1 IPacket (net.floodlightcontroller.packet.IPacket)1 OFPacketOut (org.projectfloodlight.openflow.protocol.OFPacketOut)1 Match (org.projectfloodlight.openflow.protocol.match.Match)1 DatapathId (org.projectfloodlight.openflow.types.DatapathId)1