/************************************************************************************ * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University * All rights reserved. * Refer to LICENSE for terms and conditions of use. ***********************************************************************************/ package vnsim.applications.vitp.utils; import java.util.*; public class MessageIndexModule { //an instance of this class manages the unique identifiers of the VITP //messages issued by the local node. It is used by the routing layer to //match incoming replies to pending requests public static int index=0; Vector pending=new Vector(); //the pending replies Vector broadcasted=new Vector(); //the //messages already broadcasted public synchronized static int getNewMessageIdentifier(){ index++; return index; } public void addToPending(int id) { pending.addElement(new Integer(id)); } public void addToBroacasted(int id) { broadcasted.addElement(new Integer(id)); } public boolean isPending(int id){ for(int i=0;i sentMessages=new HashMap (); // // keeps track of which messages have been unicasted to which vehicle; // this is necessary for the reply-computation phase; when a node receives // the same message again, it should not send it to the same node (because // this suggests a loop) public void addToSent(int msgId, int vehicleId) { sentMessages.put(msgId, vehicleId); } public Integer sentTo(int msgId) { return sentMessages.get(msgId); } }