Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Ethereal-dev: [Ethereal-dev] reassembly of PDU con't

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

Date: Fri, 09 Apr 2004 13:55:41 +0200 (CEST)
>On Thu, Apr 08, 2004 at 04:00:39PM +0200, Findeisen Lutz wrote:
>> I've tried to do so with fragment_add() of reassemble.h from the
>> ethereal source but it doesn't work.  (fd_head is not returned)
>
>Note that it only returns a non-null value when reassembly is
complete;
>is it not even returning a non-null value on the last cell?
>
>If so, I'd have to see the code (and the spec for the protocol) to
see
>what's being done wrong - how does something receiving an MPEG-2
>transport stream know when it's gotten the last cell?  Is there a
length
>indication or is there a "last cell" indication?  Do cells have
sequence
>numbers or byte-stream offsets, or is the assumption that cells are
>delivered in-order, with no loss, so that the N+1'st frame in the
>sequence follows the Nth frame in the sequence?


First, thanks for quick reply

This is an example of my code to do reassembly for mpeg2 section out of
packet-mpeg2.c 

if(tsh.payload_unit_start_indicator == 1) 
        {
        sect_pid = help_PID;
        frame = pinfo->fd->num;
           dword = 0;
        for(i = 5; i<8; i++)
             {
                help = tvb_get_guint8(tvb, i);
                help = help<<(8*(i-5));
                dword = dword + help;
             }
        memcpy(&secth,&dword,sizeof(secth));
        slen = (secth.section_length_hi<<8) | secth.section_length_lo;
                        
             if((!pinfo->fd->flags.visited) & (slen > 0))
             {
                  mpeg2_reassamble();
                  fragment_add(tvb, 0, pinfo, sect_pid ,
                                mpeg2_fragment_table,  5, 183,
                                 TRUE);
                                
                  fragment_set_tot_len(pinfo, sect_pid,
mpeg2_fragment_table, slen);
                  slen = slen -183;
                        
            }                        
        }
        if(!pinfo->fd->flags.visited)
        {
            if((help_PID == sect_pid) && (slen != 0) && (frame !=
pinfo->fd->num))
            {
              if(slen >= 184)
              {
                 fragment_add(tvb, 0, pinfo, sect_pid,
                              mpeg2_fragment_table, 0, 184,
                                            TRUE);
                  slen = slen - 184;
                  frame = pinfo->fd->num;
              }
        if((slen <= 184) && (slen > 0) && (frame != pinfo->fd->num))
          {
            mpeg2_head = fragment_add(tvb, 0, pinfo, sect_pid,
                                        mpeg2_fragment_table,  0,
slen,
                                          TRUE);
            slen = 0;  /*slen is set to zero because reassembly should
be complete*/
        if(mpeg2_head != NULL)
        {
           next_tvb =tvb_new_real_data(mpeg2_head->data,
                                                                
mpeg2_head->datalen, mpeg2_head->datalen);
        }                        .                                
                                
         
For explanation:

*)If tsh.payload_unit_start_indicator is set to 1 --> the start of a
section lies in this 188 byte cell of the transport stream
*)For the id of the ghashtable the PID(packetidentifier) is used.
   Because every packet that belongs to the section has the same PID.
   (But with the possibility that there are other frames between)
*)After the first fragment_add() total length is set with slen, which
is the section length out of section header located in the first
fragment
*)frag_offset is the byte offset of the Transportstreamheader (4 bytes)
plus other optional data
   frag_data_len is the rest of the frame 

What I know is that the ghashtable is build up with the frames needed.
But fragment_add_work() does not return true because max <
fd_head->datalen
I am using ethereal 0.9.16

regards,
Lutz