Пример #1
0
 internal unsafe NetMapReceiveRing(RxTxPair rxTxPair, byte *memoryRegion, long queueOffset, TPacketReceiver receiver, NetMapTransmitRing hostTxRing)
     : base(rxTxPair, memoryRegion, queueOffset)
 {
     _hostTxRing = hostTxRing;
     _receiver   = receiver;
     _worker     = new Thread(new ThreadStart(ThreadLoop));
 }
Пример #2
0
        private unsafe void SetupRings()
        {
            var txOffsets = new long[_netmapInterface.NumberOfTXRings];
            var rxOffsets = new long[_netmapInterface.NumberOfRXRings];

            _rxTxPairs = new RxTxPair[txOffsets.Length + 1];
            var span = new Span <long>(IntPtr.Add(NetMapInterfaceAddress, Unsafe.SizeOf <NetMapInterface>()).ToPointer(), _netmapInterface.NumberOfRXRings + _netmapInterface.NumberOfTXRings + 2);

            for (var i = 0; i < txOffsets.Length; i++)
            {
                txOffsets[i]  = span[0];
                span          = span.Slice(1);
                _rxTxPairs[i] = new RxTxPair(_interfaceName, i, false);
            }
            _rxTxPairs[txOffsets.Length] = new RxTxPair(_interfaceName, txOffsets.Length, true);

            var txHost = span[0];

            span = span.Slice(1);

            for (var i = 0; i < rxOffsets.Length; i++)
            {
                rxOffsets[i] = span[0];
                span         = span.Slice(1);
            }
            var rxHost = span[0];

            _hostTxRing = new NetMapTransmitRing(_rxTxPairs[_rxTxPairs.Length - 1], (byte *)_mappedRegion.ToPointer(), txHost);
            _allRings.Add(_hostTxRing);
            _transmitRings = new NetMapTransmitRing[txOffsets.Length];
            _receiveRings  = new NetMapReceiveRing <TPacketReceiver> [rxOffsets.Length];
            for (var i = 0; i < txOffsets.Length; i++)
            {
                _transmitRings[i] = new NetMapTransmitRing(_rxTxPairs[i], (byte *)_mappedRegion.ToPointer(), txOffsets[i]);
                _allRings.Add(_transmitRings[i]);
                _receiveRings[i] = new NetMapReceiveRing <TPacketReceiver>(_rxTxPairs[i], (byte *)_mappedRegion.ToPointer(), rxOffsets[i], _createReceiver(_transmitRings[i]), _hostTxRing);
                _allRings.Add(_receiveRings[i]);
            }
            _hostRxRing = new NetMapHostRxRing(_rxTxPairs[_rxTxPairs.Length - 1], (byte *)_mappedRegion.ToPointer(), rxHost, _transmitRings[0]);
            _allRings.Add(_hostRxRing);
        }
Пример #3
0
 internal unsafe NetMapHostRxRing(RxTxPair rxTxPair, byte *memoryRegion, long rxQueueOffset, NetMapTransmitRing transmitRing)
     : base(rxTxPair, memoryRegion, rxQueueOffset)
 {
     _transmitRing = transmitRing;
     _worker       = new Thread(new ThreadStart(ThreadLoop));
 }