コード例 #1
0
 public void send(Message mess) {
   mess.getSource().incrementerNbMessSend();
   if (mess.getSource().getMomentAvaiableToSend() > mess.getDate()) {
     mess.setDate(mess.getSource().getMomentAvaiableToSend());
   }
   mess.getSource()
       .setMomentAvaiableToSend(
           mess.getDate() + mess.getTaille() / mess.getSource().getCapacCarte());
   getSequencer().addMessToBuffer(mess);
 }
コード例 #2
0
 public void sendMulticast(
     Machine source, List<Machine> destinations, double taille, double date) {
   source.incrementerNbMessSend();
   Message mess = new Message(source, destinations, TypeMessage.MULTICAST, taille, date);
   // Kiem tra may co ranh de cho gui hay khong
   if (source.getMomentAvaiableToSend() > mess.getDate()) { // ko ranh
     mess.setDate(source.getMomentAvaiableToSend());
   }
   source.setMomentAvaiableToSend(mess.getDate() + mess.getTaille() / source.getCapacCarte());
   getSequencer().addMessToBuffer(mess);
 }
コード例 #3
0
  /* Calculer le debit du reseau
   * Debit Total = sum (debit sur chaque machine)
   */
  public void calculateDebit() {
    Map<Integer, Integer> nbMessEachSource = new HashMap<Integer, Integer>();
    Map<Integer, Double> sumEachSource = new HashMap<Integer, Double>();
    for (int i = 0; i < getNbMachines(); i++) {
      nbMessEachSource.put(i, 1);
      sumEachSource.put(i, 1.0);
    }

    for (Message m : getMessageArrives()) {
      int temp1 = nbMessEachSource.get(m.getSource().getId());
      double temps2 = sumEachSource.get(m.getSource().getId());
      temp1 += 1;
      temps2 +=
          (m.getDateMessDelivre() - m.getDate())
              / getUniteTemps(m.getSource().getId(), m.getSource().getCapacCarte());
      nbMessEachSource.put(m.getSource().getId(), temp1);
      sumEachSource.put(m.getSource().getId(), temps2);
    }

    double debit = 0;
    for (int i = 0; i < getNbMachines(); i++) {
      debit += nbMessEachSource.get(i) / sumEachSource.get(i);
    }
    setDebit(debit);
  }
コード例 #4
0
 /* Supposons qu'on a un liste de messages arrives. Definissons:
  * dSi: le date qu'un message i est envoye'
  * dAi: la date qu'un message i est arrive'
  * latence = (sum[0->nbMessTotal](dAi-dSi)/uniteTemps(source qui envoie message i))/nbMessTotal
  */
 public void calculLatence() {
   double temp = 0;
   for (Message m : getMessageArrives()) {
     temp +=
         (m.getDateMessDelivre() - m.getDate())
             / getUniteTemps(m.getSource().getId(), m.getTaille());
   }
   setLatence(temp / (getSequencer().getBuffer().size()));
 }
コード例 #5
0
 public void deliverAMessage(int nbSequence, int idDestinationMachine) {
   // Remove message from buffer
   Message m = this.machinesDefault[idDestinationMachine].removeMessFromBuffer(nbSequence);
   if (this.machinesDefault[idDestinationMachine].getMomentAvaiableToReceive()
       < (m.getDate() + getTempsPropa())) {
     this.machinesDefault[idDestinationMachine].setMomentAvaiableToReceive(
         getUniteTemps(m, this.machinesDefault[idDestinationMachine]));
   } else {
     this.machinesDefault[idDestinationMachine].setMomentAvaiableToReceive(
         getMachine(idDestinationMachine).getMomentAvaiableToReceive()
             + m.getTaille() / getMachine(idDestinationMachine).getCapacCarte());
   }
   m.setDateMessDelivre(getMachine(idDestinationMachine).getMomentAvaiableToReceive());
   System.out.println(
       "*****************Delivred a messages in destination machine "
           + idDestinationMachine
           + " ********************\n"
           + m.toString());
   this.messageArrives.add(m);
 }
コード例 #6
0
 public double getUniteTemps(Message m, Machine machine) {
   return getTempsPropa() + m.getTaille() / machine.getCapacCarte() + m.getDate();
 }