Example #1
0
void writeProgagationSection(std::ostream& out,
                             Config& config,
                             ChannelSet& channels)
{
    out << "# Propagation" << std::endl;
    for (size_t i=0; i<channels.size(); i++)
    {
        std::stringstream channel;
        channel << "[" << i << "]";
        out << config.getParameter(
            std::string("PROPAGATION-CHANNEL-FREQUENCY") + channel.str())
            << std::endl;
        out << config.getParameter(
            std::string("PROPAGATION-LIMIT") + channel.str())
            << std::endl;
        out << config.getParameter(
            std::string("PROPAGATION-PATHLOSS-MODEL") + channel.str())
            << std::endl;
        out << config.getParameter(
            std::string("PROPAGATION-SHADOWING-MODEL") + channel.str())
            << std::endl;
        out << config.getParameter(
            std::string("PROPAGATION-SHADOWING-MEAN") + channel.str())
            << std::endl;
        out << config.getParameter(
            std::string("PROPAGATION-FADING-MODEL") + channel.str())
            << std::endl;
        out << std::endl;
    }
}
Example #2
0
static int try_send_request()
{
	if (g_limit > 0 && g_sent_count >= g_limit)
	{
		stop_serv();
		return 0;
	}
	uint64 now = get_current_monotonic_millis();

	if (g_tp10ms > 0 && g_count_in_10msperiod >= g_tp10ms)
	{

		if (g_period_task_id == -1)
		{
			if (g_count_in_1speriod >= g_options.tps)
			{
				uint64 delay_1s = 0;
				if (now >= g_1s_transc_start_time + 1000)
				{
					delay_1s = 0;
				} else
				{
					delay_1s = (g_1s_transc_start_time + 1000) - now;
				}
				g_period_task_id = g_serv->GetTimer().ScheduleHeapTask(
						make_fun_runnable(start_1s_period_task, true), delay_1s,
						-1);
			} else
			{
				uint64 delay_10ms = 0;
				if (now >= g_10ms_transc_start_time + 10)
				{
					delay_10ms = 0;
				} else
				{
					delay_10ms = (g_10ms_transc_start_time + 10) - now;
				}
				g_period_task_id = g_serv->GetTimer().ScheduleHeapTask(
						make_fun_runnable(start_10ms_period_task, true),
						delay_10ms, -1);
			}
		}

		return 0;
	}
	if (!g_ready_channels.empty())
	{
		ChannelSet::iterator it = g_ready_channels.begin();
		HttpClientHandler* client = *it;
		client->m_request_sent = true;
		Buffer& data = get_request_data();
		client->m_client->Write(data);
		data.SetReadIndex(0);
		g_ready_channels.erase(it);
		g_count_in_10msperiod++;
		g_sent_count++;
		g_ratio_sent_req++;
		g_count_in_1speriod++;
		return 1;
	} else
	{
		if (g_all_channels.size() < g_options.concurrentConns)
		{
			http_client_connect(g_options.host.c_str(), g_options.port);
		}
	}
	return 0;
}