source: proiecte/ptvs/src/vnsim/core/Communicator.java @ 31

Last change on this file since 31 was 31, checked in by (none), 14 years ago
File size: 2.3 KB
Line 
1/************************************************************************************
2 * Copyright (C) 2008 by Politehnica University of Bucharest and Rutgers University
3 * All rights reserved.
4 * Refer to LICENSE for terms and conditions of use.
5 ***********************************************************************************/
6package vnsim.core;
7
8import java.io.Serializable;
9
10import vnsim.core.events.ReceiveEvent;
11import vnsim.network.RadioDev;
12
13/**
14 * This interface must be implemented by every node that that exists in the
15 * simulator and should communicate
16 */
17public interface Communicator {
18
19        /**
20         * Method called by the engine to obtain the message this node has to transmit 
21         *
22         * @param messageType Identifies the message type (e.g. 0 - keep alive message)
23         * @return The content of the message
24         */
25        public byte[] prepareMessage(int messageType);
26
27        /**
28         * Receive a message.
29         *
30         * @param bytesReceived The message received
31         * @param sender The sender of the message
32         */
33        public void onReceive(byte[] bytesReceived, Serializable message, Communicator sender);
34       
35        /**
36         * In promiscous mode a node just listens for messages while the nodes
37         * around know of its state. As soon as the state of the node will change
38         * it will start transmitting again.
39         *
40         * @return True if the node is in promiscous mode
41         */
42        public boolean isPromiscuousMode();
43       
44        /**
45         * Returns true if the message is a periodical message.
46         *
47         * @param messageType The type of the message
48         * @return
49         */
50        public boolean isPeriodicalMessage(int messageType);
51       
52        /**
53         * Gets the period of the message if it is a periodical message
54         *
55         * @param messageType The type of the message
56         * @return
57         */
58        public int getPeriod(int messageType);
59       
60        /**
61         * Gets the last time there was a transmission in the air.
62         *
63         * @return
64         */
65        public int getLastMediumTransmition();
66       
67        public void setLastMediumTransmition(int lastMediumTransmission);
68
69        public boolean mediumAvailable(int crtTime);
70       
71        public RadioDev getRadio();
72       
73        public short getPointIdx();
74
75        public short getRoadIdx();
76       
77        public ReceiveEvent getReceiveEventForTime(int t);
78
79        public void addReceiveEventForTime(ReceiveEvent re);
80       
81        public void removeReceiveEventForTime(int t);
82}
Note: See TracBrowser for help on using the repository browser.