Class AbstractStopAndWaitPacketStreamTransmissionDecorator<DECORATEE extends Transmission>

    • Field Detail

      • _blockSize

        protected int _blockSize
      • _acknowledgeMagicBytes

        protected byte[] _acknowledgeMagicBytes
      • _acknowledgeRetryNumber

        protected int _acknowledgeRetryNumber
      • _acknowledgeTimeoutInMs

        protected long _acknowledgeTimeoutInMs
      • _crcChecksum

        protected long _crcChecksum
      • _endianess

        protected org.refcodes.numerical.Endianess _endianess
      • _sequenceNumberWidth

        protected int _sequenceNumberWidth
      • _sequenceNumberInitValue

        protected int _sequenceNumberInitValue
      • _sequenceNumberConcatenateMode

        protected org.refcodes.mixin.ConcatenateMode _sequenceNumberConcatenateMode
      • _acknowledgeSegmentPackager

        protected SegmentPackager _acknowledgeSegmentPackager
      • _packetSize

        protected int _packetSize
      • _lastPacketMagicBytes

        protected byte[] _lastPacketMagicBytes
      • _packetMagicBytes

        protected byte[] _packetMagicBytes
      • _packetLengthWidth

        protected int _packetLengthWidth
    • Constructor Detail

      • AbstractStopAndWaitPacketStreamTransmissionDecorator

        public AbstractStopAndWaitPacketStreamTransmissionDecorator​(DECORATEE aDecoratee,
                                                                    TransmissionMetrics aTransmissionMetrics)
        Constructs an according packet-stream decorator instance wrapping the given OutputStream. The configuration attributes are taken from the TransmissionMetrics configuration object, though only those attributes are supported which are also supported by the other constructors!
        Parameters:
        aDecoratee - The decoratee to be wrapped by the packet-stream decorator.
        aTransmissionMetrics - The TransmissionMetrics to be used for configuring this instance.
      • AbstractStopAndWaitPacketStreamTransmissionDecorator

        public AbstractStopAndWaitPacketStreamTransmissionDecorator​(DECORATEE aDecoratee,
                                                                    int aBlockSize,
                                                                    int aPacketLengthWidth,
                                                                    byte[] aPacketMagicBytes,
                                                                    int aSequenceNumberInitValue,
                                                                    int aSequenceNumberWidth,
                                                                    org.refcodes.mixin.ConcatenateMode aSequenceNumberConcatenateMode,
                                                                    SegmentPackager aPacketSegmentPackager,
                                                                    byte[] aAcknowledgeMagicBytes,
                                                                    int aAcknowledgeRetryNumber,
                                                                    long aAcknowledgeTimeoutInMs,
                                                                    SegmentPackager aAckSegmentPackager,
                                                                    org.refcodes.numerical.Endianess aEndianess)
        Constructs an according packet-stream decorator instance wrapping the given OutputStream.
        Parameters:
        aDecoratee - The decoratee to be wrapped by the packet-stream decorator.
        aBlockSize - The block size of a data block for each packet.
        aPacketLengthWidth - The width (bytes) for declaring the (max) length of a package.
        aPacketMagicBytes - The magic bytes identifying a packet and distinguishing a packet from a last package.
        aSequenceNumberInitValue - The initial sequence number from where to start counting the blocks.
        aSequenceNumberWidth - The width (in bytes) to be used for sequence number values.
        aSequenceNumberConcatenateMode - The mode of concatenation to use when creating a Sequence from this Transmission and the decorated Transmission.
        aPacketSegmentPackager - An (optional) SegmentPackager used to modify a packet's data e.g. with a CRC checksum.
        aAcknowledgeMagicBytes - The ACK character(s) to be used by the return channel to transmit an ACK (acknowledge) response after successful receiving a transmission.
        aAcknowledgeRetryNumber - The number of retries waiting for an ACK from the return channel.
        aAcknowledgeTimeoutInMs - The timeout in milliseconds to pend till the next retry.
        aAckSegmentPackager - An (optional) SegmentPackager used to modify a ACK response data e.g. with a CRC checksum.
        aEndianess - The Endianess to use for integer (double) numbers and the like.
    • Method Detail

      • getCrcChecksumConcatenateMode

        public org.refcodes.mixin.ConcatenateMode getCrcChecksumConcatenateMode()
        Returns the ConcatenateMode describing the positions of the sequence number, the block data and the CRC checksum within the packet.
        Returns:
        The according ConcatenateMode.
      • getSequenceNumberWidth

        public int getSequenceNumberWidth()
        Retrieves the width (in bytes) dedicated for the sequence number.
        Returns:
        The according length of the sequence number.
      • getBlockSize

        public int getBlockSize()
        Specified by:
        getBlockSize in interface org.refcodes.mixin.BlockSizeAccessor
      • getPacketSize

        public int getPacketSize()
        ATTENTION: The packet size is not available until transmission has been put into effect!
        Specified by:
        getPacketSize in interface org.refcodes.mixin.PacketSizeAccessor
      • getLength

        public int getLength()
        Determines the overall length of this Transmission. In case of nested Transmission instances, all length values from all sub-segments are accumulated to the result as well.
        Specified by:
        getLength in interface org.refcodes.mixin.LengthAccessor
        Specified by:
        getLength in interface Transmission
        Returns:
        The (overall) length of the Transmission (including any sub-segments).
      • getDecoratee

        public DECORATEE getDecoratee()
        Specified by:
        getDecoratee in interface org.refcodes.mixin.DecorateeAccessor<DECORATEE extends Transmission>
      • getEndianess

        public org.refcodes.numerical.Endianess getEndianess()
        Specified by:
        getEndianess in interface org.refcodes.numerical.EndianessAccessor
      • getSequenceNumberInitValue

        public int getSequenceNumberInitValue()
        Retrieves the sequence number initial value from the sequence number initial value property.
        Specified by:
        getSequenceNumberInitValue in interface SequenceNumberInitValueAccessor
        Returns:
        The sequence number initial value stored by the sequence number initial value property.
      • getAcknowledgeRetryNumber

        public int getAcknowledgeRetryNumber()
        Retrieves the number of retries from the acknowledge retry number. A acknowledge retry number is the overall number of retries to use when counting retries.
        Specified by:
        getAcknowledgeRetryNumber in interface AcknowledgeRetryNumberAccessor
        Returns:
        The number of retries stored by the acknowledge retry number.
      • getAcknowledgeMagicBytes

        public byte[] getAcknowledgeMagicBytes()
        Retrieves the magic bytes from the acknowledge magic bytes property.
        Specified by:
        getAcknowledgeMagicBytes in interface AcknowledgeMagicBytesAccessor
        Returns:
        The magic bytes stored by the acknowledge magic bytes property.
      • toSimpleTypeMap

        public org.refcodes.struct.SimpleTypeMap toSimpleTypeMap()
        Returns the SimpleTypeMap representation of this Transmission. In case this Transmission has Transmission children, then the children are queried as well and contained in the resulting SimpleTypeMap. The aliases of the according Transmission instances represent the resulting path to a Transmission's final simple type.
        Specified by:
        toSimpleTypeMap in interface Transmission
        Returns:
        The SimpleTypeMap representing this Transmission and (if any) its children, with the according aliases forming the paths to the Transmission's values.