Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about packet Formating? 1

Status
Not open for further replies.

TheKing

Programmer
Feb 25, 2002
151
US
So I am writting a moble laptop program that will send information from a server to a laptop that is ridding in a car somewhere in the city.
I would like to get ideas of how to make a Message Structure that will one day be able to be upgraded if needbe.

This is what I have come up with on my own:
Start Pattern = some hex character or two of them
len mess. = the length of the entire messages
len hdr = the length of the header
fc = function code = purpose of the message.
data len = Length of message data
dest = destination of message
data = text to be sent in string format
stop pattern = some hex character or opposite of start pattern if more than one character.

so would hex be the way to go with header info or not what is the format that should be used so that I can keep my packet size down?

Thanks for all your help TheKing
[pc3]
 
Dec, Hex or Oct won't effect size since the data is always xmitted in Bin. Also why reinvent the wheel? Ever heard of IP? ----------------------------------------
Wassabi Pop Tarts! Write Kellogs today!
 
well, sure doesn't that stand for Internet Provider?
I was just wondering if that sounded like a good packet layout?
TheKing
[pc3]
 
Err, um. I think what jgercken meant when he mentioned IP was Internet Protocol.

However, the packet format (message structure) should be ok. I think the message structure is a design issue. It really depends on you, the designer. If it serves your purpose then go do it.

By the way, what programming language are you planning to use? I hope it will be the one that supports bit-fields so you can manipulate it on a bit-level (typical for a packet) and at the same time keep your packet size down.

From your message structure, it seems like you are creating a new way of communicating. Will you not use TCP/IP? Rome did not create a great empire by having meetings, they did it by
killing all those who opposed them.

- janvier -
 
I am using TCP/IP to send the packet but I still have to make the string up with my information in it.

I must be missing something about what you are asking me, I am writing my program in VB 6.0 and one in Access 97 that will do the same thing just be different platforms for the customer.

TheKing
[pc3]
 
Ok, so you will use TCP/IP.

In your first post you are asking how to keep your packet size down. As I have said before, you can keep the packet size down by using bit-fields. A bit-field example is given below (it is coded in C).

Code:
struct message {
    unsigned int active : 8 ;
    unsigned int ready : 8 ;
    unsigned int xmt_error : 16 ;
} message_packet ;

The structure above only allocates 32 bits using bit-fields as compared to the one below that allocates 96 bits (in C/C++ under x86 processors, an int is equal to 32 bits or one word).

Code:
struct message {
    unsigned int active ;
    unsigned int ready ;
    unsigned int xmt_error ;
} message_packet ;

So you see, using bit-fields is beneficial. However, I do not know if VB6 supports bit-fields. Rome did not create a great empire by having meetings, they did it by
killing all those who opposed them.

- janvier -
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top