/* 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())); }
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); }
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); }
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); }
public double getUniteTemps(Message m, Machine machine) { return getTempsPropa() + m.getTaille() / machine.getCapacCarte() + m.getDate(); }