Esempio n. 1
0
        void Run()
        {
            while (!Terminated)
            {
                try
                {
                    TunnelAdded.WaitOne(TimeBetweenTests.ToMilliseconds / (20 * (InboundTunnels.Count + OutboundTunnels.Count + 1)));

                    lock ( ExternalEventSync )
                    {
                        if (InboundTunnels.Count > 0)
                        {
                            TestOneInboundTunnel();
                        }
                        if (OutboundTunnels.Count > 0)
                        {
                            TestOneOutboundTunnel();
                        }

                        ProbesSent[] timeout = null;

                        timeout = OutstandingProbeIds.Where(p => p.Value.Created.DeltaToNow / p.Value.TotalHops > PassTestTimePerHop).
                                  Select(p => p.Value).ToArray();
                        foreach (var one in timeout)
                        {
                            DeliveryStatusTimeOut(one);
                        }
                    }
                }
                catch (Exception ex)
                {
                    DebugUtils.Log(ex);
                }
            }
        }
Esempio n. 2
0
        internal void Run()
        {
            Resend.Do(() =>
            {
                try
                {
                    List <KeyValuePair <II2NPHeader16, GarlicCreationInfo> > tosend = new List <KeyValuePair <II2NPHeader16, GarlicCreationInfo> >();
                    lock ( Window )
                    {
                        var resend = Window.Where(gci => gci.Value.LastSend.DeltaToNow > GarlicTimeBetweenResends);

                        if (WaitingForEGAck != null && WaitingForEGAck.DeltaToNow > GarlicTimeBetweenResends)
                        {
                            DebugUtils.LogDebug("TagsTransferWindow: Run: ElGamal message needs to be resent. Starting over.");
                            Session.Reset();
                        }

                        foreach (var one in resend.ToArray())
                        {
                            var egmsg = Session.Encrypt(true, one.Value.TrackingId, one.Value.Cloves);
                            var npmsg = new GarlicMessage(egmsg.Garlic).GetHeader16(I2NPHeader.GenerateMessageId());
                            one.Value.LastSend.SetNow();
                            tosend.Add(new KeyValuePair <II2NPHeader16, GarlicCreationInfo>(npmsg, egmsg));

                            if (WaitingForEGAck == null && !one.Value.AckMessageId.HasValue)
                            {
                                // Non explicit ack cloves that should not be retransmitted any more.
                                Window.Remove(one.Key);
                            }
                        }
                    }

                    foreach (var pair in tosend)
                    {
                        DebugUtils.LogDebug(string.Format("TagsTransferWindow: Resend: ({0}) TrackingId: {1}, Ack MessageId: {2}.",
                                                          pair.Value.KeyType, pair.Value.TrackingId, pair.Value.AckMessageId));

                        if (pair.Value.AckMessageId.HasValue)
                        {
                            lock ( OutstandingMessageIds )
                            {
                                OutstandingMessageIds[pair.Value.AckMessageId.Value] = pair.Value;
                            }
                        }

                        TunnelSelector(Session.LatestRemoteLeaseSet, pair.Key, pair.Value);
                    }
                }
                catch (Exception ex)
                {
                    Session.Reset();
                    DebugUtils.Log("TagsTransferWindow Run", ex);
                }
            });
        }