mirror of
https://github.com/rtbrick/bngblaster.git
synced 2024-05-06 15:54:57 +00:00
@@ -450,6 +450,7 @@ Attribute | Description | Default
|
||||
`start-rate` | Setup request rate in sessions per second | 400
|
||||
`stop-rate` | Teardown request rate in sessions per second | 400
|
||||
`iterate-vlan-outer` | Iterate on outer VLAN first | false
|
||||
`start-delay` | Wait N seconds after all interface are resolved before starting sessions | 0
|
||||
|
||||
Per default sessions are created by iteration over inner VLAN range first and outer VLAN second.
|
||||
Which can be changed by `iterate-vlan-outer` to iterate on outer VLAN first and inner VLAN second.
|
||||
|
||||
@@ -246,6 +246,9 @@ bbl_ctrl_job (timer_s *timer)
|
||||
int rate = 0;
|
||||
uint32_t i;
|
||||
|
||||
struct timespec timestamp;
|
||||
struct timespec time_diff;
|
||||
|
||||
/* Setup phase ...
|
||||
* Wait for all network interfaces to be resolved. */
|
||||
if(g_init_phase && !g_teardown) {
|
||||
@@ -268,6 +271,7 @@ bbl_ctrl_job (timer_s *timer)
|
||||
}
|
||||
g_init_phase = false;
|
||||
LOG(INFO, "All network interfaces resolved\n");
|
||||
clock_gettime(CLOCK_MONOTONIC, &ctx->timestamp_resolved);
|
||||
}
|
||||
|
||||
if(ctx->sessions_outstanding) ctx->sessions_outstanding--;
|
||||
@@ -307,6 +311,14 @@ bbl_ctrl_job (timer_s *timer)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* Wait N seconds (default 0) before we start to setup sessions. */
|
||||
if(ctx->config.sessions_start_delay) {
|
||||
clock_gettime(CLOCK_MONOTONIC, ×tamp);
|
||||
timespec_sub(&time_diff, ×tamp, &ctx->timestamp_resolved);
|
||||
if(time_diff.tv_sec < ctx->config.sessions_start_delay) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
/* Iterate over all idle session (list of pending sessions)
|
||||
* and start as much as permitted per interval based on max
|
||||
* outstanding and setup rate. Sessions started will be removed
|
||||
|
||||
+3
-1
@@ -272,7 +272,9 @@ bbl_a10nsp_pppoes_handler(bbl_interface_s *interface,
|
||||
stream = *search;
|
||||
stream->packets_rx++;
|
||||
stream->rx_len = eth->length;
|
||||
stream->rx_priority = ((bbl_ipv4_t*)eth->next)->tos;
|
||||
stream->rx_priority = ipv4->tos;
|
||||
stream->rx_outer_vlan_pbit = eth->vlan_outer_priority;
|
||||
stream->rx_inner_vlan_pbit = eth->vlan_inner_priority;
|
||||
timespec_sub(&delay, ð->timestamp, &bbl->timestamp);
|
||||
delay_nsec = delay.tv_sec * 1e9 + delay.tv_nsec;
|
||||
if(delay_nsec > stream->max_delay_ns) {
|
||||
|
||||
@@ -879,6 +879,10 @@ json_parse_config (json_t *root, bbl_ctx_s *ctx) {
|
||||
if (json_is_boolean(value)) {
|
||||
ctx->config.iterate_outer_vlan = json_boolean_value(value);
|
||||
}
|
||||
value = json_object_get(section, "start-delay");
|
||||
if (json_is_number(value)) {
|
||||
ctx->config.sessions_start_delay = json_number_value(value);
|
||||
}
|
||||
}
|
||||
|
||||
/* IPoE Configuration */
|
||||
|
||||
@@ -36,6 +36,7 @@ typedef struct bbl_ctx_
|
||||
|
||||
struct timespec timestamp_start;
|
||||
struct timespec timestamp_stop;
|
||||
struct timespec timestamp_resolved;
|
||||
|
||||
uint32_t sessions;
|
||||
uint32_t sessions_pppoe;
|
||||
@@ -169,6 +170,8 @@ typedef struct bbl_ctx_
|
||||
uint32_t sessions_max_outstanding;
|
||||
uint16_t sessions_start_rate;
|
||||
uint16_t sessions_stop_rate;
|
||||
uint16_t sessions_start_delay;
|
||||
|
||||
bool iterate_outer_vlan;
|
||||
|
||||
/* Static */
|
||||
|
||||
+3
-1
@@ -1026,7 +1026,9 @@ bbl_l2tp_data_rx(bbl_ethernet_header_t *eth, bbl_l2tp_t *l2tp, bbl_interface_s *
|
||||
stream = *search;
|
||||
stream->packets_rx++;
|
||||
stream->rx_len = eth->length;
|
||||
stream->rx_priority = ((bbl_ipv4_t*)eth->next)->tos;
|
||||
stream->rx_priority = ipv4->tos;
|
||||
stream->rx_outer_vlan_pbit = eth->vlan_outer_priority;
|
||||
stream->rx_inner_vlan_pbit = eth->vlan_inner_priority;
|
||||
timespec_sub(&delay, ð->timestamp, &bbl->timestamp);
|
||||
delay_nsec = delay.tv_sec * 1e9 + delay.tv_nsec;
|
||||
if(delay_nsec > stream->max_delay_ns) {
|
||||
|
||||
+27
-25
@@ -148,6 +148,7 @@ bbl_stream_build_access_pppoe_packet(bbl_stream *stream) {
|
||||
bbl.outer_vlan_id = session->vlan_key.outer_vlan_id;
|
||||
bbl.inner_vlan_id = session->vlan_key.inner_vlan_id;
|
||||
bbl.flow_id = stream->flow_id;
|
||||
bbl.tos = config->priority;
|
||||
bbl.direction = BBL_DIRECTION_UP;
|
||||
|
||||
switch (stream->config->type) {
|
||||
@@ -263,10 +264,10 @@ bbl_stream_build_a10nsp_pppoe_packet(bbl_stream *stream) {
|
||||
eth.qinq = a10nsp_if->qinq;
|
||||
eth.vlan_outer = a10nsp_session->s_vlan;
|
||||
}
|
||||
eth.vlan_outer_priority = config->vlan_priority;
|
||||
eth.vlan_inner = session->vlan_key.inner_vlan_id;
|
||||
eth.vlan_inner_priority = config->vlan_priority;
|
||||
eth.vlan_three = session->access_third_vlan;
|
||||
eth.vlan_outer_priority = config->vlan_priority;
|
||||
eth.vlan_inner_priority = config->vlan_priority;
|
||||
eth.type = ETH_TYPE_PPPOE_SESSION;
|
||||
eth.next = &pppoe;
|
||||
pppoe.session_id = session->pppoe_session_id;
|
||||
@@ -280,7 +281,7 @@ bbl_stream_build_a10nsp_pppoe_packet(bbl_stream *stream) {
|
||||
bbl.outer_vlan_id = session->vlan_key.outer_vlan_id;
|
||||
bbl.inner_vlan_id = session->vlan_key.inner_vlan_id;
|
||||
bbl.flow_id = stream->flow_id;
|
||||
|
||||
bbl.tos = config->priority;
|
||||
switch (stream->config->type) {
|
||||
case STREAM_IPV4:
|
||||
pppoe.protocol = PROTOCOL_IPV4;
|
||||
@@ -388,10 +389,10 @@ bbl_stream_build_access_ipoe_packet(bbl_stream *stream) {
|
||||
eth.src = session->client_mac;
|
||||
eth.qinq = session->access_config->qinq;
|
||||
eth.vlan_outer = session->vlan_key.outer_vlan_id;
|
||||
eth.vlan_outer_priority = config->vlan_priority;
|
||||
eth.vlan_inner = session->vlan_key.inner_vlan_id;
|
||||
eth.vlan_inner_priority = config->vlan_priority;
|
||||
eth.vlan_three = session->access_third_vlan;
|
||||
eth.vlan_inner_priority = config->vlan_priority;
|
||||
eth.vlan_outer_priority = config->vlan_priority;
|
||||
|
||||
udp.src = BBL_UDP_PORT;
|
||||
udp.dst = BBL_UDP_PORT;
|
||||
@@ -403,6 +404,7 @@ bbl_stream_build_access_ipoe_packet(bbl_stream *stream) {
|
||||
bbl.outer_vlan_id = session->vlan_key.outer_vlan_id;
|
||||
bbl.inner_vlan_id = session->vlan_key.inner_vlan_id;
|
||||
bbl.flow_id = stream->flow_id;
|
||||
bbl.tos = config->priority;
|
||||
bbl.direction = BBL_DIRECTION_UP;
|
||||
|
||||
switch (stream->config->type) {
|
||||
@@ -519,6 +521,7 @@ bbl_stream_build_network_packet(bbl_stream *stream) {
|
||||
bbl.inner_vlan_id = session->vlan_key.inner_vlan_id;
|
||||
}
|
||||
bbl.flow_id = stream->flow_id;
|
||||
bbl.tos = config->priority;
|
||||
bbl.direction = BBL_DIRECTION_DOWN;
|
||||
switch (stream->config->type) {
|
||||
case STREAM_IPV4:
|
||||
@@ -667,6 +670,7 @@ bbl_stream_build_l2tp_packet(bbl_stream *stream) {
|
||||
bbl.outer_vlan_id = session->vlan_key.outer_vlan_id;
|
||||
bbl.inner_vlan_id = session->vlan_key.inner_vlan_id;
|
||||
bbl.flow_id = stream->flow_id;
|
||||
bbl.tos = config->priority;
|
||||
bbl.direction = BBL_DIRECTION_DOWN;
|
||||
bbl.sub_type = BBL_SUB_TYPE_IPV4;
|
||||
if (config->length > 76) {
|
||||
@@ -1177,6 +1181,7 @@ bbl_stream_add(bbl_ctx_s *ctx, bbl_access_config_s *access_config, bbl_session_s
|
||||
bbl_stream *stream;
|
||||
bbl_stream *session_stream;
|
||||
bbl_stream_thread *thread;
|
||||
bbl_interface_s *network_if;
|
||||
|
||||
dict_insert_result result;
|
||||
|
||||
@@ -1184,28 +1189,25 @@ bbl_stream_add(bbl_ctx_s *ctx, bbl_access_config_s *access_config, bbl_session_s
|
||||
long timer_nsec = 0;
|
||||
|
||||
config = ctx->config.stream_config;
|
||||
|
||||
/* *
|
||||
* The corresponding network interfaces will be selected
|
||||
* in the following order:
|
||||
* - "network-interface" from stream section
|
||||
* - "network-interface" from access interface section
|
||||
* - first network interface from network section (default)
|
||||
*/
|
||||
bbl_interface_s *network_if;
|
||||
if(config->network_interface) {
|
||||
network_if = bbl_get_network_interface(ctx, config->network_interface);
|
||||
} else if(config->a10nsp_interface) {
|
||||
network_if = bbl_get_a10nsp_interface(ctx, config->a10nsp_interface);
|
||||
} else {
|
||||
network_if = session->network_interface;
|
||||
}
|
||||
if(!network_if) {
|
||||
return false;
|
||||
}
|
||||
|
||||
while(config) {
|
||||
if(config->stream_group_id == access_config->stream_group_id) {
|
||||
/* *
|
||||
* The corresponding network interfaces will be selected
|
||||
* in the following order:
|
||||
* - "network-interface" from stream section
|
||||
* - "network-interface" from access interface section
|
||||
* - first network interface from network section (default)
|
||||
*/
|
||||
if(config->network_interface) {
|
||||
network_if = bbl_get_network_interface(ctx, config->network_interface);
|
||||
} else if(config->a10nsp_interface) {
|
||||
network_if = bbl_get_a10nsp_interface(ctx, config->a10nsp_interface);
|
||||
} else {
|
||||
network_if = session->network_interface;
|
||||
}
|
||||
if(!network_if) {
|
||||
return false;
|
||||
}
|
||||
if(!network_if) {
|
||||
LOG(ERROR, "Failed to add stream because of missing network interface\n");
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user