Search in sources :

Example 21 with Ethernet

use of org.onlab.packet.Ethernet in project trellis-control by opennetworkinglab.

the class IcmpHandlerTest method testPing6LoopbackPair.

// Ping6 to the looback of our leaf (pair)
@Test
public void testPing6LoopbackPair() {
    // Expected behavior
    expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF1)).andReturn(true).times(1);
    expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF2)).andReturn(true).times(1);
    replay(segmentRoutingManager.deviceService);
    // Process
    icmpHandler.processIcmpv6(ETH_REQ_IPV6_LOOPBACK_PAIR, CP2021);
    // Verify packet-out
    Ethernet ethernet = packetService.getEthernetPacket(ETH_REQ_IPV6_LOOPBACK_PAIR.getSourceMAC());
    assertNotNull(ethernet);
    assertThat(ethernet.getSourceMAC(), is(ETH_REQ_IPV6_LOOPBACK_PAIR.getDestinationMAC()));
    assertThat(ethernet.getDestinationMAC(), is(ETH_REQ_IPV6_LOOPBACK_PAIR.getSourceMAC()));
    assertTrue(ethernet.getPayload() instanceof IPv6);
    IPv6 ip = (IPv6) ethernet.getPayload();
    assertThat(ip.getSourceAddress(), is(DST_IPV6_LOOPBACK_PAIR.toOctets()));
    assertThat(ip.getDestinationAddress(), is(SRC_IPV61.toOctets()));
    assertTrue(ip.getPayload() instanceof ICMP6);
    ICMP6 icmp = (ICMP6) ip.getPayload();
    assertThat(icmp.getIcmpType(), is(ECHO_REPLY));
    // Verify behavior
    verify(segmentRoutingManager.deviceService);
}
Also used : IPv6(org.onlab.packet.IPv6) Ethernet(org.onlab.packet.Ethernet) ICMP6(org.onlab.packet.ICMP6) Test(org.junit.Test)

Example 22 with Ethernet

use of org.onlab.packet.Ethernet in project trellis-control by opennetworkinglab.

the class IcmpHandlerTest method testPing6Loopback.

// Ping6 to the looback of our leaf
@Test
public void testPing6Loopback() {
    // Expected behavior
    expect(segmentRoutingManager.deviceService.isAvailable(REMOTE_LEAF)).andReturn(true).times(1);
    replay(segmentRoutingManager.deviceService);
    // Process
    icmpHandler.processIcmpv6(ETH_REQ_IPV6_LOOPBACK, CP12);
    // Verify packet-out
    Ethernet ethernet = packetService.getEthernetPacket(ETH_REQ_IPV6_LOOPBACK.getSourceMAC());
    assertNotNull(ethernet);
    assertThat(ethernet.getSourceMAC(), is(ETH_REQ_IPV6_LOOPBACK.getDestinationMAC()));
    assertThat(ethernet.getDestinationMAC(), is(ETH_REQ_IPV6_LOOPBACK.getSourceMAC()));
    assertTrue(ethernet.getPayload() instanceof IPv6);
    IPv6 ip = (IPv6) ethernet.getPayload();
    assertThat(ip.getSourceAddress(), is(DST_IPV6_LOOPBACK.toOctets()));
    assertThat(ip.getDestinationAddress(), is(SRC_IPV6_MY.toOctets()));
    assertTrue(ip.getPayload() instanceof ICMP6);
    ICMP6 icmp = (ICMP6) ip.getPayload();
    assertThat(icmp.getIcmpType(), is(ECHO_REPLY));
    // Verify behavior
    verify(segmentRoutingManager.deviceService);
}
Also used : IPv6(org.onlab.packet.IPv6) Ethernet(org.onlab.packet.Ethernet) ICMP6(org.onlab.packet.ICMP6) Test(org.junit.Test)

Example 23 with Ethernet

use of org.onlab.packet.Ethernet in project trellis-control by opennetworkinglab.

the class IcmpHandlerTest method testPing6LoopbackPairDifferentLeafDown.

// Ping6 loopback of a destination that is down but
// hashing of the bond interfaces sends to other leaf
@Test
public void testPing6LoopbackPairDifferentLeafDown() {
    // Expected behavior
    expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF1)).andReturn(true).times(1);
    expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF2)).andReturn(false).times(1);
    replay(segmentRoutingManager.deviceService);
    // Process
    icmpHandler.processIcmpv6(ETH_REQ_IPV6_LOOPBACK_PAIR, CP2011);
    // Verify packet-out
    Ethernet ethernet = packetService.getEthernetPacket(ETH_REQ_IPV6_LOOPBACK_PAIR.getSourceMAC());
    assertNotNull(ethernet);
    assertThat(ethernet.getSourceMAC(), is(ETH_REQ_IPV6_LOOPBACK_PAIR.getDestinationMAC()));
    assertThat(ethernet.getDestinationMAC(), is(ETH_REQ_IPV6_LOOPBACK_PAIR.getSourceMAC()));
    assertTrue(ethernet.getPayload() instanceof IPv6);
    IPv6 ip = (IPv6) ethernet.getPayload();
    assertThat(ip.getSourceAddress(), is(DST_IPV6_LOOPBACK_PAIR.toOctets()));
    assertThat(ip.getDestinationAddress(), is(SRC_IPV61.toOctets()));
    assertTrue(ip.getPayload() instanceof ICMP6);
    ICMP6 icmp = (ICMP6) ip.getPayload();
    assertThat(icmp.getIcmpType(), is(ECHO_REPLY));
    // Verify behavior
    verify(segmentRoutingManager.deviceService);
}
Also used : IPv6(org.onlab.packet.IPv6) Ethernet(org.onlab.packet.Ethernet) ICMP6(org.onlab.packet.ICMP6) Test(org.junit.Test)

Example 24 with Ethernet

use of org.onlab.packet.Ethernet in project trellis-control by opennetworkinglab.

the class IcmpHandlerTest method testPing4LoopbackPairDifferentLeafDown.

// Ping loopback of a destination that is down but
// hashing of the bond interfaces sends to other leaf
@Test
public void testPing4LoopbackPairDifferentLeafDown() {
    // Expected behavior
    expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF1)).andReturn(false).times(1);
    expect(segmentRoutingManager.deviceService.isAvailable(LOCAL_LEAF2)).andReturn(true).times(1);
    replay(segmentRoutingManager.deviceService);
    // Process
    icmpHandler.processIcmp(ETH_REQ_IPV4_LOOPBACK_PAIR, CP2021);
    // Verify packet-out
    Ethernet ethernet = packetService.getEthernetPacket(ETH_REQ_IPV4_LOOPBACK_PAIR.getSourceMAC());
    assertNotNull(ethernet);
    assertThat(ethernet.getSourceMAC(), is(ETH_REQ_IPV4_LOOPBACK_PAIR.getDestinationMAC()));
    assertThat(ethernet.getDestinationMAC(), is(ETH_REQ_IPV4_LOOPBACK_PAIR.getSourceMAC()));
    assertTrue(ethernet.getPayload() instanceof IPv4);
    IPv4 ip = (IPv4) ethernet.getPayload();
    assertThat(ip.getSourceAddress(), is(DST_IPV4_LOOPBACK_PAIR.toInt()));
    assertThat(ip.getDestinationAddress(), is(SRC_IPV41.toInt()));
    assertTrue(ip.getPayload() instanceof ICMP);
    ICMP icmp = (ICMP) ip.getPayload();
    assertThat(icmp.getIcmpType(), is(TYPE_ECHO_REPLY));
    assertThat(icmp.getIcmpCode(), is(CODE_ECHO_REPLY));
    // Verify behavior
    verify(segmentRoutingManager.deviceService);
}
Also used : Ethernet(org.onlab.packet.Ethernet) IPv4(org.onlab.packet.IPv4) ICMP(org.onlab.packet.ICMP) Test(org.junit.Test)

Example 25 with Ethernet

use of org.onlab.packet.Ethernet in project trellis-control by opennetworkinglab.

the class IcmpHandlerTest method testPing6LinkLocalAddress.

// Ping6 to a link local address
@Test
public void testPing6LinkLocalAddress() {
    // Process
    icmpHandler.processIcmpv6(ETH_REQ_IPV6_LL, CP12);
    // Verify packet-out
    Ethernet ethernet = packetService.getEthernetPacket(ETH_REQ_IPV6_LL.getSourceMAC());
    assertNotNull(ethernet);
    assertThat(ethernet.getSourceMAC(), is(ETH_REQ_IPV6_LL.getDestinationMAC()));
    assertThat(ethernet.getDestinationMAC(), is(ETH_REQ_IPV6_LL.getSourceMAC()));
    assertTrue(ethernet.getPayload() instanceof IPv6);
    IPv6 ip = (IPv6) ethernet.getPayload();
    assertThat(ip.getSourceAddress(), is(DST_IPV6_LL.toOctets()));
    assertThat(ip.getDestinationAddress(), is(SRC_IPV6_LL.toOctets()));
    assertTrue(ip.getPayload() instanceof ICMP6);
    ICMP6 icmp = (ICMP6) ip.getPayload();
    assertThat(icmp.getIcmpType(), is(ECHO_REPLY));
}
Also used : IPv6(org.onlab.packet.IPv6) Ethernet(org.onlab.packet.Ethernet) ICMP6(org.onlab.packet.ICMP6) Test(org.junit.Test)

Aggregations

Ethernet (org.onlab.packet.Ethernet)187 Test (org.junit.Test)91 ConnectPoint (org.onosproject.net.ConnectPoint)46 IPv4 (org.onlab.packet.IPv4)42 IPv6 (org.onlab.packet.IPv6)41 UDP (org.onlab.packet.UDP)38 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)33 MacAddress (org.onlab.packet.MacAddress)30 DefaultOutboundPacket (org.onosproject.net.packet.DefaultOutboundPacket)30 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)29 IpAddress (org.onlab.packet.IpAddress)28 OutboundPacket (org.onosproject.net.packet.OutboundPacket)26 DeviceId (org.onosproject.net.DeviceId)25 ByteBuffer (java.nio.ByteBuffer)24 DHCP (org.onlab.packet.DHCP)24 DHCP6 (org.onlab.packet.DHCP6)24 Interface (org.onosproject.net.intf.Interface)22 DeserializationException (org.onlab.packet.DeserializationException)20 ICMP6 (org.onlab.packet.ICMP6)20 InboundPacket (org.onosproject.net.packet.InboundPacket)20