// fine tune this to decide about sending speed:
network_time_seconds network_throttle::get_sleep_time(size_t packet_size) const 
{
	double D2=0;
	calculate_times_struct cts = { 0, 0, 0, 0};
	calculate_times(packet_size, cts, true, m_window_size); D2=cts.delay;
	return D2;
}
void network_throttle::_handle_trafic_exact(size_t packet_size, size_t orginal_size)
{
	tick();

	calculate_times_struct cts ;  calculate_times(packet_size, cts , false, -1);
	calculate_times_struct cts2;  calculate_times(packet_size, cts2, false, 5);
	m_history[0].m_size += packet_size;

	std::ostringstream oss; oss << "["; 	for (auto sample: m_history) oss << sample.m_size << " ";	 oss << "]" << std::ends;
	std::string history_str = oss.str();

	MTRACE("Throttle " << m_name << ": packet of ~"<<packet_size<<"b " << " (from "<<orginal_size<<" b)"
        << " Speed AVG=" << std::setw(4) <<  ((long int)(cts .average/1024)) <<"[w="<<cts .window<<"]"
        <<           " " << std::setw(4) <<  ((long int)(cts2.average/1024)) <<"[w="<<cts2.window<<"]"
				<<" / " << " Limit="<< ((long int)(m_target_speed/1024)) <<" KiB/sec "
				<< " " << history_str
		);
}
Esempio n. 3
0
	void TimeCache::recalculate(const glm::vec3& last_pos, const glm::quat& last_rot, const glm::vec3& last_scale, F32 last_net_time) {
		//Set current state as last predicted states
		last_predicted_pos = last_pos;
		last_predicted_rot = last_rot;
		last_predicted_scale = last_scale;
		//Update times and velocities
		calculate_times(last_net_time);
		calculate_velocities();
	}