internal InboundFragmentationMessage( UInt16 source, UInt16 destination, byte sequenceNumber, DataRequestHandler lowerLayerRequestHandler, int maxPduSize, int reservedHeaderSize, int reservedTailSize, FragmentationMessageTimer timer) : base(source, destination, sequenceNumber, lowerLayerRequestHandler, maxPduSize, reservedHeaderSize, reservedTailSize, timer) { }
public void Start(UInt16 localAddress) { lock (_lock) { if (_started) { Stop(); } _localShortAddress = localAddress; _outboundAssociations = new FragmentationMessageAssociationSet(); _inboundAssociations = new FragmentationMessageAssociationSet(); _dataRequestQueueEvent = new AutoResetEvent(false); _dataRequestQueueSet = new DataRequestQueueSet(_maxRequestNumberPerDestination, _dataRequestQueueEvent); _started = true; _timer = new FragmentationMessageTimer(50); _transmissionCharacteristicStorage = new TransmissionCharacteristicStorage(); } }
internal FragmentationMessage( UInt16 source, UInt16 destination, byte messageSeqNumber, DataRequestHandler lowerLayerRequestHandler, int maxPduSize, int reservedHeaderSize, int reservedTailSize, FragmentationMessageTimer timer) { _timer = timer; _lowerLayerRequestHandler = lowerLayerRequestHandler; _currentState = FragmentationMessageState.Initial; _source = source; _destination = destination; _messageSeqNumber = messageSeqNumber; _lock = new object(); _timeoutTicks = long.MaxValue; _maxPduSize = maxPduSize; _reservedHeaderSize = reservedHeaderSize; _reservedTailSize = reservedTailSize; _lastFragmentSeqNumberReceived = 0xFF; _lastFragmentSeqNumberSent = 0xFF; }
internal OutboundFragmentationMessage( UInt16 source, UInt16 destination, byte messageSeqNumber, DataRequestHandler lowerLayerRequestHandler, ref Frame sdu, Byte sduHandle, DataConfirmHandler handler, int maxPduSize, int reservedHeaderSize, int reservedTailSize, FragmentationMessageTimer timer ) : base(source, destination, messageSeqNumber, lowerLayerRequestHandler, maxPduSize, reservedHeaderSize, reservedTailSize, timer) { if (sdu.LengthDataUsed == 0) { Frame.Release(ref sdu); throw new ArgumentException("sdu is empty", "sdu"); } int payloadSize = maxPduSize - 2 - 2; // 2 for our own header, 1 for nb fragment, 1 for fragment id if (payloadSize == 0) { Frame.Release(ref sdu); throw new ArgumentException("PDU is too small", "maxPduSize"); } ushort flag = (ushort)(1 << 15); _isBroadcast = (destination & flag) > 0 ? true : false; _sdu = sdu; sdu = null; _sduHandle = sduHandle; _dataConfirmHandler = handler; _messageSeqNumber = messageSeqNumber; _timeoutForResending = c_defaultTimeoutForResending; _maxFragmentsBeforeAck = c_defaultMaxFragmentsBeforeAck; // compute required nb fragments and respective indices. int nbFragments = ((_sdu.LengthDataUsed % payloadSize) == 0) ? _sdu.LengthDataUsed / payloadSize : 1 + _sdu.LengthDataUsed / payloadSize; if (nbFragments > byte.MaxValue) { throw new ArgumentException("sdu is too large."); } _nbFragments = (byte)nbFragments; _endingIndices = new int[_nbFragments]; int lastIndex = -1; for (int i = 0; i + 1 < _nbFragments; i++) { lastIndex += payloadSize; _endingIndices[i] = lastIndex; } lastIndex += ((_sdu.LengthDataUsed % payloadSize) == 0) ? payloadSize : _sdu.LengthDataUsed % payloadSize; _endingIndices[_nbFragments - 1] = lastIndex; _successfullyTransmittedFragments = new BitArray(_nbFragments, false); _lastFragmentSent = new BitArray(_nbFragments, false); }
internal OutboundFragmentationMessage( UInt16 source, UInt16 destination, byte messageSeqNumber, DataRequestHandler lowerLayerRequestHandler, ref Frame sdu, Byte sduHandle, DataConfirmHandler handler, int maxPduSize, int reservedHeaderSize, int reservedTailSize, FragmentationMessageTimer timer ) : base(source, destination, messageSeqNumber, lowerLayerRequestHandler, maxPduSize, reservedHeaderSize, reservedTailSize, timer) { if (sdu.LengthDataUsed == 0) { Frame.Release(ref sdu); throw new ArgumentException("sdu is empty", "sdu"); } int payloadSize = maxPduSize - 2 - 2; // 2 for our own header, 1 for nb fragment, 1 for fragment id if (payloadSize == 0) { Frame.Release(ref sdu); throw new ArgumentException("PDU is too small", "maxPduSize"); } ushort flag = (ushort)(1 << 15); _isBroadcast = (destination & flag) > 0 ? true : false; _sdu = sdu; sdu = null; _sduHandle = sduHandle; _dataConfirmHandler = handler; _messageSeqNumber = messageSeqNumber; _timeoutForResending = c_defaultTimeoutForResending; _maxFragmentsBeforeAck = c_defaultMaxFragmentsBeforeAck; // compute required nb fragments and respective indices. int nbFragments = ((_sdu.LengthDataUsed % payloadSize) == 0) ? _sdu.LengthDataUsed / payloadSize : 1 + _sdu.LengthDataUsed / payloadSize; if (nbFragments > byte.MaxValue) throw new ArgumentException("sdu is too large."); _nbFragments = (byte)nbFragments; _endingIndices = new int[_nbFragments]; int lastIndex = -1; for (int i = 0; i + 1 < _nbFragments; i++) { lastIndex += payloadSize; _endingIndices[i] = lastIndex; } lastIndex += ((_sdu.LengthDataUsed % payloadSize) == 0) ? payloadSize : _sdu.LengthDataUsed % payloadSize; _endingIndices[_nbFragments - 1] = lastIndex; _successfullyTransmittedFragments = new BitArray(_nbFragments, false); _lastFragmentSent = new BitArray(_nbFragments, false); }