FullCircle/Netzwerkprotokoll

Aus C3MAWiki
Zur Navigation springenZur Suche springen

// used in both files and network. A Snip is a single network protocol message // containing some payload. The payload can include all protobuf types. package fullcircle;


message BinarySequenceMetadata {

 required uint32 frames_per_second = 1;
 required uint32 width = 2;
 required uint32 height = 3;
 required string generator_name = 4;
 required string generator_version = 5;

}

message RGBValue {

 required uint32 red = 1;
 required uint32 green = 2;
 required uint32 blue = 3;
 required uint32 x = 4;
 required uint32 y = 5;

}

message BinaryFrame {

 repeated RGBValue pixel = 1;

}

message BinarySequence {

 required BinarySequenceMetadata metadata = 1;
 repeated BinaryFrame frame = 2;

}

// network-only below. A Snip is a single network protocol message // containing some payload. The payload can include all protobuf types. message Snip {

 enum SnipType {
   PING = 1;
   PONG = 2;
   ERROR = 3;
   REQUEST = 4;
   START = 5;
   FRAME = 6;
   ACK = 7;
   NACK = 8;
   TIMEOUT = 9;
   ABORT = 10;
   EOS = 11;
   INFO_REQUEST = 12;
   INFO_ANSWER = 13;
 }
 required SnipType type = 1;
 message PingSnip {
   required uint32 count = 1;
 }
 optional PingSnip ping_snip = 11;
 message PongSnip {
   required uint32 count = 1;
 }
 optional PongSnip pong_snip = 12;
 enum ErrorCodeType {
   OK = 1;
   DECODING_ERROR = 2;
   // To be extended.
 }
 message ErrorSnip {
   required ErrorCodeType errorcode = 1;
   required string description = 2;
 }
 optional ErrorSnip error_snip = 13;
 message RequestSnip {
   required string color = 1;
   required uint32 seqId = 2;
   required BinarySequenceMetadata meta = 3;
 }
 optional RequestSnip req_snip = 14;
 message StartSnip {
 }
 optional StartSnip start_snip = 15;
 message FrameSnip {
   required BinaryFrame frame = 1;
 }
 optional FrameSnip frame_snip = 16;
 message AckSnip {
 }
 optional AckSnip ack_snip = 17;
 message NackSnip {
 }
 optional NackSnip nack_snip = 18;
 message TimeoutSnip {
 }
 optional TimeoutSnip timeout_snip = 19;
 message AbortSnip {
 }
 optional AbortSnip abort_snip = 20;
 message EosSnip {
 }
 optional EosSnip eos_snip = 21;
 message InfoRequestSnip {
 }
 optional InfoRequestSnip inforequest_snip = 22;
 message InfoAnswerSnip {
   required BinarySequenceMetadata meta = 1;
 }
 optional InfoAnswerSnip infoanswer_snip = 23;

}

Grundlagen

Ein Packet besteht aus einem Header und Payload. Der Header ist ein 10 Byte Ascii String, in welchem Rechtsbündig die Länge des Payload in Ascii gesendet wird. Der Payload ist ein serialiesierter Probufstring des Typ Snip (siehe oben).

Beispiel: Ping => type: PING ping_snip {

 count: 1

}

Header:" 6" Bodycount: "\b\001Z\002\b\001" String:" 6\b\001Z\002\b\001"

Verbindung

Client

Frames senden

  1. REQUEST senden mit:
    1. color
    2. seqId
    3. metadata typ:(BinaryMetaData)
  2. ACK erhalten
  3. Warten auf START
  4. FRAMEs senden, mit der entsprechenden Framerate
  5. Wenn fertig EOS (End of Sequence) senden
  • Während des Senden Timeout oder Abort Abfangen und behandeln.

Netwerktest

  • PING
    • count

Server antwortet mit

  • PONG
    • count

Status

  • INFO_REQUEST

Server antwortet mit

  • INFO_ANSWER
    • meta
      • width
      • height
      • fps
      • "server"
      • verison of server

Server

  1. Warten auf REQUEST
  2. ACK senden wenn gültig
  3. Wenn Slot auf Wand frei, START senden
  4. FRAMEs engegen nehmen und direkt auf der Wand zeigen
  5. Wenn Wartezeit zwischen Frames zu lang TIMEOUT Senden
  6. Wenn Sonnst was Brocken ABORT sednen