/**
   * Configures source node
   *
   * <p>Has working layer1, used to send packets
   */
  private DEECoContainer setupSourceNode(int id) {
    DEECoContainer node = Mockito.mock(DEECoContainer.class);

    // Configure id for mocked container
    Mockito.when(node.getId()).thenReturn(id);

    // Configure runtime
    Mockito.when(node.getRuntimeFramework()).thenReturn(runtime);

    // Configure Network for mocked container
    Layer1 layer1 = new Layer1((byte) id, DefaultDataIDSource.getInstance(), scheduler);
    Network network = Mockito.mock(Network.class);
    Mockito.when(network.getL1()).thenReturn(layer1);
    Mockito.when(node.getPluginInstance(Network.class)).thenReturn(network);

    return node;
  }
  /**
   * Configures destination node
   *
   * <p>Has mocked layer1, used to confirm packet reception
   */
  private DEECoContainer setupDestinationNode(int id) {
    DEECoContainer node = Mockito.mock(DEECoContainer.class);

    // Configure id for mocked container
    Mockito.when(node.getId()).thenReturn(id);

    // Configure runtime
    Mockito.when(node.getRuntimeFramework()).thenReturn(runtime);

    // Configure Network for mocked container
    Layer1 layer1 =
        Mockito.spy(new Layer1((byte) id, DefaultDataIDSource.getInstance(), scheduler));
    Mockito.doNothing().when(layer1).processL0Packet(Mockito.any(), Mockito.any(), Mockito.any());
    Network network = Mockito.mock(Network.class);
    Mockito.when(network.getL1()).thenReturn(layer1);
    Mockito.when(node.getPluginInstance(Network.class)).thenReturn(network);

    return node;
  }
Ejemplo n.º 3
0
    public LoopDevice(DEECoContainer container) {
      this.container = container;
      address = new MANETBroadcastAddress(getId());
      positionProvider = container.getPluginInstance(PositionPlugin.class);
      scheduler = container.getRuntimeFramework().getScheduler();

      if (positionProvider != null) {
        Log.i(
            container.getId()
                + ": "
                + LoopDevice.class.getSimpleName()
                + " using node position information provided by "
                + positionProvider.getClass().getSimpleName());
      } else {
        Log.i(
            container.getId()
                + ": "
                + LoopDevice.class.getSimpleName()
                + " not using node position information");
      }
    }