Example #1
0
 public DLPAOutputSlot(
     boolean isRequestSlot, int maxDelay, Simulator simulator, Mix mix, DLPABasic dLPABasic) {
   this.dLPABasic = dLPABasic;
   this.mix = mix;
   this.simulator = simulator;
   this.messagesToSend =
       new HashMap<AbstractClient, MixMessage>(simulator.getNumberOfClients() * 2);
   this.isRequestSlot = isRequestSlot;
   this.setTimeOfOutput(Simulator.getNow() + maxDelay);
   this.relatedOutputEvent = new Event(this, getTimeOfOutput(), OutputStrategyEvent.DLPA_TIMEOUT);
   simulator.scheduleEvent(relatedOutputEvent, this);
 }
Example #2
0
  public void putOutMessages() {
    if (isRequestSlot) dLPABasic.removeRequestOutputslot(this);
    else dLPABasic.removeReplyOutputslot(this);
    Vector<MixMessage> messages = new Vector<MixMessage>(simulator.getNumberOfClients());
    int dummyCounter = 0;
    int noneDummyCounter = 0;
    for (AbstractClient client : simulator.getClients().values()) {

      MixMessage mixMessage = messagesToSend.get(client);
      if (mixMessage == null) {
        mixMessage = createDummyMessage(client, isRequestSlot);
        dummyCounter++;
        if (isRequestSlot)
          dLPABasic.statistics.addValue(true, StatisticsType.DLPA_REQUEST_MESSAGE_DROP_PERCENTAGE);
      } else {
        noneDummyCounter++;
        if (isRequestSlot)
          dLPABasic.statistics.addValue(false, StatisticsType.DLPA_REQUEST_MESSAGE_DROP_PERCENTAGE);
      }
      messages.add(mixMessage);
    }
    messagesToSend.clear();
    Collections.shuffle(messages);
    for (MixMessage m : messages) {
      if (isRequestSlot) {
        dLPABasic.statistics.increment(1, StatisticsType.DLPA_REQUEST_SENDING_RATE_PER_MIX);
        dLPABasic.statistics.increment(
            1, StatisticsType.DLPA_REQUEST_SENDING_RATE_PER_MIX_AND_CLIENT);
        mix.putOutRequest(m);
      } else { // reply slot
        dLPABasic.statistics.increment(1, StatisticsType.DLPA_REPLY_SENDING_RATE_PER_MIX);
        mix.putOutReply(m);
      }
      dLPABasic.statistics.increment(1, StatisticsType.DLPA_REQUEST_AND_REPLY_SENDING_RATE_PER_MIX);
    }
    double totalMessages = dummyCounter + noneDummyCounter;
    if (isRequestSlot) {
      dLPABasic.statistics.addValue(
          ((double) dummyCounter / totalMessages) * 100d,
          StatisticsType.DLPA_REQUEST_DUMMY_PERCENTAGE_PER_MIX);
    } else {
      dLPABasic.statistics.addValue(
          ((double) dummyCounter / totalMessages) * 100d,
          StatisticsType.DLPA_REPLY_DUMMY_PERCENTAGE_PER_MIX);
    }
    dLPABasic.statistics.addValue(
        ((double) dummyCounter / totalMessages) * 100d,
        StatisticsType.DLPA_DUMMY_PERCENTAGE_PER_MIX);
  }
Example #3
0
 private MixMessage createDummyMessage(AbstractClient owner, boolean isRequest) {
   NetworkNode source = isRequest ? owner : mix;
   NetworkNode destination = isRequest ? simulator.getDistantProxy() : owner;
   return MixMessage.getInstance(isRequest, source, destination, owner, Simulator.getNow(), true);
 }