utp_socket_manager::utp_socket_manager(session_settings const& sett, udp_socket& s , incoming_utp_callback_t cb) : m_sock(s) , m_cb(cb) , m_last_socket(0) , m_new_connection(-1) , m_sett(sett) , m_last_route_update(min_time()) , m_last_if_update(min_time()) , m_sock_buf_size(0) {}
void _mstream_congestion_ack(struct congestion_info* cinfo, time_val rtt, time_val now) { if(rtt) { // printf("GOT RTT %llu %llu\n", cinfo->rtt, rtt); int shft = cinfo->slow_start ? 2 : 4; if(!cinfo->slow_start) { /* Don't allow rtt to grow too quickly. */ rtt = min_time(rtt, cinfo->rtt << 1); } cinfo->spacing /= cinfo->rtt; cinfo->rtt = ((cinfo->rtt << shft) - cinfo->rtt + rtt) >> shft; if(cinfo->rtt == 0) { cinfo->rtt = 1; } cinfo->spacing *= cinfo->rtt; cinfo->rtt_ssq = ((cinfo->rtt_ssq << shft) - cinfo->rtt_ssq + rtt * rtt) >> shft; if(!cinfo->slow_start) { if((cinfo->rtt_trigger_next == 0 || (stime_val)(now - cinfo->rtt_trigger_next) >= 0) && cinfo->rtt >= cinfo->rtt_trigger) { printf("RTT BACKOFF\n"); cinfo->spacing *= 1.3; if(cinfo->spacing > 3e6) { cinfo->spacing = 3e6; } cinfo->rtt_trigger = cinfo->rtt + (cinfo->rtt >> 2) + 1000; cinfo->rtt_trigger_next = now + (cinfo->rtt << 1); } else { cinfo->rtt_trigger = min_time(cinfo->rtt_trigger, cinfo->rtt + (cinfo->rtt >> 2) + 1000); } }
node_entry::node_entry() : last_queried(min_time()) , id(nullptr) , rtt(0xffff) , timeout_count(0xff) { #ifndef TORRENT_DISABLE_LOGGING first_seen = aux::time_now(); #endif }
dos_blocker::dos_blocker() : m_message_rate_limit(5) , m_block_timeout(5 * 60) { for (int i = 0; i < num_ban_nodes; ++i) { m_ban_nodes[i].count = 0; m_ban_nodes[i].limit = min_time(); } }
utp_socket_manager::utp_socket_manager(aux::session_settings const& sett , udp_socket& s , counters& cnt , void* ssl_context , incoming_utp_callback_t cb) : m_sock(s) , m_cb(cb) , m_last_socket(0) , m_new_connection(-1) , m_sett(sett) , m_last_route_update(min_time()) , m_last_if_update(min_time()) , m_sock_buf_size(0) , m_counters(cnt) , m_mtu_idx(0) , m_ssl_context(ssl_context) { m_restrict_mtu.fill(65536); }
dos_blocker::dos_blocker() : m_message_rate_limit(5) , m_block_timeout(5 * 60) { for (auto& e : m_ban_nodes) { e.count = 0; e.limit = min_time(); } }
node_entry::node_entry() : last_queried(min_time()) , id(0) , p(0) , rtt(0xffff) , timeout_count(0xff) { #ifdef TORRENT_DHT_VERBOSE_LOGGING first_seen = aux::time_now(); #endif }
node_entry::node_entry(udp::endpoint ep) : last_queried(min_time()) , id(0) , a(ep.address().to_v4().to_bytes()) , p(ep.port()) , rtt(0xffff) , timeout_count(0xff) { #ifdef TORRENT_DHT_VERBOSE_LOGGING first_seen = aux::time_now(); #endif }
node_entry::node_entry(node_id const& id_, udp::endpoint const& ep , int roundtriptime , bool pinged) : last_queried(pinged ? aux::time_now() : min_time()) , id(id_) , endpoint(ep) , rtt(roundtriptime & 0xffff) , timeout_count(pinged ? 0 : 0xff) { #ifndef TORRENT_DISABLE_LOGGING first_seen = aux::time_now(); #endif }
node_entry::node_entry(node_id const& id_, udp::endpoint ep , int roundtriptime , bool pinged) : last_queried(pinged ? aux::time_now() : min_time()) , id(id_) , a(ep.address().to_v4().to_bytes()) , p(ep.port()) , rtt(roundtriptime & 0xffff) , timeout_count(pinged ? 0 : 0xff) { #ifdef TORRENT_DHT_VERBOSE_LOGGING first_seen = aux::time_now(); #endif }
bool DeltaGantry::get_move(LinearMove &move) { if (!update_next_pos()) { return false; } update_next_steps(); update_next_unit_direction(); update_steps(move.steps); move.cruise_speed = std::min(requested_speed, length/min_time(move.steps)); move.acceleration = std::min(requested_acc, length/min_time2(move.steps)); move.entry_speed = max_entry_speed(requested_acc); move.length = length; last = next; return true; }
time_duration rpc_manager::tick() { INVARIANT_CHECK; const static int short_timeout = 1; const static int timeout = 8; // look for observers that have timed out if (m_transactions.empty()) return seconds(short_timeout); std::list<observer_ptr> timeouts; time_duration ret = seconds(short_timeout); ptime now = time_now(); #if defined TORRENT_DEBUG || TORRENT_RELEASE_ASSERTS ptime last = min_time(); for (transactions_t::iterator i = m_transactions.begin(); i != m_transactions.end(); ++i) { TORRENT_ASSERT((*i)->sent() >= last); last = (*i)->sent(); } #endif for (transactions_t::iterator i = m_transactions.begin(); i != m_transactions.end();) { observer_ptr o = *i; // if we reach an observer that hasn't timed out // break, because every observer after this one will // also not have timed out yet time_duration diff = now - o->sent(); if (diff < seconds(timeout)) { ret = seconds(timeout) - diff; break; } #ifdef TORRENT_DHT_VERBOSE_LOGGING TORRENT_LOG(rpc) << "[" << o->m_algorithm.get() << "] Timing out transaction id: " << (*i)->transaction_id() << " from " << o->target_ep(); #endif m_transactions.erase(i++); timeouts.push_back(o); } std::for_each(timeouts.begin(), timeouts.end(), boost::bind(&observer::timeout, _1)); timeouts.clear(); for (transactions_t::iterator i = m_transactions.begin(); i != m_transactions.end(); ++i) { observer_ptr o = *i; // if we reach an observer that hasn't timed out // break, because every observer after this one will // also not have timed out yet time_duration diff = now - o->sent(); if (diff < seconds(short_timeout)) { ret = seconds(short_timeout) - diff; break; } if (o->has_short_timeout()) continue; // TODO: don't call short_timeout() again if we've // already called it once timeouts.push_back(o); } std::for_each(timeouts.begin(), timeouts.end(), boost::bind(&observer::short_timeout, _1)); return ret; }
uint64_t precise_local_tick_count() { return (boost::posix_time::microsec_clock::universal_time()-min_time()).total_milliseconds()TIME_INACCURACY_TEST; }
metadata_piece(): num_requests(0), last_request(min_time()) {}
int main(int argc, char **argv){ if(argc<2){ printf("Usage: ./trace domain \n for example: ./trace www.utdallas.edu\n"); exit(0); } char command[200]; strcpy(command, "traceroute "); strcat(command, argv[1]); strcat(command, " > output.txt"); system(command); FILE * fp; char * line = NULL; size_t len = 0; ssize_t read; char *token; char delimiter[5] = " (),"; char* strArray[12]; fp = fopen("output.txt", "r"); // open file if (fp == NULL) exit(EXIT_FAILURE); int line_number = 0; int currentLine = 0; int tokenNumber = 0; float time[3]; float min, max, avg; while ((read = getline(&line, &len, fp)) != -1) { //while line present do following printf("%s", line); tokenNumber = 0; token = strtok(line, delimiter); // token separated if(currentLine == 0) { //code for fist line while(token != NULL) { strArray[tokenNumber] = (char*)malloc(strlen(token) + 1); strcpy(strArray[tokenNumber], token); //token copy tokenNumber++; token = strtok(NULL, delimiter); } printf("DNS = %s\nIP = %s\n\n",strArray[2],strArray[3]); currentLine++; } else { //code for other lines while(token != NULL) { strArray[tokenNumber] = (char*)malloc(strlen(token) + 1); strcpy(strArray[tokenNumber], token); if(tokenNumber == 3) { time[0] = atof(strArray[tokenNumber]); //time token saved by converting it to float } if(tokenNumber == 5) { time[1] = strtod(strArray[tokenNumber],NULL); //time token saved by converting it to float } if(tokenNumber == 7) { time[2] = strtod(strArray[tokenNumber],NULL); //time token saved by converting it to float } tokenNumber++; token = strtok(NULL, delimiter); } min = min_time(time, 3); //find min max = max_time(time, 3); // find max avg = avg_time(time, 3); // find avg printf("DNS = %s\nIP = %s\n",strArray[1],strArray[2]); printf( "time 1 = %f, time 2 = %f, time 3 = %f\n",time[0], time[1], time[2]); printf( "min time = %f\nmax time = %f\navg time = %f\n\n",min, max, avg); } } fclose(fp); //close file printf(" ** end of mytrace program ** \n"); }