File Common/CommonMessages.msg

Contains:

//
// Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//

cplusplus {{
#include <OverlayKey.h>
#include <NodeHandle.h>
#include <IPvXAddress.h>
#include <TransportAddress.h>
#include <BinaryValue.h>
#include <Vector2D.h>
#include <DHTDataStorage.h>
#include <OverSimMessage.h>

#define KEY_L OverlayKey::getLength()

static const int TYPE_L = 8;
static const int IPADDR_L = 32;
static const int UDPPORT_L = 16;
static const int HOPCOUNT_L = 16;
static const int NONCE_L = 32;
static const int COMP_L = 16;
static const int NUMSIBLINGS_L = 8;
static const int NEIGHBORSFLAG_L = 8;
static const int RESPONSEFLAG_L = 8;
static const int TRYAGAINFLAG_L = 8;
static const int TIER_L = 8;
static const int ARRAYSIZE_L = 8;
static const int ROUTINGTYPE_L = 8;

#define NODEHANDLE_L (IPADDR_L + UDPPORT_L + KEY_L)
#define TRANSPORTADDRESS_L (IPADDR_L + UDPPORT_L)

#define BASEOVERLAY_L(msg) TYPE_L
#define BASEROUTE_L(msg) (BASEOVERLAY_L(msg) + NODEHANDLE_L + KEY_L + \
                          HOPCOUNT_L + ROUTINGTYPE_L +\
                          ARRAYSIZE_L + (msg->getVisitedHopsArraySize() *\
                          TRANSPORTADDRESS_L) +\
                          ARRAYSIZE_L + (msg->getNextHopsArraySize() *\
                          TRANSPORTADDRESS_L) +\
                          ARRAYSIZE_L + (msg->getHintsArraySize() *\
                          NODEHANDLE_L))
#define BASEAPPDATA_L(msg) (BASEOVERLAY_L(msg) + 2*COMP_L)
#define BASERPC_L(msg) (BASEOVERLAY_L(msg) + NONCE_L + NODEHANDLE_L + \
	                TIER_L)
#define BASECALL_L(msg) BASERPC_L(msg)
#define BASERESPONSE_L(msg) BASERPC_L(msg)
#define FINDNODECALL_L(msg) (BASECALL_L(msg) + KEY_L)
#define FINDNODERESPONSE_L(msg) (BASERESPONSE_L(msg) + NEIGHBORSFLAG_L + \
                  (msg->getClosestNodesArraySize() * NODEHANDLE_L))
#define FAILEDNODECALL_L(msg) (BASECALL_L(msg) + IPADDR_L + UDPPORT_L)
#define FAILEDNODERESPONSE_L(msg) (BASERESPONSE_L(msg) + TRYAGAINFLAG_L)
#define PINGCALL_L(msg) BASECALL_L(msg)
#define PINGRESPONSE_L(msg) BASERESPONSE_L(msg)
#define BOOTSTRAPPINGCALL_L(msg) BASECALL_L(msg)
#define BOOTSTRAPPINGRESPONSE_L(msg) BASERESPONSE_L(msg)
#define NEXTHOPCALL_L(msg) BASECALL_L(msg)
#define NEXTHOPRESPONSE_L(msg) BASERESPONSE_L(msg)
}};

class OverSimMessage;
class BaseOverlayMessage;
class BaseRpcMessage;
class BaseCallMessage;
class BaseResponseMessage;
class noncobject NodeHandle;
class noncobject TransportAddress;
class noncobject OverlayKey;
class noncobject IPvXAddress;
class noncobject Vector2D;
class noncobject BinaryValue;
class noncobject CompType;
class noncobject DhtDumpEntry;

enum BaseOverlayMessageType
{
	OVERLAYSIGNALING = 0;
	RPC = 1;
	APPDATA = 2;
	OVERLAYROUTE = 3;
};

enum CompType
{
    INVALID_COMP = 0;
    OVERLAY_COMP = 1;
    TIER1_COMP = 2;
    TIER2_COMP = 3;
    TIER3_COMP = 4;
    BOOTSTRAPLIST_COMP = 5;
};
    
enum RoutingType
{
    NO_OVERLAY_ROUTING = 0;
    DEFAULT_ROUTING = 1;
    ITERATIVE_ROUTING = 2;
    EXHAUSTIVE_ITERATIVE_ROUTING = 3;
    SEMI_RECURSIVE_ROUTING = 4;
    FULL_RECURSIVE_ROUTING = 5;
    RECURSIVE_SOURCE_ROUTING = 6;
};

enum TransportType
{
    INVALID_TRANSPORT = 0;
    INTERNAL_TRANSPORT = 1;
    UDP_TRANSPORT = 2;
    ROUTE_TRANSPORT = 3;
};

enum CommonAPIMessageType
{
    COMMON_API_UNDEFINED = 0;
    KBR_ROUTE = 1;
    KBR_DELIVER = 2;
    KBR_FORWARD = 3;
    KBR_FORWARD_RESPONSE = 4;
    KBR_UPDATE = 5;
};

enum StatType
{
    MAINTENANCE_STAT = 0;
    APP_DATA_STAT = 1;
    APP_LOOKUP_STAT = 2;

};

//
// Base class for all messages handled by overlay modules
//
// @author Bernhard Heep
// @see ChordMessage
//
//message BaseOverlayMessage extends OverSimMessage {
message BaseOverlayMessage {

  fields:
    int type enum(BaseOverlayMessageType) = OVERLAYSIGNALING;  // message type
    int statType enum(StatType) = MAINTENANCE_STAT; // message type for stats
};

message BaseRouteMessage extends BaseOverlayMessage {
  fields:
    OverlayKey destKey;             // destination key
    NodeHandle srcNode;             // source node
    int routingType enum(RoutingType); // routing type
    int hopCount = 0;               // hop count, increased by BaseOverlay
    TransportAddress visitedHops[]; // hops for source routing
    TransportAddress nextHops[];    // hops for source routing
    NodeHandle hints[];             // hints for next hop (optional)
    simtime_t hopStamp;             // timestamp of processing at last hop
    simtime_t hopDelay[];           // vector of single-hop latency (for stats)
};

message BaseAppDataMessage extends BaseOverlayMessage {
  fields:
    int destComp enum(CompType); // destination component
    int srcComp enum(CompType);  // source component
};

//
// A basic Remote-Procedure-Call message used for calls and return values
//
message BaseRpcMessage extends BaseOverlayMessage {
  fields:
    unsigned int nonce;  // nonce to match RPC responses to corresponding calls
    NodeHandle srcNode;  // source node
};

//
// A basic Remote-Procedure-Call message
//
message BaseCallMessage extends BaseRpcMessage {
};

//
// A basic Remote-Procedure-Response message
//
message BaseResponseMessage extends BaseRpcMessage {
};

//
// The RPC Timeout self-message
//
message RpcTimeoutMessage extends BaseRpcMessage {
};

//
// A basic find node rpc response
//
message FindNodeCall extends BaseCallMessage {
  fields:
    OverlayKey lookupKey;   // request nextHops for this key
    int numRedundantNodes;  // number of redundant nodes to return
    int numSiblings;        // number of siblings to return
};

//
// A basic find node rpc call
//
message FindNodeResponse extends BaseResponseMessage {
  fields:
    // the closestNodes[] vector contains all sibling for the lookup key
    bool siblings; 
    NodeHandle closestNodes[];  // vector of known next hops to the lookup key
};

//
// A basic failed node notification
//
message FailedNodeCall extends BaseCallMessage {
fields:
    TransportAddress failedNode;
};

//
// A basic failed node response
//
message FailedNodeResponse extends BaseResponseMessage {
fields:
    bool tryAgain;
};

//
// A basic ping rpc call
//
message PingCall extends BaseCallMessage {
};

//
// A basic ping response
//
message PingResponse extends BaseResponseMessage {
};

//
// Notification that a component finished its init phase
//
message CompReadyMessage extends cMessage {
fields:
    bool ready;              // true, if the component is ready
    int comp enum(CompType); // the component, which is ready 
};

//
// Internal message for the BootstrapList lookup listener
//
message BootstrapLookupMessage extends BaseOverlayMessage {
};

//
// A next hop rpc call
//
message NextHopCall extends BaseCallMessage {
};

//
// A next hop response / acknowledgement
//
message NextHopResponse extends BaseResponseMessage {
};



// -------------------------------------------------------------
// Common API messages (internal messages)
// -------------------------------------------------------------


//
// Base class for all common API message types
//
// @author Bernhard Heep
//
message CommonAPIMessage
{
    fields:
        int type enum(CommonAPIMessageType) = COMMON_API_UNDEFINED;  // message type
};

//
// Message type for KBR route calls
//
// @author Bernhard Heep
//
message KBRroute extends CommonAPIMessage
{
    fields:
        OverlayKey destKey;                // the destination key
        int destComp enum(CompType);       // destination component
        int srcComp enum(CompType);        // source component
        TransportAddress sourceRoute[];    // source route or hint
        int routingType enum(RoutingType); // routing type
};

//
// Message type for KBR forward calls
//
// @author Bernhard Heep
//
message KBRforward extends CommonAPIMessage
{
    fields:
        OverlayKey destKey;     // the destination key
        NodeHandle nextHopNode; // the proposed/changed next hop node
};

//
// Message type for information sent from the overlay to the application
//
// @author Bernhard Heep
//
message KBRdeliver extends CommonAPIMessage
{
    fields:
        OverlayKey destKey; // destination overlay key
};

//
// Message type to inform overlay nodes about new or left nodes
//
// @author Bernhard Heep
//
message KBRupdate extends CommonAPIMessage
{
    fields:
        NodeHandle node; // the node that has joined or left the overlay
        bool joined; // true if node has joined, false if node has left
};

//
// Message type to store value at the keys root
//
// @author Ingmar Baumgart
//
message DHTputCAPICall extends BaseCallMessage
{
    fields:
        OverlayKey key; // overlayKey that corresponds with value
        BinaryValue value; // value that has to be stored on keys root
        int ttl; // time to life
        bool isModifiable;
};

//
// Message type to order the value corresponding to the OverlayKey key from the node responsible of key
//
// @author Ingmar Baumgart
//
message DHTgetCAPICall extends BaseCallMessage
{
    fields:
        OverlayKey key; // corresponding OverlayKey to the requested value
};

//
// Message type to respond to a DHTput request @see DHTput
//
// @author Ingmar Baumgart
//
message DHTputCAPIResponse extends BaseResponseMessage
{
    fields:
        OverlayKey key;
        BinaryValue value; // the value for which this node is root now
        bool isSuccess;
};

//
// Message type to respond to a DHTget request @see DHTget
//
// @author Ingmar Baumgart
//
message DHTgetCAPIResponse extends BaseResponseMessage
{
    fields:
        OverlayKey key;
        BinaryValue value; // the requested value
        bool isSuccess;
};

//
// Request to dump all local DHT records
//
// @author Ingmar Baumgart
//
message DHTdumpCall extends BaseCallMessage
{
};

//
// Response to a DHTdumpCall
//
// @author Ingmar Baumgart
//
message DHTdumpResponse extends BaseResponseMessage
{
    fields:
        DhtDumpEntry record[]; // array of local dht entries
};



//
// Internal RPC to ask overlay to start a lookup
// @author Ingmar Baumgart
//
message LookupCall extends BaseCallMessage {
    fields:
        OverlayKey key;
        int numSiblings;
};

//
// Internal RPC response from overlay containing lookup results
// @author Ingmar Baumgart
//
message LookupResponse extends BaseResponseMessage {
    fields:
        OverlayKey key;
        bool isValid;
        NodeHandle siblings[]; // set of siblings
};

//
// P2PNS Register RPC Call
//
// @author Ingmar Baumgart
//
message P2pnsRegisterCall extends BaseCallMessage
{
    fields:
        BinaryValue p2pName; // the name to register
        BinaryValue address; // the current address of the name
        int ttl;             // time to life
};

//
// P2PNS Register RPC Response
//
// @author Ingmar Baumgart
//
message P2pnsRegisterResponse extends BaseResponseMessage
{
    fields:
        BinaryValue p2pName;  // the name to register
        BinaryValue address;  // the current address of the name
        bool isSuccess;       // true, if the name was successfully registered
};

//
// P2PNS Resolve RPC Call
//
// @author Ingmar Baumgart
//
message P2pnsResolveCall extends BaseCallMessage
{
    fields:
        BinaryValue p2pName;    // the name to register
};

//
// P2PNS Resolve RPC Response
//
// @author Ingmar Baumgart
//
message P2pnsResolveResponse extends BaseResponseMessage
{
    fields:
        BinaryValue p2pName;  // the name to register
        BinaryValue address;  // the current address of the name
        bool isSuccess;       // true, if the name was successfully resolved
};


//
// Control info for internal handling BaseOverlaMessages.
//
// @author Bernhard Heep
//
class OverlayCtrlInfo
{
    fields:
        TransportAddress lastHop;    // last hop node
        NodeHandle srcNode;          // the message's source node IP/port/nodeID
        int hopCount = 0;            // hop count
        TransportAddress visitedHops[];     // hops on route
        int srcComp enum(CompType);  // source component
        int destComp enum(CompType); // destination component
        int transportType enum(TransportType) = INVALID_TRANSPORT; // transport type of the received message
        int routingType enum(RoutingType);
};

//
// Base message for ALM communication
//
// @author Stephan Krause
//
message ALMMessage {
    fields:
        OverlayKey groupId;
};

//
// Create a multicast group
//
// @author Stephan Krause
//
message ALMCreateMessage extends ALMMessage {
};

//
// Delete a multicast group
//
// @author Stephan Krause
//
message ALMDeleteMessage extends ALMMessage {
};

//
// Subscribe to a multicast group
//
// @author Stephan Krause
//
message ALMSubscribeMessage extends ALMMessage {
};

//
// Leave a multicast group
//
// @author Stephan Krause
//
message ALMLeaveMessage extends ALMMessage {
};

//
// Send a multicast message to all group members
//
// @author Stephan Krause
//
message ALMMulticastMessage extends ALMMessage {
};

//
// Send a message to a (random) member in the group
//
// @author Stephan Krause
//
message ALMAnycastMessage extends ALMMessage {
};

//
// Base classes for all overlay / gameclient communication
//
// @author Helge Backhaus
//
enum GameAPIMessageCommand
{
    MOVEMENT_INDICATION = 0;
    MOVEMENT_REQUEST = 1;
    NEIGHBOR_UPDATE = 2;
    RESIZE_AOI = 3;
    GAMEEVENT_CHAT = 4;
    GAMEEVENT_SNOW = 5;
    GAMEEVENT_FROZEN = 6;
};

message GameAPIMessage extends BaseOverlayMessage // MOVEMENT_REQUEST
{
    fields:
        int command enum(GameAPIMessageCommand);
};

message GameAPIListMessage extends GameAPIMessage // NEIGHBOR_UPDATE
{
    fields:
        NodeHandle removeNeighbor[];
        NodeHandle addNeighbor[];
        Vector2D neighborPosition[];
};

message GameAPIPositionMessage extends GameAPIMessage // MOVEMENT_INDICATION
{
    fields:
        Vector2D position;
};

message GameAPIResizeAOIMessage extends GameAPIMessage
{
    fields:
        double AOIsize;
};

message GameAPIChatMessage extends GameAPIMessage
{
    fields:
        NodeHandle src;
        string msg;
};

message GameAPISnowMessage extends GameAPIMessage
{
    fields:
        NodeHandle src;
        Vector2D start;
        Vector2D end;
        int timeSec;
        int timeUsec;
}

message GameAPIFrozenMessage extends GameAPIMessage
{
    fields:
        NodeHandle src;
        int timeSec;
        int timeUsec;
}