Added charon.send/receive_delay options to simulate different RTTs
This commit is contained in:
@@ -99,6 +99,11 @@ struct private_receiver_t {
|
|||||||
* how many half open IKE_SAs per peer before blocking
|
* how many half open IKE_SAs per peer before blocking
|
||||||
*/
|
*/
|
||||||
u_int32_t block_threshold;
|
u_int32_t block_threshold;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delay for receiving incoming packets, to simulate larger RTT
|
||||||
|
*/
|
||||||
|
u_int receive_delay;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -325,7 +330,15 @@ static job_requeue_t receive_packets(private_receiver_t *this)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
job = (job_t*)process_message_job_create(message);
|
job = (job_t*)process_message_job_create(message);
|
||||||
charon->processor->queue_job(charon->processor, job);
|
if (this->receive_delay)
|
||||||
|
{
|
||||||
|
charon->scheduler->schedule_job_ms(charon->scheduler,
|
||||||
|
job, this->receive_delay);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
charon->processor->queue_job(charon->processor, job);
|
||||||
|
}
|
||||||
return JOB_REQUEUE_DIRECT;
|
return JOB_REQUEUE_DIRECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,6 +372,9 @@ receiver_t *receiver_create()
|
|||||||
this->block_threshold = lib->settings->get_int(lib->settings,
|
this->block_threshold = lib->settings->get_int(lib->settings,
|
||||||
"charon.block_threshold", BLOCK_THRESHOLD_DEFAULT);
|
"charon.block_threshold", BLOCK_THRESHOLD_DEFAULT);
|
||||||
}
|
}
|
||||||
|
this->receive_delay = lib->settings->get_int(lib->settings,
|
||||||
|
"charon.receive_delay", 0);
|
||||||
|
|
||||||
this->hasher = lib->crypto->create_hasher(lib->crypto, HASH_PREFERRED);
|
this->hasher = lib->crypto->create_hasher(lib->crypto, HASH_PREFERRED);
|
||||||
if (this->hasher == NULL)
|
if (this->hasher == NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
* for more details.
|
* for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "sender.h"
|
#include "sender.h"
|
||||||
@@ -61,6 +62,11 @@ struct private_sender_t {
|
|||||||
* condvar to signal for packets sent
|
* condvar to signal for packets sent
|
||||||
*/
|
*/
|
||||||
condvar_t *sent;
|
condvar_t *sent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delay for sending outgoing packets, to simulate larger RTT
|
||||||
|
*/
|
||||||
|
int send_delay;
|
||||||
};
|
};
|
||||||
|
|
||||||
METHOD(sender_t, send_, void,
|
METHOD(sender_t, send_, void,
|
||||||
@@ -72,6 +78,11 @@ METHOD(sender_t, send_, void,
|
|||||||
dst = packet->get_destination(packet);
|
dst = packet->get_destination(packet);
|
||||||
DBG1(DBG_NET, "sending packet: from %#H to %#H", src, dst);
|
DBG1(DBG_NET, "sending packet: from %#H to %#H", src, dst);
|
||||||
|
|
||||||
|
if (this->send_delay)
|
||||||
|
{
|
||||||
|
usleep(this->send_delay * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
this->mutex->lock(this->mutex);
|
this->mutex->lock(this->mutex);
|
||||||
this->list->insert_last(this->list, packet);
|
this->list->insert_last(this->list, packet);
|
||||||
this->got->signal(this->got);
|
this->got->signal(this->got);
|
||||||
@@ -143,6 +154,8 @@ sender_t * sender_create()
|
|||||||
.sent = condvar_create(CONDVAR_TYPE_DEFAULT),
|
.sent = condvar_create(CONDVAR_TYPE_DEFAULT),
|
||||||
.job = callback_job_create((callback_job_cb_t)send_packets,
|
.job = callback_job_create((callback_job_cb_t)send_packets,
|
||||||
this, NULL, NULL),
|
this, NULL, NULL),
|
||||||
|
.send_delay = lib->settings->get_int(lib->settings,
|
||||||
|
"charon.send_delay", 0),
|
||||||
);
|
);
|
||||||
|
|
||||||
charon->processor->queue_job(charon->processor, (job_t*)this->job);
|
charon->processor->queue_job(charon->processor, (job_t*)this->job);
|
||||||
|
|||||||
Reference in New Issue
Block a user