======================================================================
Common header: Appears at the start of all SRMv2 packets. 

       (8)      (8)           (16)
   +--------+---------+---------------------------+
   | flags  | pkttype |       reserved            |
   +--------+---------+---------------------------+


   SRMv2 Flags.
   0   1   2   3   4   5   6   7   
   +---+---+---+---+---+---+---+---+
   |   V   | P | U |   Reserved    |
   +---+---+---+---+---+---+---+---+
   
   V: 2-bit SRM version number
   
   P: 1-bit padding, set when padded to closest
      word boundary in encrypted packets. 

   U: Unicast bit set when packet is unicast.
      Unicast address appears in the IP header.
      This is used in 2-step recovery when the initial
      response is unicast to the requesting host. 

   Reserved: Unused bits
   
 ***************************************************
   pkttype: SRMv2 protocol message type.
            One of SRMv2_DATA, SRMv2_REXMIT, SRMv2_RREQ,
            SRMv2_NSREQUEST, SRMv2_NSREPAIR,
            SRMv2_ANNOUNCE, SRMv2_DELAYS,
   Note: It is not necessary that original and retransmitted data
   have seperate codes. This difference must go away eventually. 
 ***************************************************
 
======================================================================
Container header: To identify the container of the
                     data carried in this packet. 
   
                      (32)
   +--------+---------+---------------------------+
   |               source ID (0-31)               | 
   +--------+---------+---------------------------+
   |               source ID (32-63)              |
   +--------+---------+---------------------------+
   |               container ID                   |
   +--------+---------+---------------------------+

   source ID: Obtained by the exclusive OR of the two halves
   of the 16 B quantity from md5_digest(). See source-srmv2.cc
   for more details on the digest function and its return value. 
   
   conatiner ID: ID allocated to corresponding container by
                 the original source (also called owner).                 

   This is the {source, container ID} w.r.t the original source. 
   Hence, repair responses do not contain the IDs of the responding
   host. Data is identified, not the host currently transmitting it. 
 

======================================================================
Source header: This needs to be used in the two-step
   recovery process, where the first response is transmitted
   via unicast to the requesting host. In this case, the
   requesting host includes its source ID to the packet header. 
   Again, source ID is as explained under "container header"
   build_conhdr above.
                      (32)
   +--------+---------+---------------------------+
   |               source ID (0-31)               | 
   +--------+---------+---------------------------+
   |               source ID (32-63)              |
   +--------+---------+---------------------------+
 

======================================================================
ADU header: Appears before each ADU/fragment.

   F: Fragment flag indicates whether this is a whole ADU or
      a fragment. 
   resv: Unused bits
   adutype: ADU data type set by the application. This may be used,
            for example, in mb for the different media and drawing types
            in webcast, for HTML, GIF, JPEG, etc. 
   adulen/fraglen: Length of ADU is F is not set, or
                   fragment length otherwise. 	   
   seq#: Last level in the SNAP hierarchy permits data
         to be identified using this sequence number.
          
   adu timestamp: 64-bit timestamp that is supplied by the application.
                  May be used as the creation time of the ADU at the
                  application. Note: This may be (much) earlier than the
                  instant of transmission. 

       (8)      (8)           (16)
   +-+------+---------+---------------------------+
   |F| resv | adutype |      adulen/fraglen       |
   +-+------+---------+---------------------------+
   |              seq# (or adu#)                  |
   +--------+---------+---------------------------+
   |               adu timestamp (0-31)           | 
   +--------+---------+---------------------------+
   |               adu timestamp (32-63)          | 
   +--------+---------+---------------------------+

 
======================================================================
Fragment header: Appears at the head of each fragment.

   M: "More" bit that indicates that this is not the last fragment
       of the ADU. 
   [Note: The sender knows the total length of the ADU at the time it's
          transmission starts at the sender. Hence, an alternative to the
          "stream" approach with the "more" bit is to include the total
           ADU length in all fragments. This was not done in order to save
           32-bit per packet overhead. IP performs the same optimization.
           We cannot simply include the ADU length in the first fragment alone,
           since this would be sensitive to the loss of the first fragment.] 
   
   offset:  Is the byte offset of the first byte in the fragment
            relative to the first byte in the adu 
   
    (1)                (31)
   +---+---------+---------------------------+
   | M |        offset                       |
   +---+---------+---------------------------+

 
======================================================================
RREQ header: Appears before each repair request. 

   Note: Multiple repair reqeusts may eb stacked in one
   packet. Our current implementation (timer-per-request)
   makes this slightly more involved. 

   Each RREQ is a fixed length (128B) record that contains
   the left and right boundaries of the missing ADUs.
   Each boundary of the two-dimensional ADU space is
   a tuple {seqno, byte offset}. Note that a single 
   RREQ record cannot contain a gap that spans
   multiple containers. The lost range includes the
   left, but not the right boundary. 

                      (32)
   +--------+---------+---------------------------+
   |               start adu seqno                | 
   +--------+---------+---------------------------+
   |               start offset (Bytes)           | 
   +--------+---------+---------------------------+
   |                 end adu seqno                | 
   +--------+---------+---------------------------+
   |                 end offset (Bytes)           | 
   +--------+---------+---------------------------+

 
======================================================================
Source info header: Application specific info included as 
  	             part of announcements, 
                     e.g., human-readable source identifiers, etc.
   
   +--------+---------+-------------------------+
   |length of src's app_info_ -- 2 bytes        |
   | (0xFFFF indicates no app_info in this pkt) |
   +--------+---------+-------------------------+
   |                 app info                   |
   +--------+---------+-------------------------+
   |         (padding to multiple of 4)         | 
   +--------+---------+-------------------------+
 

======================================================================
SRMv2_ANNOUNCE: Each announcement record contains
   summary information for one container (internal or
   external node in the SNAP hierarchy). 
   Note: We may have to revisit this when we allow
   internal SNAP nodes to contain ADUs in addition to
   other SNAP nodes. 
   
                        (32)
   +--------+---------+---------------------------+
   |               container ID                   | 
   +--------+---------+---------------------------+
   |                signature (last adu#)         | 
   +--------+---------+---------------------------+
 

======================================================================
SRMv2_NSHEADER : When a new container is created, updates to the 
   namespace are transmitted to the entire group using this packet. 
                        (32)
   +--------+---------+---------------------------+
   |               parent ID                      | 
   +--------+---------+---------------------------+
   |               container ID                   | 
   +--------+---------+---------------------------+
   |             offset within parent             | 
   +--------+---------+---------------------------+
   |             signature                        | 
   +--------+---------+---------------------------+
   |      length of container name (2 bytes)      | 
   +--------+---------+---------------------------+
   |              container name                  |
   +--------+---------+---------------------------+
   |          (padding to multiple of 4)          | 
   +========+=========+===========================+
   |               parent ID                      | 
   +--------+---------+---------------------------+
   |               container ID                   | 
   +--------+---------+---------------------------+
   |             offset within parent             | 
   +--------+---------+---------------------------+
   |             signature                        | 
   +--------+---------+---------------------------+
   |      length of container name (2 bytes)      | 
   +--------+---------+---------------------------+
   |              container name                  |
   +--------+---------+---------------------------+
   |          (padding to multiple of 4)          | 
   +========+=========+===========================+
                   ...
   +--------+---------+---------------------------+
   |               parent ID                      | 
   +--------+---------+---------------------------+
   |               container ID                   | 
   +--------+---------+---------------------------+
   |             offset within parent             | 
   +--------+---------+---------------------------+
   |             signature                        | 
   +--------+---------+---------------------------+
   |      length of container name (2 bytes)      | 
   +--------+---------+---------------------------+
   |              container name                  |
   +--------+---------+---------------------------+
   |          (padding to multiple of 4)          | 
   +--------+---------+---------------------------+
 
