/************************************************************************************ * 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.core; import java.io.Serializable; import vnsim.core.events.ReceiveEvent; import vnsim.network.RadioDev; /** * This interface must be implemented by every node that that exists in the * simulator and should communicate */ public interface Communicator { /** * Method called by the engine to obtain the message this node has to transmit * * @param messageType Identifies the message type (e.g. 0 - keep alive message) * @return The content of the message */ public byte[] prepareMessage(int messageType); /** * Receive a message. * * @param bytesReceived The message received * @param sender The sender of the message */ public void onReceive(byte[] bytesReceived, Serializable message, Communicator sender); /** * In promiscous mode a node just listens for messages while the nodes * around know of its state. As soon as the state of the node will change * it will start transmitting again. * * @return True if the node is in promiscous mode */ public boolean isPromiscuousMode(); /** * Returns true if the message is a periodical message. * * @param messageType The type of the message * @return */ public boolean isPeriodicalMessage(int messageType); /** * Gets the period of the message if it is a periodical message * * @param messageType The type of the message * @return */ public int getPeriod(int messageType); /** * Gets the last time there was a transmission in the air. * * @return */ public int getLastMediumTransmition(); public void setLastMediumTransmition(int lastMediumTransmission); public boolean mediumAvailable(int crtTime); public RadioDev getRadio(); public short getPointIdx(); public short getRoadIdx(); public ReceiveEvent getReceiveEventForTime(int t); public void addReceiveEventForTime(ReceiveEvent re); public void removeReceiveEventForTime(int t); }