public OutboundMessageRateLimiter(IAuditAggregator<double> outboundMessageRateLimitAggregator, int baseRate, int rateVelocity, int initialRate, double packetLossDecayFactor) { this.outboundMessageRateLimitAggregator = outboundMessageRateLimitAggregator; this.baseRate = baseRate; this.rateVelocity = rateVelocity; this.currentRate = initialRate; this.packetLossDecayFactor = packetLossDecayFactor; this.lastIterationTime = DateTime.Now; }
public OutboundMessageRateLimiter(IAuditAggregator <double> outboundMessageRateLimitAggregator, int baseRate, int rateVelocity, int initialRate, double packetLossDecayFactor) { this.outboundMessageRateLimitAggregator = outboundMessageRateLimitAggregator; this.baseRate = baseRate; this.rateVelocity = rateVelocity; this.currentRate = initialRate; this.packetLossDecayFactor = packetLossDecayFactor; this.lastIterationTime = DateTime.Now; }
public UdpUnicasterFactory(Identity identity, UdpClient udpClient, AcknowledgementCoordinator acknowledgementCoordinator, IObjectPool<byte[]> sendReceiveBufferPool, IAuditCounter resendsCounter, IAuditAggregator<int> resendsAggregator, IAuditAggregator<double> outboundMessageRateLimitAggregator, IAuditAggregator<double> sendQueueDepthAggregator) { this.identity = identity; this.udpClient = udpClient; this.acknowledgementCoordinator = acknowledgementCoordinator; this.sendReceiveBufferPool = sendReceiveBufferPool; this.resendsCounter = resendsCounter; this.resendsAggregator = resendsAggregator; this.outboundMessageRateLimitAggregator = outboundMessageRateLimitAggregator; this.sendQueueDepthAggregator = sendQueueDepthAggregator; }
public UdpUnicasterFactory(Identity identity, UdpClient udpClient, AcknowledgementCoordinator acknowledgementCoordinator, IObjectPool <byte[]> sendReceiveBufferPool, IAuditCounter resendsCounter, IAuditAggregator <int> resendsAggregator, IAuditAggregator <double> outboundMessageRateLimitAggregator, IAuditAggregator <double> sendQueueDepthAggregator) { this.identity = identity; this.udpClient = udpClient; this.acknowledgementCoordinator = acknowledgementCoordinator; this.sendReceiveBufferPool = sendReceiveBufferPool; this.resendsCounter = resendsCounter; this.resendsAggregator = resendsAggregator; this.outboundMessageRateLimitAggregator = outboundMessageRateLimitAggregator; this.sendQueueDepthAggregator = sendQueueDepthAggregator; }
public UdpUnicaster(Identity identity, UdpClient udpClient, AcknowledgementCoordinator acknowledgementCoordinator, IObjectPool <byte[]> sendReceiveBufferPool, UdpClientRemoteInfo remoteInfo, IAuditCounter resendsCounter, IAuditAggregator <int> resendsAggregator, IAuditAggregator <double> outboundMessageRateLimitAggregator, IAuditAggregator <double> sendQueueDepthAggregator) { this.outboundPacketMemoryStreamPool = new ByteArrayPoolBackedMemoryStreamPool(sendReceiveBufferPool); this.identity = identity; this.udpClient = udpClient; this.acknowledgementCoordinator = acknowledgementCoordinator; this.remoteInfo = remoteInfo; this.resendsCounter = resendsCounter; this.resendsAggregator = resendsAggregator; this.outboundMessageRateLimitAggregator = outboundMessageRateLimitAggregator; this.sendQueueDepthAggregator = sendQueueDepthAggregator; }
private UdpClient(UdpTransportConfiguration configuration, List <Socket> multicastSockets, List <Socket> unicastSockets, IJobQueue <UdpUnicastJob> unicastJobQueue, IObjectPool <byte[]> sendReceiveBufferPool, IAuditAggregator <double> inboundBytesAggregator, IAuditAggregator <double> outboundBytesAggregator, IAuditAggregator <double> inboundReceiveProcessDispatchLatencyAggregator) { this.configuration = configuration; this.multicastSockets = multicastSockets; this.unicastSockets = unicastSockets; this.unicastJobQueue = unicastJobQueue; this.sendReceiveBufferPool = sendReceiveBufferPool; this.inboundBytesAggregator = inboundBytesAggregator; this.outboundBytesAggregator = outboundBytesAggregator; this.inboundReceiveProcessDispatchLatencyAggregator = inboundReceiveProcessDispatchLatencyAggregator; this.sendArgsPool = ObjectPool.CreateStackBacked(() => new SocketAsyncEventArgs()); }
public UdpDispatcherImpl(Identity identity, UdpClient udpClient, DuplicateFilter duplicateFilter, PayloadSender payloadSender, AcknowledgementCoordinator acknowledgementCoordinator, RoutingTable routingTable, PeerTable peerTable, InboundMessageDispatcher inboundMessageDispatcher, MultiPartPacketReassembler multiPartPacketReassembler, IUdpUnicasterFactory udpUnicasterFactory, IAuditCounter announcementsReceivedCounter, IAuditCounter tossedCounter, IAuditCounter duplicateReceivesCounter, IAuditAggregator<int> multiPartChunksBytesReceivedAggregator) { this.identity = identity; this.udpClient = udpClient; this.duplicateFilter = duplicateFilter; this.payloadSender = payloadSender; this.acknowledgementCoordinator = acknowledgementCoordinator; this.routingTable = routingTable; this.peerTable = peerTable; this.inboundMessageDispatcher = inboundMessageDispatcher; this.multiPartPacketReassembler = multiPartPacketReassembler; this.udpUnicasterFactory = udpUnicasterFactory; this.announcementsReceivedCounter = announcementsReceivedCounter; this.tossedCounter = tossedCounter; this.duplicateReceivesCounter = duplicateReceivesCounter; this.multiPartChunksBytesReceivedAggregator = multiPartChunksBytesReceivedAggregator; }
public UdpDispatcherImpl(Identity identity, UdpClient udpClient, DuplicateFilter duplicateFilter, PayloadSender payloadSender, AcknowledgementCoordinator acknowledgementCoordinator, RoutingTable routingTable, PeerTable peerTable, InboundMessageDispatcher inboundMessageDispatcher, MultiPartPacketReassembler multiPartPacketReassembler, IUdpUnicasterFactory udpUnicasterFactory, IAuditCounter announcementsReceivedCounter, IAuditCounter tossedCounter, IAuditCounter duplicateReceivesCounter, IAuditAggregator <int> multiPartChunksBytesReceivedAggregator) { this.identity = identity; this.udpClient = udpClient; this.duplicateFilter = duplicateFilter; this.payloadSender = payloadSender; this.acknowledgementCoordinator = acknowledgementCoordinator; this.routingTable = routingTable; this.peerTable = peerTable; this.inboundMessageDispatcher = inboundMessageDispatcher; this.multiPartPacketReassembler = multiPartPacketReassembler; this.udpUnicasterFactory = udpUnicasterFactory; this.announcementsReceivedCounter = announcementsReceivedCounter; this.tossedCounter = tossedCounter; this.duplicateReceivesCounter = duplicateReceivesCounter; this.multiPartChunksBytesReceivedAggregator = multiPartChunksBytesReceivedAggregator; }
public PayloadUtils(IAuditAggregator <double> inboundBytesAggregator, IAuditAggregator <double> outboundBytesAggregator) { this.inboundBytesAggregator = inboundBytesAggregator; this.outboundBytesAggregator = outboundBytesAggregator; }
public static UdpClient Create(UdpTransportConfiguration udpTransportConfiguration, IScheduler udpUnicastScheduler, IObjectPool <byte[]> sendReceiveBufferPool, IAuditAggregator <double> inboundBytesAggregator, IAuditAggregator <double> outboundBytesAggregator, IAuditAggregator <double> inboundReceiveProcessDispatchLatencyAggregator) { var multicastSockets = new List <Socket>(); var unicastSockets = new List <Socket>(); foreach (var networkInterface in NetworkInterface.GetAllNetworkInterfaces()) { if (!networkInterface.SupportsMulticast || networkInterface.OperationalStatus != OperationalStatus.Up || networkInterface.IsReceiveOnly) { continue; } // HACK loopback disable if (networkInterface.Name.Contains("3")) { continue; } var ipv4Properties = networkInterface.GetIPProperties()?.GetIPv4Properties(); if (ipv4Properties != null) { multicastSockets.Add(CreateMulticastSocket(ipv4Properties.Index, udpTransportConfiguration)); if (!udpTransportConfiguration.MulticastReceiveEndpoint.Equals(udpTransportConfiguration.UnicastReceiveEndpoint)) { unicastSockets.Add(CreateUnicastSocket(ipv4Properties.Index, udpTransportConfiguration)); } } var ni = networkInterface; if (ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet) { Console.WriteLine(ni.Name); foreach (UnicastIPAddressInformation ip in ni.GetIPProperties().UnicastAddresses) { if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { Console.WriteLine(ip.Address.ToString()); } } } } var unicastJobQueue = udpUnicastScheduler.CreateJobQueue <UdpUnicastJob>( job => { var outboundBuffer = job.OutboundBuffer; outboundBytesAggregator.Put(outboundBuffer.Length); var e = new SocketAsyncEventArgs(); e.RemoteEndPoint = job.RemoteInfo.IPEndpoint; e.SetBuffer(outboundBuffer.GetBuffer(), 0, (int)outboundBuffer.Position); e.Completed += (sender, args) => { // Duplicate code with below. args.SetBuffer(null, 0, 0); args.Dispose(); job.SendCompletionHandler(); }; const int kSendStateAsync = 1; const int kSendStateDone = 2; const int kSendStateError = 3; int sendState; try { bool completingAsynchronously = job.RemoteInfo.Socket.SendToAsync(e); sendState = completingAsynchronously ? kSendStateAsync : kSendStateDone; } catch (ObjectDisposedException) { sendState = kSendStateError; } if (sendState == kSendStateDone || sendState == kSendStateError) { // Completed synchronously so e.Completed won't be called. e.SetBuffer(null, 0, 0); e.Dispose(); job.SendCompletionHandler(); } }); return(new UdpClient(udpTransportConfiguration, multicastSockets, unicastSockets, unicastJobQueue, sendReceiveBufferPool, inboundBytesAggregator, outboundBytesAggregator, inboundReceiveProcessDispatchLatencyAggregator)); }
public PayloadUtils(IAuditAggregator<double> inboundBytesAggregator, IAuditAggregator<double> outboundBytesAggregator) { this.inboundBytesAggregator = inboundBytesAggregator; this.outboundBytesAggregator = outboundBytesAggregator; }