Пример #1
0
        protected TransportAddress GetTransportAddress(int id)
        {
            string tas = String.Format("b.{0}://{1}",
                                       TransportAddress.TATypeToString(TAType), id);

            return(TransportAddressFactory.CreateInstance(tas));
        }
Пример #2
0
 public SimulationEdgeListener(int id, double loss_prob, TAAuthorizer ta_auth, bool use_delay) :
     this(id, loss_prob, ta_auth, use_delay, TransportAddress.TAType.S,
          new PublicNat(TransportAddressFactory.CreateInstance(
                            String.Format("b.{0}://{1}",
                                          TransportAddress.TATypeToString(TransportAddress.TAType.S), id))))
 {
 }
Пример #3
0
        /// <summary>Returns a Tunnel Sync message containing up to 40 addresses
        /// first starting with previous overlap followed by new potential
        /// connections for overlap.</summary>
        public virtual IDictionary GetSyncMessage(IList <Connection> current_overlap,
                                                  Address local_addr, ConnectionList cons)
        {
            Hashtable ht  = new Hashtable();
            DateTime  now = DateTime.UtcNow;

            if (current_overlap != null)
            {
                foreach (Connection con in current_overlap)
                {
                    Hashtable info = new Hashtable(2);
                    info["ta"] = TransportAddress.TATypeToString(con.Edge.TAType);
                    info["ct"] = (int)(now - con.CreationTime).TotalMilliseconds;
                    ht[con.Address.ToMemBlock()] = info;
                }
            }

            int idx = cons.IndexOf(local_addr);

            if (idx < 0)
            {
                idx = ~idx;
            }
            int max   = cons.Count < 16 ? cons.Count : 16;
            int start = idx - max / 2;
            int end   = idx + max / 2;

            for (int i = start; i < end; i++)
            {
                Connection con = cons[i];
                MemBlock   key = con.Address.ToMemBlock();
                if (ht.Contains(key))
                {
                    continue;
                }
                Hashtable info = new Hashtable();
                info["ta"] = TransportAddress.TATypeToString(con.Edge.TAType);
                info["ct"] = (int)(now - con.CreationTime).TotalMilliseconds;
                ht[key]    = info;
            }

            return(ht);
        }
Пример #4
0
        /**
         * <summary>This returns all the gathered information as a hashtable.
         * Particularly useful for crawling.</summary>
         * <returns>The dictionary (hashtable) containing the information about the
         * node.</returns>
         */
        public IDictionary Info()
        {
            GetGeoLoc();
            Hashtable ht = new Hashtable(UserData);

            ht.Add("type", _type);
            ht.Add("geo_loc", geo_loc);
            ht.Add("localips", _node.sys_link.GetLocalIPAddresses());
            ht.Add("neighbors", _node.sys_link.GetNeighbors());
            int wedge_count = 0;

            foreach (EdgeListener el in _node.EdgeListenerList)
            {
                WrapperEdgeListener wel = el as WrapperEdgeListener;
                if (wel != null)
                {
                    try {
                        wedge_count += el.Count;
                        ht.Add(TransportAddress.TATypeToString(wel.TAType), wel.UnderlyingCount);
                    } catch { }
                }
                else
                {
                    int count = 0;
                    try {
                        count = el.Count;
                    } catch { }
                    ht.Add(TransportAddress.TATypeToString(el.TAType), count);
                }
            }

            ht.Add("cons", _node.ConnectionTable.TotalCount);
            if (wedge_count != 0)
            {
                ht.Add("wedges", wedge_count);
            }
            if (_so != null)
            {
                ht.Add("sas", _so.SACount);
            }
            return(ht);
        }
Пример #5
0
        /// <summary>Returns a Relay Sync message containing all overlap and then
        /// the four fastest (if not included in the overlap.</summary>
        public override IDictionary GetSyncMessage(IList <Connection> current_overlap,
                                                   Address local_addr, ConnectionList cons)
        {
            Hashtable ht  = new Hashtable(40);
            DateTime  now = DateTime.UtcNow;

            if (current_overlap != null)
            {
                foreach (Connection con in current_overlap)
                {
                    Hashtable info = new Hashtable(3);
                    info["ta"]  = TransportAddress.TATypeToString(con.State.Edge.TAType);
                    info["lat"] = _ncservice.GetMeasuredLatency(con.Address);
                    info["ct"]  = (int)(now - con.CreationTime).TotalMilliseconds;
                    ht[con.Address.ToMemBlock()] = info;
                }
            }

            foreach (Connection con in GetClosest(cons))
            {
                MemBlock key = con.Address.ToMemBlock();
                if (ht.Contains(key))
                {
                    continue;
                }
                // No need to verify it is >= 0, since addr comes from cons in a
                // previous stage
                Hashtable info = new Hashtable(3);
                info["ta"]  = TransportAddress.TATypeToString(con.State.Edge.TAType);
                info["lat"] = _ncservice.GetMeasuredLatency(con.Address);
                info["ct"]  = (int)(now - con.CreationTime).TotalMilliseconds;
                ht[key]     = info;
            }

            return(ht);
        }
Пример #6
0
 public static string GetString(TransportAddress.TAType ta_type, int id)
 {
     return(String.Format("b.{0}://{1}", TransportAddress.TATypeToString(ta_type), id));
 }