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);
}
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);
}
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);
}
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);
}
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));
}
Aggregations