how i prepare a c++ code(c code) for implementing my own protocol format

helo my protocol format is given below

{ destno,mode,no.of packet,pktsize,,pktno,textsize,CRC}
description:- { is starting flag
destno - 4bytes
mode - 1 byte
no.of pkt - 4byes
pktsize - 6 bytes
pktno 3 bytes
text size 6 bytes
CRC is 2 bytes
i want to write c++ code(or c code) to prepare this packet and after this
i want to transfer this packet over serial port.
after that how i write a code to receive this packet from serial port and how i extract this packet after receiving the packet.
Regards,
Amit

You need six bytes for a packet size? Wow.

Do you have code to generate and check CRCs?

sending side

len=call_generate_crc(buf,len);
write(fd,buf,len);

at receiving side

while (1)
{
    if (read(fd,buf,1) !=1) exit(1);
    if (buf[0]==start_of_packet) break;
}
..... /*read rest of packet */

check_crc(buf,len);