How to Built your own UDP Packet of lets say 524 bytes?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raghaw
    New Member
    • Sep 2008
    • 7

    How to Built your own UDP Packet of lets say 524 bytes?

    Hello everybody,
    Is there any way i can built my own UDP Packet of any size and then transmit it over the network?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    1. Open a UDP Socket to the destination (preferably one that is listening for incoming UDP packets).
    2. Put your data in a buffer of usigned char
    3. Send it
    4. Close your link if you have nothing else to send

    Comment

    • raghaw
      New Member
      • Sep 2008
      • 7

      #3
      ok lets say i have a structure

      struct Msg_42
      {
      Msg_42();//constructor
      U32 Vehicle_ID;
      U32 CUCS_ID;
      U8 Flight_Path_Con trol_Mode;
      };
      with a header structure

      struct STANAG_Message_ Header
      {
      U8 IDD [10];
      U16 Mesasge_Instanc e_Identifier;
      U16 Message_Type;
      U32 Message_Length;
      S16 Stream_ID;
      };


      and

      final message

      struct STANAG_Message
      {
      struct STANAG_Message_ Header st_mh;
      char * Message_Data;
      U32 checksum;
      };


      then how tio put this into a UDP Packet

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Like I said you just open a connection to a UDP socket and send the data you want to in the packet in a single function call (that will mean putting all the data into a single buffer) to send (assuming you are using Berkley sockets or an implementation thereof).

        The network layer will handle the nitty gritty of creating the UDP packet headers.

        Comment

        Working...