Java 类org.projectfloodlight.openflow.protocol.OFPacketInReason 实例源码

项目:open-kilda    文件:PacketFactory.java   
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
项目:fresco_floodlight    文件:LinkDiscoveryManagerTest.java   
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
                                  String srcIp, String dstIp, short vlan) {
    IPacket testPacket = new Ethernet()
    .setDestinationMACAddress(dstMAC)
    .setSourceMACAddress(srcMAC)
    .setVlanID(vlan)
    .setEtherType(EthType.IPv4)
    .setPayload(
            new IPv4()
            .setTtl((byte) 128)
            .setSourceAddress(srcIp)
            .setDestinationAddress(dstIp)
            .setPayload(new UDP()
            .setSourcePort((short) 5000)
            .setDestinationPort((short) 5001)
            .setPayload(new Data(new byte[] {0x01}))));
    byte[] testPacketSerialized = testPacket.serialize();
    OFPacketIn pi;
    // build out input packet
    pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setData(testPacketSerialized)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    return pi;
}
项目:fresco_floodlight    文件:OFSwitchHandlerTestBase.java   
/**
 * Test dispatch of messages while in MASTER role
 */
@Test
public void testMessageDispatchMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    reset(switchManager);
    switchManager.handleMessage(sw, pi, null);
    expectLastCall().once();
    replay(switchManager);
    switchHandler.processOFMessage(pi);

    // TODO: many more to go
}
项目:fresco_floodlight    文件:PacketFactory.java   
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
项目:iTAP-controller    文件:LinkDiscoveryManagerTest.java   
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
                                  String srcIp, String dstIp, short vlan) {
    IPacket testPacket = new Ethernet()
    .setDestinationMACAddress(dstMAC)
    .setSourceMACAddress(srcMAC)
    .setVlanID(vlan)
    .setEtherType(EthType.IPv4)
    .setPayload(
            new IPv4()
            .setTtl((byte) 128)
            .setSourceAddress(srcIp)
            .setDestinationAddress(dstIp)
            .setPayload(new UDP()
            .setSourcePort((short) 5000)
            .setDestinationPort((short) 5001)
            .setPayload(new Data(new byte[] {0x01}))));
    byte[] testPacketSerialized = testPacket.serialize();
    OFPacketIn pi;
    // build out input packet
    pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setData(testPacketSerialized)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    return pi;
}
项目:iTAP-controller    文件:OFSwitchHandlerTestBase.java   
/**
 * Test dispatch of messages while in MASTER role
 */
@Test
public void testMessageDispatchMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    reset(switchManager);
    switchManager.handleMessage(sw, pi, null);
    expectLastCall().once();
    replay(switchManager);
    switchHandler.processOFMessage(pi);

    // TODO: many more to go
}
项目:iTAP-controller    文件:PacketFactory.java   
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
项目:SDN-Multicast    文件:LinkDiscoveryManagerTest.java   
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
                                  String srcIp, String dstIp, short vlan) {
    IPacket testPacket = new Ethernet()
    .setDestinationMACAddress(dstMAC)
    .setSourceMACAddress(srcMAC)
    .setVlanID(vlan)
    .setEtherType(EthType.IPv4)
    .setPayload(
            new IPv4()
            .setTtl((byte) 128)
            .setSourceAddress(srcIp)
            .setDestinationAddress(dstIp)
            .setPayload(new UDP()
            .setSourcePort((short) 5000)
            .setDestinationPort((short) 5001)
            .setPayload(new Data(new byte[] {0x01}))));
    byte[] testPacketSerialized = testPacket.serialize();
    OFPacketIn pi;
    // build out input packet
    pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setData(testPacketSerialized)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    return pi;
}
项目:SDN-Multicast    文件:OFSwitchHandlerTestBase.java   
/**
 * Test dispatch of messages while in MASTER role
 */
@Test
public void testMessageDispatchMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    reset(switchManager);
    switchManager.handleMessage(sw, pi, null);
    expectLastCall().once();
    replay(switchManager);
    switchHandler.processOFMessage(pi);

    // TODO: many more to go
}
项目:SDN-Multicast    文件:PacketFactory.java   
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
项目:arscheduler    文件:LinkDiscoveryManagerTest.java   
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
                                  String srcIp, String dstIp, short vlan) {
    IPacket testPacket = new Ethernet()
    .setDestinationMACAddress(dstMAC)
    .setSourceMACAddress(srcMAC)
    .setVlanID(vlan)
    .setEtherType(EthType.IPv4)
    .setPayload(
            new IPv4()
            .setTtl((byte) 128)
            .setSourceAddress(srcIp)
            .setDestinationAddress(dstIp)
            .setPayload(new UDP()
            .setSourcePort((short) 5000)
            .setDestinationPort((short) 5001)
            .setPayload(new Data(new byte[] {0x01}))));
    byte[] testPacketSerialized = testPacket.serialize();
    OFPacketIn pi;
    // build out input packet
    pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setData(testPacketSerialized)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    return pi;
}
项目:arscheduler    文件:OFSwitchHandlerTestBase.java   
/**
 * Test dispatch of messages while in MASTER role
 */
@Test
public void testMessageDispatchMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    reset(switchManager);
    switchManager.handleMessage(sw, pi, null);
    expectLastCall().once();
    replay(switchManager);
    switchHandler.processOFMessage(pi);

    // TODO: many more to go
}
项目:arscheduler    文件:PacketFactory.java   
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
项目:floodlight1.2-delay    文件:LinkDiscoveryManagerTest.java   
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
                                  String srcIp, String dstIp, short vlan) {
    IPacket testPacket = new Ethernet()
    .setDestinationMACAddress(dstMAC)
    .setSourceMACAddress(srcMAC)
    .setVlanID(vlan)
    .setEtherType(EthType.IPv4)
    .setPayload(
            new IPv4()
            .setTtl((byte) 128)
            .setSourceAddress(srcIp)
            .setDestinationAddress(dstIp)
            .setPayload(new UDP()
            .setSourcePort((short) 5000)
            .setDestinationPort((short) 5001)
            .setPayload(new Data(new byte[] {0x01}))));
    byte[] testPacketSerialized = testPacket.serialize();
    OFPacketIn pi;
    // build out input packet
    pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setData(testPacketSerialized)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    return pi;
}
项目:floodlight1.2-delay    文件:OFSwitchHandlerTestBase.java   
/**
 * Test dispatch of messages while in MASTER role
 */
@Test
public void testMessageDispatchMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    reset(switchManager);
    switchManager.handleMessage(sw, pi, null);
    expectLastCall().once();
    replay(switchManager);
    switchHandler.processOFMessage(pi);

    // TODO: many more to go
}
项目:floodlight1.2-delay    文件:PacketFactory.java   
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
项目:floodlight-hardware    文件:LinkDiscoveryManagerTest.java   
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
                                  String srcIp, String dstIp, short vlan) {
    IPacket testPacket = new Ethernet()
    .setDestinationMACAddress(dstMAC)
    .setSourceMACAddress(srcMAC)
    .setVlanID(vlan)
    .setEtherType(EthType.IPv4)
    .setPayload(
            new IPv4()
            .setTtl((byte) 128)
            .setSourceAddress(srcIp)
            .setDestinationAddress(dstIp)
            .setPayload(new UDP()
            .setSourcePort((short) 5000)
            .setDestinationPort((short) 5001)
            .setPayload(new Data(new byte[] {0x01}))));
    byte[] testPacketSerialized = testPacket.serialize();
    OFPacketIn pi;
    // build out input packet
    pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setData(testPacketSerialized)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    return pi;
}
项目:floodlight-hardware    文件:OFSwitchHandlerTestBase.java   
/**
 * Test dispatch of messages while in MASTER role
 */
@Test
public void testMessageDispatchMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    reset(switchManager);
    switchManager.handleMessage(sw, pi, null);
    expectLastCall().once();
    replay(switchManager);
    switchHandler.processOFMessage(pi);

    // TODO: many more to go
}
项目:floodlight-hardware    文件:PacketFactory.java   
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
项目:ACAMPController    文件:LinkDiscoveryManagerTest.java   
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
                                  String srcIp, String dstIp, short vlan) {
    IPacket testPacket = new Ethernet()
    .setDestinationMACAddress(dstMAC)
    .setSourceMACAddress(srcMAC)
    .setVlanID(vlan)
    .setEtherType(EthType.IPv4)
    .setPayload(
            new IPv4()
            .setTtl((byte) 128)
            .setSourceAddress(srcIp)
            .setDestinationAddress(dstIp)
            .setPayload(new UDP()
            .setSourcePort((short) 5000)
            .setDestinationPort((short) 5001)
            .setPayload(new Data(new byte[] {0x01}))));
    byte[] testPacketSerialized = testPacket.serialize();
    OFPacketIn pi;
    // build out input packet
    pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setData(testPacketSerialized)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    return pi;
}
项目:ACAMPController    文件:OFSwitchHandlerTestBase.java   
/**
 * Test dispatch of messages while in MASTER role
 */
@Test
public void testMessageDispatchMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    reset(switchManager);
    switchManager.handleMessage(sw, pi, null);
    expectLastCall().once();
    replay(switchManager);
    switchHandler.processOFMessage(pi);

    // TODO: many more to go
}
项目:ACAMPController    文件:PacketFactory.java   
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
项目:fast-failover-demo    文件:LinkDiscoveryManagerTest.java   
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
                                  String srcIp, String dstIp, short vlan) {
    IPacket testPacket = new Ethernet()
    .setDestinationMACAddress(dstMAC)
    .setSourceMACAddress(srcMAC)
    .setVlanID(vlan)
    .setEtherType(EthType.IPv4)
    .setPayload(
            new IPv4()
            .setTtl((byte) 128)
            .setSourceAddress(srcIp)
            .setDestinationAddress(dstIp)
            .setPayload(new UDP()
            .setSourcePort((short) 5000)
            .setDestinationPort((short) 5001)
            .setPayload(new Data(new byte[] {0x01}))));
    byte[] testPacketSerialized = testPacket.serialize();
    OFPacketIn pi;
    // build out input packet
    pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setData(testPacketSerialized)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    return pi;
}
项目:fast-failover-demo    文件:OFSwitchHandlerTestBase.java   
/**
 * Test dispatch of messages while in MASTER role
 */
@Test
public void testMessageDispatchMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    reset(switchManager);
    switchManager.handleMessage(sw, pi, null);
    expectLastCall().once();
    replay(switchManager);
    switchHandler.processOFMessage(pi);

    // TODO: many more to go
}
项目:fast-failover-demo    文件:PacketFactory.java   
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
项目:floodlightLB    文件:LinkDiscoveryManagerTest.java   
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
                                  String srcIp, String dstIp, short vlan) {
    IPacket testPacket = new Ethernet()
    .setDestinationMACAddress(dstMAC)
    .setSourceMACAddress(srcMAC)
    .setVlanID(vlan)
    .setEtherType(EthType.IPv4)
    .setPayload(
            new IPv4()
            .setTtl((byte) 128)
            .setSourceAddress(srcIp)
            .setDestinationAddress(dstIp)
            .setPayload(new UDP()
            .setSourcePort((short) 5000)
            .setDestinationPort((short) 5001)
            .setPayload(new Data(new byte[] {0x01}))));
    byte[] testPacketSerialized = testPacket.serialize();
    OFPacketIn pi;
    // build out input packet
    pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setData(testPacketSerialized)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    return pi;
}
项目:floodlightLB    文件:OFSwitchHandlerTestBase.java   
/**
 * Test dispatch of messages while in MASTER role
 */
@Test
public void testMessageDispatchMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    reset(switchManager);
    switchManager.handleMessage(sw, pi, null);
    expectLastCall().once();
    replay(switchManager);
    switchHandler.processOFMessage(pi);

    // TODO: many more to go
}
项目:floodlightLB    文件:PacketFactory.java   
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
项目:DSC    文件:LinkDiscoveryManagerTest.java   
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
                                  String srcIp, String dstIp, short vlan) {
    IPacket testPacket = new Ethernet()
    .setDestinationMACAddress(dstMAC)
    .setSourceMACAddress(srcMAC)
    .setVlanID(vlan)
    .setEtherType(EthType.IPv4)
    .setPayload(
            new IPv4()
            .setTtl((byte) 128)
            .setSourceAddress(srcIp)
            .setDestinationAddress(dstIp)
            .setPayload(new UDP()
            .setSourcePort((short) 5000)
            .setDestinationPort((short) 5001)
            .setPayload(new Data(new byte[] {0x01}))));
    byte[] testPacketSerialized = testPacket.serialize();
    OFPacketIn pi;
    // build out input packet
    pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setData(testPacketSerialized)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    return pi;
}
项目:DSC    文件:OFSwitchHandlerTestBase.java   
/**
 * Test dispatch of messages while in MASTER role
 */
@Test
public void testMessageDispatchMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    reset(switchManager);
    switchManager.handleMessage(sw, pi, null);
    expectLastCall().once();
    replay(switchManager);
    switchHandler.processOFMessage(pi);

    // TODO: many more to go
}
项目:DSC    文件:PacketFactory.java   
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
项目:floodlight    文件:LinkDiscoveryManagerTest.java   
private OFPacketIn createPacketIn(String srcMAC, String dstMAC,
                                  String srcIp, String dstIp, short vlan) {
    IPacket testPacket = new Ethernet()
    .setDestinationMACAddress(dstMAC)
    .setSourceMACAddress(srcMAC)
    .setVlanID(vlan)
    .setEtherType(Ethernet.TYPE_IPv4)
    .setPayload(
            new IPv4()
            .setTtl((byte) 128)
            .setSourceAddress(srcIp)
            .setDestinationAddress(dstIp)
            .setPayload(new UDP()
            .setSourcePort((short) 5000)
            .setDestinationPort((short) 5001)
            .setPayload(new Data(new byte[] {0x01}))));
    byte[] testPacketSerialized = testPacket.serialize();
    OFPacketIn pi;
    // build out input packet
    pi = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setData(testPacketSerialized)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    return pi;
}
项目:floodlight    文件:OFSwitchHandlerTestBase.java   
/**
 * Test dispatch of messages while in MASTER role
 */
@Test
public void testMessageDispatchMaster() throws Exception {
    testInitialMoveToMasterWithRole();

    // Send packet in. expect dispatch
    OFPacketIn pi = factory.buildPacketIn()
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    reset(switchManager);
    switchManager.handleMessage(sw, pi, null);
    expectLastCall().once();
    replay(switchManager);
    switchHandler.processOFMessage(pi);

    // TODO: many more to go
}
项目:floodlight    文件:PacketFactory.java   
/**
 * Generates a DHCP request OFPacketIn.
 * @param hostMac The host MAC address of for the request.
 * @return An OFPacketIn that contains a DHCP request packet.
 */
public static OFPacketIn DhcpDiscoveryRequestOFPacketIn(IOFSwitch sw,
        MacAddress hostMac) {
    byte[] serializedPacket = DhcpDiscoveryRequestEthernet(hostMac).serialize();
    OFFactory factory = sw.getOFFactory();
    OFPacketIn.Builder packetInBuilder = factory.buildPacketIn();
    if (factory.getVersion() == OFVersion.OF_10) {
        packetInBuilder
            .setInPort(OFPort.of(1))
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH);
    } else {
        packetInBuilder
        .setMatch(factory.buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
        .setData(serializedPacket)
        .setReason(OFPacketInReason.NO_MATCH);
    }
    return packetInBuilder.build();
}
项目:Engine    文件:ScenariosTest.java   
OpenFlowMessage getMsgTestPacketIn(long dpid, int xid) {
    Ethernet ethernet = new Ethernet().setEtherType(Ethernet.TYPE_IPV4).setSourceMACAddress(MacAddress.valueOf(42)).setDestinationMACAddress(MacAddress.valueOf(0xdd43));
    IPv4 iPv4 = new IPv4().setProtocol(IPv4.PROTOCOL_TCP);
    TCP tcp = new TCP().setSourcePort((short) 1000).setDestinationPort((short) 2000);
    tcp.setPayload(new Data(new byte[]{0x1a, 0x1b, 0x1c, 0x1d, 0x1e}));
    iPv4.setPayload(tcp);
    ethernet.setPayload(iPv4);
    OFPacketIn newPacketIn = OFFactories.getFactory(OFVersion.OF_10).buildPacketIn().setData(ethernet.serialize()).setReason(OFPacketInReason.NO_MATCH).build();
    OpenFlowMessage newMessage = new OpenFlowMessage();
    newMessage.setOfMessage(newPacketIn);
    MessageHeader header = new MessageHeader();
    header.setTransactionId(xid);

    newMessage.getHeader().setDatapathId(dpid);
    return newMessage;
}
项目:athena    文件:OpenFlowPacketProviderTest.java   
@Test
public void handlePacket() {
    OFPacketIn pkt = sw.factory().buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setInPort(OFPort.NO_MASK)
            .setReason(OFPacketInReason.INVALID_TTL)
            .build();

    controller.processPacket(null, pkt);
    assertNotNull("message unprocessed", registry.ctx);

}
项目:fresco_floodlight    文件:DeviceManagerImplTest.java   
/**
 * Updates testUDPPacketIn and testUDPPacketSrld from testUDPPacket
 * To be called after testUDPPacket has been mangled.
 */
private void updateUDPPacketIn() {
    this.testUDPPacketSrld = this.testUDPPacket.serialize();
    // Build the PacketIn
    this.testUDPPacketIn = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setMatch(OFFactories.getFactory(OFVersion.OF_13).buildMatch().setExact(MatchField.IN_PORT, OFPort.of(3)).build())
            .setData(this.testUDPPacketSrld)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
}
项目:fresco_floodlight    文件:HubTest.java   
@Before
public void setUp() throws Exception {
    super.setUp();

    mockFloodlightProvider = getMockFloodlightProvider();
    hub = new Hub();
    mockFloodlightProvider.addOFMessageListener(OFType.PACKET_IN, hub);
    hub.setFloodlightProvider(mockFloodlightProvider);

    // Build our test packet
    this.testPacket = new Ethernet()
        .setDestinationMACAddress("00:11:22:33:44:55")
        .setSourceMACAddress("00:44:33:22:11:00")
        .setEtherType(EthType.IPv4)
        .setPayload(
            new IPv4()
            .setTtl((byte) 128)
            .setSourceAddress("192.168.1.1")
            .setDestinationAddress("192.168.1.2")
            .setPayload(new UDP()
                        .setSourcePort((short) 5000)
                        .setDestinationPort((short) 5001)
                        .setPayload(new Data(new byte[] {0x01}))));
    this.testPacketSerialized = testPacket.serialize();

    // Build the PacketIn
    this.packetIn = (OFPacketIn) OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
        .setBufferId(OFBufferId.NO_BUFFER)
        .setMatch(OFFactories.getFactory(OFVersion.OF_13).buildMatch()
                .setExact(MatchField.IN_PORT, OFPort.of(1))
                .build())
        .setData(this.testPacketSerialized)
        .setReason(OFPacketInReason.NO_MATCH)
        .setTotalLen((short) this.testPacketSerialized.length).build();
}
项目:fresco_floodlight    文件:FirewallTest.java   
protected void setPacketIn(IPacket packet) {
    byte[] serializedPacket = packet.serialize();
    // Build the PacketIn
    this.packetIn = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setMatch(OFFactories.getFactory(OFVersion.OF_13).buildMatch().setExact(MatchField.IN_PORT, OFPort.of(1)).build())
            .setData(serializedPacket)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
    // Add the packet to the context store
    IFloodlightProviderService.bcStore.
    put(cntx,
            IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
            (Ethernet)packet);
}
项目:iTAP-controller    文件:DeviceManagerImplTest.java   
/**
 * Updates testUDPPacketIn and testUDPPacketSrld from testUDPPacket
 * To be called after testUDPPacket has been mangled.
 */
private void updateUDPPacketIn() {
    this.testUDPPacketSrld = this.testUDPPacket.serialize();
    // Build the PacketIn
    this.testUDPPacketIn = OFFactories.getFactory(OFVersion.OF_13).buildPacketIn()
            .setBufferId(OFBufferId.NO_BUFFER)
            .setMatch(OFFactories.getFactory(OFVersion.OF_13).buildMatch().setExact(MatchField.IN_PORT, OFPort.of(3)).build())
            .setData(this.testUDPPacketSrld)
            .setReason(OFPacketInReason.NO_MATCH)
            .build();
}