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>

#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;

#define NODEHANDLE_L (IPADDR_L + UDPPORT_L + KEY_L)

//signaling?
#define BASEOVERLAY_L(msg) TYPE_L
#define BASEROUTE_L(msg) (BASEOVERLAY_L(msg) + NODEHANDLE_L + KEY_L + \
                          HOPCOUNT_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 NEXTHOPCALL_L(msg) BASECALL_L(msg)
#define NEXTHOPRESPONSE_L(msg) BASERESPONSE_L(msg)
}};

class CommonAPIMessage;
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;

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 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;
    DHT_PUT = 6;
    DHT_PUT_RESPONSE = 7;
    DHT_GET = 8;
    DHT_GET_RESPONSE = 9;
    DHT_REMOVE = 10;
    DHT_REMOVE_RESPONSE = 11;
};
    
//
// Base class for all messages handled by overlay modules
//
// @author Bernhard Heep
// @see ChordMessage
//
message BaseOverlayMessage {
  fields:
    int type enum(BaseOverlayMessageType) = OVERLAYSIGNALING;  // message type
    bool signaling = true;  // true if this is a signaling message
};

message BaseRouteMessage extends BaseOverlayMessage {
  fields:
    OverlayKey destKey;     // destination key
    NodeHandle srcNode;     // source node
    int hopCount = 0;       // hop count, increased by BaseOverlay
    simtime_t hopStamp;	    // timestamp of processing at last hop and ...
    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 layer finished his init phase
//
message TierReadyMessage extends cMessage {
fields:
    bool ready;
    NodeHandle thisNode;
};

//
// 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)
// -------------------------------------------------------------


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

//
// @author Bernhard Heep
//
// Message type for KBR route calls
//
message KBRroute extends CommonAPIMessage
{
    fields:
        OverlayKey destKey; // the destination key
        int destComp enum(CompType); // destination component
        int srcComp enum(CompType); // source component
        TransportAddress hint;    // first hop, usually unspecified
};

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

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

//
// @author Bernhard Heep
//
// Message type to inform overlay nodes about new or left nodes
//
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
};

//
// @author Ingmar Baumgart
//
// Message type to store value at the keys root
//
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;
};

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

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

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

//
// @author Ingmar Baumgart
//
message LookupCall extends BaseCallMessage {
    fields:
        OverlayKey key;
        int numSiblings;
};

//
// @author Ingmar Baumgart
//
message LookupResponse extends BaseResponseMessage {
    fields:
        OverlayKey key;
        bool isValid;
        NodeHandle siblings[];   // set of siblings
};

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

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

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

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


//
// @author Bernhard Heep
//
// Control info for sending/receiving data via overlay Network. Travels between
// application and overlay.
//
class OverlayCtrlInfo
{
    fields:
        IPvXAddress lastHopAddr; // IP address of last hop node
        int lastHopPort;         // UDP port of last hop node
        NodeHandle srcNode;      // the message's source node IP/port/nodeID
        int hopCount = 0;        // hop count
        int srcComp enum(CompType); // source component
        int destComp enum(CompType); // destination component
        int transportType enum(TransportType) = INVALID_TRANSPORT; // transport type of the received message
};

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

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

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

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

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

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

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

//
// @author Helge Backhaus
//
// Base classes for all overlay / gameclient communication
//
enum GameAPIMessageCommand
{
    MOVEMENT_INDICATION = 0;
    MOVEMENT_REQUEST = 1;
    NEIGHBOR_UPDATE = 2;
};

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;
};