- measurement_running = GNUNET_NO;
- struct GNUNET_TIME_Relative duration
- = GNUNET_TIME_absolute_get_difference(start_time, GNUNET_TIME_absolute_get());
-
-
- if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
- {
- GNUNET_SCHEDULER_cancel (measurement_counter_task);
- measurement_counter_task = GNUNET_SCHEDULER_NO_TASK;
- }
-
- if (transmit_handle != NULL)
- {
- GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
- transmit_handle = NULL;
- }
-
- if (current_quota_p1 < current_quota_p2)
- quota_allowed = current_quota_p1;
- else
- quota_allowed = current_quota_p2;
-
-
- if (MEASUREMENT_SOFT_LIMIT > (quota_allowed/3))
- delta = MEASUREMENT_SOFT_LIMIT;
- else
- delta = (quota_allowed/3);
-
- /* Throughput is far too slow. This is to prevent the test to exit with success when throughput is 0 */
- if ((total_bytes_sent/(duration.rel_value / 1000)) < 100)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "\nQuota compliance failed: \n" \
- "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n" \
- "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n" \
- "Throughput : %10llu kB/s (%llu B/s)\n",
- (quota_allowed / (1024)), quota_allowed,
- ((quota_allowed+delta) / (1024)), quota_allowed+delta,
- (total_bytes_sent/(duration.rel_value / 1000)/1024),
- total_bytes_sent/(duration.rel_value / 1000));
- ok = 1;
- failed_measurement_counter--;
- if (failed_measurement_counter < 0)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "\nQuota measurement failed and no free strike: %i\n",
- failed_measurement_counter);
- end();
- return;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "\nQuota measurement failed and %i free strikes\n",
- failed_measurement_counter);
- }
-
- /* Throughput is bigger than allowed quota + some extra*/
- if ((total_bytes_sent/(duration.rel_value / 1000)) > (quota_allowed + delta))
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "\nQuota compliance failed: \n" \
- "Hard quota limit allowed: %10llu kB/s (%llu B/s)\n" \
- "Soft quota limit allowed: %10llu kB/s (%llu B/s)\n" \
- "Throughput : %10llu kB/s (%llu B/s)\n",
- (quota_allowed / (1024)), quota_allowed,
- ((quota_allowed+delta) / (1024)), quota_allowed+delta,
- (total_bytes_sent/(duration.rel_value / 1000)/1024),
- total_bytes_sent/(duration.rel_value / 1000));
- ok = 1;
- failed_measurement_counter--;
- if (failed_measurement_counter < 0)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "\nQuota measurement failed and no free strike: %i\n",failed_measurement_counter);
- end();
- return;
- }
- else
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "\nQuota measurement failed and %i free strikes\n",failed_measurement_counter);
- }
- else
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "\nQuota compliance ok: \n" \
- "Quota allowed: %10llu kB/s\n" \
- "Throughput : %10llu kB/s\n",
- (quota_allowed / (1024)),
- (total_bytes_sent/(duration.rel_value / 1000)/1024));
- if (failed_measurement_counter < 2)
- failed_measurement_counter++;
- ok = 0;
- }
-
- if ((quota_allowed) > (2 *(total_bytes_sent/(duration.rel_value / 1000))))
- {
- if (failed_measurement_counter < 2)
- failed_measurement_counter++;
- if (strike_counter == 2)
- {
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Maximum transmission rate reached, stopping test\n");
- end();
- return;
- }
- }
- else
- {
- strike_counter = 0;
- }
-
- if (quota_allowed == MEASUREMENT_MAX_QUOTA)
- {
- end();
- return;
- }
- if (is_asymmetric_send_constant == GNUNET_YES)
- {
- if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
- measure (current_quota_p1 * 2, MEASUREMENT_MAX_QUOTA);
- else
- measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
- }
- else if (is_asymmetric_recv_constant == GNUNET_YES)
- {
- if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
- measure (MEASUREMENT_MAX_QUOTA, current_quota_p2 * 2);
- else
- measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
- }
- else
- {
- if ((quota_allowed * 2) < MEASUREMENT_MAX_QUOTA)
- measure ((current_quota_p1) * 2, (current_quota_p2) * 2);
- else
- measure (MEASUREMENT_MAX_QUOTA, MEASUREMENT_MAX_QUOTA);
- }
-}
-
-static void
-measure (unsigned long long quota_p1, unsigned long long quota_p2)
-{
- current_quota_p1 = quota_p1;
- current_quota_p2 = quota_p2;
-#if VERBOSE
- if ((is_asymmetric_send_constant == GNUNET_YES) || (is_asymmetric_recv_constant == GNUNET_YES))
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Starting transport level measurement for %u seconds, receiving peer quota %llu kB/s, sending peer quota %llu kB/s\n",
- MEASUREMENT_INTERVALL.rel_value / 1000 ,
- current_quota_p1 / 1024,
- current_quota_p2 / 1024);
- else
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Starting transport level measurement for %u seconds, symmetric quota %llu kB/s\n",
- MEASUREMENT_INTERVALL.rel_value / 1000,
- current_quota_p2 / 1024);
-
-#endif
- GNUNET_TRANSPORT_set_quota (p1.th,
- &p2.id,
- GNUNET_BANDWIDTH_value_init (current_quota_p1),
- GNUNET_BANDWIDTH_value_init (current_quota_p1));
- GNUNET_TRANSPORT_set_quota (p2.th,
- &p1.id,
- GNUNET_BANDWIDTH_value_init (current_quota_p2),
- GNUNET_BANDWIDTH_value_init (current_quota_p2));
- GNUNET_SCHEDULER_cancel (die_task);
- die_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
- &end_badly,
- NULL);
- if (measurement_counter_task != GNUNET_SCHEDULER_NO_TASK)
- GNUNET_SCHEDULER_cancel (measurement_counter_task);
- measurement_counter_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
- &measurement_counter,
- NULL);
- measurement_task = GNUNET_SCHEDULER_add_delayed (MEASUREMENT_INTERVALL,
- &measurement_end,
- NULL);
- total_bytes_sent = 0;
- last_msg_sent = 0;
- last_msg_recv = 0;
- measurement_running = GNUNET_YES;
- start_time = GNUNET_TIME_absolute_get ();
-
- if (transmit_handle != NULL)
- GNUNET_TRANSPORT_notify_transmit_ready_cancel(transmit_handle);
- transmit_handle = GNUNET_TRANSPORT_notify_transmit_ready (p2.th,
- &p1.id,
- get_size (), 0, SEND_TIMEOUT,
- ¬ify_ready,
- NULL);