Class FRAG.FragmentationTable

  • Enclosing class:
    FRAG

    static class FRAG.FragmentationTable
    extends java.lang.Object
    Keeps track of the fragments that are received. Reassembles fragements into entire messages when all fragments have been received. The fragmentation holds a an array of byte arrays for a unique sender The first dimension of the array is the order of the fragmentation, in case the arrive out of order
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      (package private) static class  FRAG.FragmentationTable.FragEntry
      inner class represents an entry for a message each entry holds an array of byte arrays sorted once all the byte buffer entries have been filled the fragmentation is considered complete.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] add​(long id, int frag_id, int tot_frags, byte[] fragment)
      Creates a new entry if not yet present.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • FragmentationTable

        FragmentationTable​(Address sender)
    • Method Detail

      • add

        public byte[] add​(long id,
                          int frag_id,
                          int tot_frags,
                          byte[] fragment)
        Creates a new entry if not yet present. Adds the fragment. If all fragements for a given message have been received, an entire message is reassembled and returned. Otherwise null is returned.
        Parameters:
        id - - the message ID, unique for a sender
        frag_id - the index of this fragmentation (0..tot_frags-1)
        tot_frags - the total number of fragmentations expected
        fragment - - the byte buffer for this fragment
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object