public VirtualNode(EvalEnvironment env, VirtualNetwork network, EvalOptionSet opt, IntervalInterrupter messagingInt, IntervalInterrupter kbrStabilizeInt, IntervalInterrupter anonInt, IntervalInterrupter dhtInt) { IPAddress pubAdrs = _ipGenerator.Next (); int bindPort; lock (_rnd) { bindPort = _rnd.Next (1024, ushort.MaxValue); } _pubEP = new IPEndPoint (pubAdrs, bindPort); _nodePrivateKey = ECKeyPair.Create (DefaultECDomain); _nodeId = Key.Create (_nodePrivateKey); VirtualDatagramEventSocket sock = new VirtualDatagramEventSocket (network, pubAdrs); sock.Bind (new IPEndPoint (IPAddress.Any, bindPort)); _msock = opt.BypassMessagingSerializer ? (IMessagingSocket)new VirtualMessagingSocket (sock, true, messagingInt, DefaultMessagingRTO, DefaultMessagingRetries, DefaultMessagingRetryBufferSize, DefaultMessagingDupCheckSize) : (IMessagingSocket)new MessagingSocket (sock, true, SymmetricKey.NoneKey, Serializer.Instance, null, messagingInt, DefaultMessagingRTO, DefaultMessagingRetries, DefaultMessagingRetryBufferSize, DefaultMessagingDupCheckSize); _kbr = new SimpleIterativeRouter2 (_nodeId, 0, _msock, new SimpleRoutingAlgorithm (), Serializer.Instance, opt.NewKBRStrictMode); _localDHT = new OnMemoryLocalHashTable (_kbr, dhtInt); _dht = new SimpleDHT (_kbr, _msock, _localDHT); _dht.RegisterTypeID (typeof (string), 0, new LocalHashTableValueMerger<string> ()); p2pncs.Net.Overlay.Anonymous.AnonymousRouter.DefaultRelayNodes = opt.AnonymousRouteRelays; p2pncs.Net.Overlay.Anonymous.AnonymousRouter.DefaultSubscribeRoutes = opt.AnonymousRouteRoutes + opt.AnonymousRouteBackupRoutes; p2pncs.Net.Overlay.Anonymous.AnonymousRouter.AC_DefaultUseSubscribeRoutes = opt.AnonymousRouteRoutes; _anonRouter = new AnonymousRouter (_dht, _nodePrivateKey, anonInt); _kbrStabilizeInt = kbrStabilizeInt; _kbrStabilizeInt.AddInterruption (_kbr.RoutingAlgorithm.Stabilize); _env = env; }
public Interrupters() { _msgInt = new IntervalInterrupter (TimeSpan.FromMilliseconds (100), "MessagingSocket Interval Interrupter"); _dhtInt = new IntervalInterrupter (TimeSpan.FromSeconds (1), "DHT Timeout Check Interrupter"); _kbrInt = new IntervalInterrupter (TimeSpan.FromSeconds (10), "KBR Stabilize Interval Interrupter"); _anonInt = new IntervalInterrupter (TimeSpan.FromMilliseconds (100), "AnonymousRouter Timeout Check Interrupter"); _updateCheckInt = new IntervalInterrupter (TimeSpan.FromMilliseconds (500), "WebApp UpdateChecker"); _messagingInt = new IntervalInterrupter (TimeSpan.FromMilliseconds (100), "AnonymousMessagingSocket RetryTimer"); _streamTimeoutInt = new IntervalInterrupter (TimeSpan.FromMilliseconds (100), "StreamSocket TimeoutTimer"); _mkdTimer = new IntervalInterrupter (TimeSpan.FromSeconds (5), "MassKeyDeliver Timer"); _dfsRePutTimer = new IntervalInterrupter (TimeSpan.FromSeconds (1), "DFS RePut Timer"); _crawlingInt = new IntervalInterrupter (TimeSpan.FromSeconds (10), "Crawling Timer"); _statInt = new IntervalInterrupter (TimeSpan.FromSeconds (1), "Statistics Update Thread"); _msgInt.Start (); _dhtInt.Start (); _kbrInt.Start (); _anonInt.Start (); _updateCheckInt.Start (); _messagingInt.Start (); _streamTimeoutInt.Start (); _mkdTimer.Start (); _dfsRePutTimer.Start (); _crawlingInt.Start (); _statInt.Start (); }
public FileInfoCrawler(ITcpListener listener, MMLC mmlc, IntervalInterrupter interrupter) { _listener = listener; _mmlc = mmlc; _int = interrupter; _listener.RegisterAcceptHandler (typeof (Request), Accepted); _int.AddInterruption (StartCrawling); }
public MassKeyDeliverer(IDistributedHashTable dht, IMassKeyDelivererLocalStore store, IntervalInterrupter timer) { _router = dht.KeyBasedRouter; _dht = dht; _sock = _router.MessagingSocket; _store = store; _int = timer; timer.AddInterruption (Deliver); _values = new List<DHTEntry> [_router.RoutingAlgorithm.MaxRoutingLevel]; for (int i = 0; i < _values.Length; i ++) _values[i] = new List<DHTEntry> (); _sock.AddInquiredHandler (typeof (Message), Messaging_Inquired); }
public WebApp(Node node, Interrupters ints) { _node = node; node.MMLC.Register (BBS.SimpleBBSParser.Instance); node.MMLC.Register (Wiki.WikiParser.Instance); _statInt = ints.StatisticsTimer; lock (_xslTemplate) { if (_threadInfoArray == null) { _statInt.AddInterruption (UpdateThreadStatistics); UpdateThreadStatistics (); } } _statInt.AddInterruption (UpdateStatistics); }
public void Evaluate(EvalOptionSet opt) { using (EvalEnvironment env = new EvalEnvironment (opt)) { env.AddNodes (opt.NumberOfNodes, true); env.StartChurn (); ISubscribeInfo subscribeInfo1 = env.Nodes[0].Subscribe (); ISubscribeInfo subscribeInfo2 = env.Nodes[1].Subscribe (); while (true) { if (subscribeInfo1.Status == SubscribeRouteStatus.Stable && subscribeInfo2.Status == SubscribeRouteStatus.Stable) break; Thread.Sleep (10); } bool routeEstablished = false; IAnonymousSocket sock1 = null, sock2 = null; StreamSocket strm1 = null, strm2 = null; do { int datasize = 1000 * 1000; IntervalInterrupter timeoutChecker = new IntervalInterrupter (TimeSpan.FromMilliseconds (100), "StreamSocket TimeoutChecker"); timeoutChecker.Start (); try { IAsyncResult ar = env.Nodes[0].AnonymousRouter.BeginConnect (subscribeInfo1.Key, subscribeInfo2.Key, AnonymousConnectionType.HighThroughput, null, null, null); sock1 = env.Nodes[0].AnonymousRouter.EndConnect (ar); if (env.Nodes[1].AnonymousSocketInfoList.Count == 0) throw new System.Net.Sockets.SocketException (); routeEstablished = true; sock2 = env.Nodes[1].AnonymousSocketInfoList[0].BaseSocket; strm1 = new StreamSocket (sock1, AnonymousRouter.DummyEndPoint, 500, timeoutChecker); strm2 = new StreamSocket (sock2, AnonymousRouter.DummyEndPoint, 500, timeoutChecker); sock1.InitializedEventHandlers (); sock2.InitializedEventHandlers (); Stopwatch sw = Stopwatch.StartNew (); byte[] data = new byte[datasize]; strm1.Send (data, 0, data.Length); strm1.Shutdown (); strm2.Shutdown (); Logger.Log (LogLevel.Info, this, "{0:f1}sec, {1:f2}Mbps", sw.Elapsed.TotalSeconds, datasize * 8 / sw.Elapsed.TotalSeconds / 1000.0 / 1000.0); } catch { } finally { timeoutChecker.Dispose (); if (sock1 != null) sock1.Dispose (); if (sock2 != null) sock2.Dispose (); if (strm1 != null) strm1.Dispose (); if (strm2 != null) strm2.Dispose (); } } while (!routeEstablished); } }
public StreamSocket(IDatagramEventSocket sock, EndPoint remoteEP, int max_datagram_size, TimeSpan init_RTT, IntervalInterrupter timeoutCheckInt) { _sock = sock; _mss = max_datagram_size - HeaderSize; _remoteEP = remoteEP; for (int i = 0; i < _sendBuffer.Length; i ++) _sendBuffer[i] = new Packet (max_datagram_size); _sock.Received += new DatagramReceiveEventHandler (Socket_Received); _timeoutCheckInt = timeoutCheckInt; _timeoutCheckInt.AddInterruption (CheckTimeout); _srtt = (int)init_RTT.TotalMilliseconds; _rttvar = _srtt / 2; _rto = _srtt + 4 * _rttvar; }
public KBREnvironment(bool enableDHT, bool enableAnon) { _network = new VirtualNetwork (LatencyTypes.Constant (20), 5, PacketLossType.Lossless (), 2); _interrupter = new IntervalInterrupter (TimeSpan.FromMilliseconds (50), "MessagingSocket Interrupter"); _interrupter.Start (); if (enableDHT || enableAnon) { _dhts = new List<IDistributedHashTable> (); _dhtInt = new IntervalInterrupter (TimeSpan.FromSeconds (5), "DHT Maintenance Interrupter"); _dhtInt.Start (); } if (enableAnon) { _anons = new List<IAnonymousRouter> (); _anonInt = new IntervalInterrupter (TimeSpan.FromMilliseconds (500), "Anonymous Interrupter"); _anonInt.Start (); } }
public MessagingSocket(IDatagramEventSocket sock, bool ownSocket, SymmetricKey key, IFormatter formatter, object nullObject, IntervalInterrupter interrupter, IRTOAlgorithm rtoAlgo, int maxRetry, int retryBufferSize, int inquiryDupCheckSize) : base(sock, ownSocket, interrupter, rtoAlgo, maxRetry, retryBufferSize, inquiryDupCheckSize) { _key = (key != null ? key : SymmetricKey.NoneKey); _formatter = formatter; _nullObject = nullObject != null ? nullObject : NullObject.Instance; sock.Received += Socket_Received; _maxMsgSize = sock.MaxDatagramSize; if (_key.AlgorithmType != SymmetricAlgorithmType.None && key.IV != null) { _maxMsgSize -= _maxMsgSize % key.IV.Length; if (key.Padding != System.Security.Cryptography.PaddingMode.None) _maxMsgSize --; if (key.EnableIVShuffle) _maxMsgSize -= key.IV.Length; } _maxMsgSize -= MAX_HEADER_SIZE; }
public EvalEnvironment(EvalOptionSet opt) { _opt = opt; _network = new VirtualNetwork (opt.GetLatency (), 5, opt.GetPacketLossRate (), Environment.ProcessorCount); _nodes = new List<VirtualNode> (); _msgInt1 = new IntervalInterrupter (TimeSpan.FromMilliseconds (50), "MessagingSocket Interrupter"); _msgInt2 = new IntervalInterrupter (TimeSpan.FromMilliseconds (50), "AnonymousMessagingSocket Interrupter"); _anonInt = new IntervalInterrupter (TimeSpan.FromMilliseconds (50), "Anonymous Interrupter"); _kbrInt = new IntervalInterrupter (TimeSpan.FromSeconds (10), "KBR Stabilize Interrupter"); _dhtInt = new IntervalInterrupter (TimeSpan.FromSeconds (10), "DHT Maintenance Interrupter"); _kbrInt.LoadEqualizing = true; _dhtInt.LoadEqualizing = true; _msgInt1.Start (); _msgInt2.Start (); _anonInt.Start (); _kbrInt.Start (); _dhtInt.Start (); if (opt.ChurnInterval > 0) _churnInt = new IntervalInterrupter (TimeSpan.FromMilliseconds (opt.ChurnInterval), "Churn Interrupter"); }
public Program() { _ints = new Interrupters (); _churnInt = new IntervalInterrupter (TimeSpan.FromSeconds (500.0 / NODES), "Churn Timer"); Directory.CreateDirectory ("db"); }
public StreamSocket(IDatagramEventSocket sock, EndPoint remoteEP, int max_datagram_size, IntervalInterrupter timeoutCheckInt) : this(sock, remoteEP, max_datagram_size, TimeSpan.FromSeconds (3), timeoutCheckInt) { }
public virtual void Init() { _formatter = Serializer.Instance; _interrupter = new IntervalInterrupter (TimeSpan.FromMilliseconds (10.0), "Test IntervalInterrupter"); _interrupter.Start (); }
public VirtualMessagingSocket(VirtualDatagramEventSocket baseSock, bool ownSocket, IntervalInterrupter interrupter, IRTOAlgorithm rtoAlgo, int maxRetry, int retryBufferSize, int inquiryDupCheckSize) : base(baseSock, ownSocket, interrupter, rtoAlgo, maxRetry, retryBufferSize, inquiryDupCheckSize) { baseSock.VirtualNetwork.AddVirtualMessagingSocketToVirtualNode (baseSock, this); }