Packet Reading Strategy

This is a discussion on Packet Reading Strategy within the Networking/Device Communication forums, part of the General Programming Boards category; Hello, I was wondering if peeps could give me an idea about how to read complete/incomplete packets out of a ...

  1. #1
    Registered /usr
    Join Date
    Aug 2001
    Location
    Newport, South Wales, UK
    Posts
    1,262

    Packet Reading Strategy

    Hello,

    I was wondering if peeps could give me an idea about how to read complete/incomplete packets out of a receive buffer.

    At the moment, I'm just passing the entire buffer to the validation function, which checks reported size against buffer length, checksum etc. The problem is when the buffer contains a fragment of a packet yet to be fully received, this is currently being discarded as erroneous but obviously that's not good as the peer then has to retransmit, blah blah blah.

    I'm having one of my mental block periods at the moment, but would it go something like:-
    Read as many valid packets as possible until you come across one that has bad size field
    Copy from this point in the buffer back to the start
    Read into buffer address + part packet length
    ?

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,473
    do you have a packet length in the packet header?
    In this case you can retry reading till you achieve the required number of bytes...
    And only then process the decoding
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Packet processing in Socket programming, please help
    By pumpkin in forum Networking/Device Communication
    Replies: 5
    Last Post: 05-28-2009, 01:33 AM
  2. Replies: 4
    Last Post: 05-05-2009, 05:35 AM
  3. How to make a Packet sniffer/filter?
    By shown in forum C++ Programming
    Replies: 2
    Last Post: 02-22-2009, 08:51 PM
  4. question about reading files in
    By smd in forum C++ Programming
    Replies: 11
    Last Post: 08-25-2003, 07:40 PM
  5. problems reading data into an array and printing output
    By serino78 in forum C Programming
    Replies: 4
    Last Post: 04-28-2003, 08:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21