Search in sources :

Example 6 with IPacket

use of net.floodlightcontroller.packet.IPacket in project open-kilda by telstra.

the class BfdSessionCommand method makeSessionConfigPayload.

private IPacket makeSessionConfigPayload(IOFSwitch sw) {
    final TransportPort udpPort = TransportPort.of(bfdSession.getUdpPortNumber());
    UDP l4 = new UDP().setSourcePort(udpPort).setDestinationPort(udpPort);
    InetAddress sourceIpAddress = bfdSession.getTarget().getInetAddress();
    InetAddress destIpAddress = bfdSession.getRemote().getInetAddress();
    IPacket l3 = new IPv4().setSourceAddress(IPv4Address.of(sourceIpAddress.getAddress())).setDestinationAddress(IPv4Address.of(destIpAddress.getAddress())).setProtocol(IpProtocol.UDP).setPayload(l4);
    DatapathId remoteDatapath = DatapathId.of(bfdSession.getRemote().getDatapath().toLong());
    return new Ethernet().setEtherType(EthType.IPv4).setSourceMACAddress(convertDpIdToMac(sw.getId())).setDestinationMACAddress(convertDpIdToMac(remoteDatapath)).setPayload(l3);
}
Also used : UDP(net.floodlightcontroller.packet.UDP) IPacket(net.floodlightcontroller.packet.IPacket) IPv4(net.floodlightcontroller.packet.IPv4) Ethernet(net.floodlightcontroller.packet.Ethernet) DatapathId(org.projectfloodlight.openflow.types.DatapathId) TransportPort(org.projectfloodlight.openflow.types.TransportPort) InetAddress(java.net.InetAddress)

Example 7 with IPacket

use of net.floodlightcontroller.packet.IPacket in project open-kilda by telstra.

the class EnableBfdResource method makeSessionConfigPayload.

private IPacket makeSessionConfigPayload(IOFSwitch sw, ISwitchManager switchManager, NoviBfdSession bfdSession) {
    final TransportPort udpPort = TransportPort.of(bfdSession.getUdpPortNumber());
    UDP l4 = new UDP().setSourcePort(udpPort).setDestinationPort(udpPort);
    InetAddress sourceIpAddress = switchManager.getSwitchIpAddress(sw);
    InetAddress destIpAddress = bfdSession.getRemote().getInetAddress();
    IPacket l3 = new IPv4().setSourceAddress(IPv4Address.of(sourceIpAddress.getAddress())).setDestinationAddress(IPv4Address.of(destIpAddress.getAddress())).setProtocol(IpProtocol.UDP).setPayload(l4);
    DatapathId remoteDatapath = DatapathId.of(bfdSession.getRemote().getDatapath().toLong());
    return new Ethernet().setEtherType(EthType.IPv4).setSourceMACAddress(convertDpIdToMac(sw.getId())).setDestinationMACAddress(convertDpIdToMac(remoteDatapath)).setPayload(l3);
}
Also used : UDP(net.floodlightcontroller.packet.UDP) IPacket(net.floodlightcontroller.packet.IPacket) IPv4(net.floodlightcontroller.packet.IPv4) Ethernet(net.floodlightcontroller.packet.Ethernet) DatapathId(org.projectfloodlight.openflow.types.DatapathId) TransportPort(org.projectfloodlight.openflow.types.TransportPort) InetAddress(java.net.InetAddress)

Example 8 with IPacket

use of net.floodlightcontroller.packet.IPacket in project open-kilda by telstra.

the class PathVerificationPacketInTest method testDeserialize.

@Test
public void testDeserialize() {
    Ethernet ethernet = (Ethernet) new Ethernet().deserialize(pkt, 0, pkt.length);
    assertArrayEquals(pkt, ethernet.serialize());
    IPacket expected = getPacket();
    assertArrayEquals(expected.serialize(), ethernet.serialize());
}
Also used : IPacket(net.floodlightcontroller.packet.IPacket) Ethernet(net.floodlightcontroller.packet.Ethernet) Test(org.junit.Test)

Example 9 with IPacket

use of net.floodlightcontroller.packet.IPacket in project open-kilda by telstra.

the class PathVerificationPacketSignTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    final OFPacketOut packetOut = pvs.generateDiscoveryPacket(sw1, OFPort.of(1), true, null);
    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();
    expect(ofPacketIn.getCookie()).andReturn(PathVerificationService.OF_CATCH_RULE_COOKIE);
    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);
}
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)

Example 10 with IPacket

use of net.floodlightcontroller.packet.IPacket in project open-kilda by telstra.

the class PathVerificationPacketSignTest method testSignPacketMissedSign.

@Test
public void testSignPacketMissedSign() {
    replay(producerService);
    OFPacketOut noSignPacket = pvs.generateDiscoveryPacket(sw1, OFPort.of(1), false, null);
    IPacket noSignPacketData = new Ethernet().deserialize(noSignPacket.getData(), 0, noSignPacket.getData().length);
    context.getStorage().put(IFloodlightProviderService.CONTEXT_PI_PAYLOAD, noSignPacketData);
    pvs.handlePacketIn(new OfInput(sw2, ofPacketIn, context));
    verify(producerService);
}
Also used : OfInput(org.openkilda.floodlight.model.OfInput) IPacket(net.floodlightcontroller.packet.IPacket) Ethernet(net.floodlightcontroller.packet.Ethernet) OFPacketOut(org.projectfloodlight.openflow.protocol.OFPacketOut) Test(org.junit.Test)

Aggregations

IPacket (net.floodlightcontroller.packet.IPacket)13 Ethernet (net.floodlightcontroller.packet.Ethernet)9 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)4 IPv4 (net.floodlightcontroller.packet.IPv4)4 UDP (net.floodlightcontroller.packet.UDP)4 DatapathId (org.projectfloodlight.openflow.types.DatapathId)4 PingWiredView (org.openkilda.floodlight.model.PingWiredView)3 InputService (org.openkilda.floodlight.service.of.InputService)3 NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)3 Ping (org.openkilda.messaging.model.Ping)3 FlowTransitEncapsulation (org.openkilda.model.FlowTransitEncapsulation)3 SwitchId (org.openkilda.model.SwitchId)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 InetAddress (java.net.InetAddress)2 FloodlightContext (net.floodlightcontroller.core.FloodlightContext)2 OfInput (org.openkilda.floodlight.model.OfInput)2 OFPacketIn (org.projectfloodlight.openflow.protocol.OFPacketIn)2 OFPacketOut (org.projectfloodlight.openflow.protocol.OFPacketOut)2 TransportPort (org.projectfloodlight.openflow.types.TransportPort)2