@Override
 public void init(DEECoContainer container) {
   random = new Random(container.getId());
   LoopDevice loop = new LoopDevice(container);
   Layer1 l1 = container.getPluginInstance(Network.class).getL1();
   l1.registerDevice(loop);
   loops.add(loop);
 }
  /** Tests sending packet from node to nonexistent node */
  @Test(expected = UnsupportedOperationException.class)
  public void testNodeToVoidRouting() {
    SimpleInfrastructureDevice loop = new SimpleInfrastructureDevice();

    // Register nodes 0 with Infrastructure loop-back
    loop.init(node0);

    // Send packet from node 0 to node 5 (non existent)
    Layer1 node0layer1 = node0.getPluginInstance(Network.class).getL1();
    node0layer1.sendL1Packet(TEST_PACKET, new IPAddress(String.valueOf(5)));

    // Exception should be thrown as destination node is not present
  }
  /** Tests sending packet from one node to another one */
  @Test
  public void testNodeToNodeRouting() {
    SimpleInfrastructureDevice loop = new SimpleInfrastructureDevice();

    // Register nodes 0 and 1 with Infrastructure loop-back
    loop.init(node0);
    loop.init(node1);

    // Send packet from node 0 to node 1
    Layer1 node0layer1 = node0.getPluginInstance(Network.class).getL1();
    node0layer1.sendL1Packet(TEST_PACKET, new IPAddress(String.valueOf(node1.getId())));

    // Test packet was received on node 1
    Layer1 node1layer1 = node1.getPluginInstance(Network.class).getL1();
    Mockito.verify(node1layer1, Mockito.atLeastOnce())
        .processL0Packet(Mockito.any(), Mockito.any(), Mockito.any());
  }