Skip to content

Commit

Permalink
Adopt the different congestion control defaults as in Rust (#894)
Browse files Browse the repository at this point in the history
* Adopt the different congestion control defaults as in Rust

* Revert unnecessary changes

* void arg

* const functions are static inline

* Fix fragmentation test
  • Loading branch information
Mallets authored Feb 12, 2025
1 parent 25b8499 commit 5d7a490
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 20 deletions.
6 changes: 3 additions & 3 deletions include/zenoh-pico.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
#ifndef ZENOH_PICO_H
#define ZENOH_PICO_H

#define ZENOH_PICO "1.0.0.0"
#define ZENOH_PICO "1.2.1.0"
#define ZENOH_PICO_MAJOR 1
#define ZENOH_PICO_MINOR 0
#define ZENOH_PICO_PATCH 0
#define ZENOH_PICO_MINOR 2
#define ZENOH_PICO_PATCH 1
#define ZENOH_PICO_TWEAK 0

#include "zenoh-pico/api/constants.h"
Expand Down
14 changes: 12 additions & 2 deletions include/zenoh-pico/api/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,18 @@ typedef enum { Z_RELIABILITY_BEST_EFFORT = 1, Z_RELIABILITY_RELIABLE = 0 } z_rel
* Z_CONGESTION_CONTROL_DROP: Defines congestion control as ``DROP``. Messages are dropped in case
* of congestion control.
*/
typedef enum { Z_CONGESTION_CONTROL_BLOCK = 0, Z_CONGESTION_CONTROL_DROP = 1 } z_congestion_control_t;
#define Z_CONGESTION_CONTROL_DEFAULT Z_CONGESTION_CONTROL_BLOCK
typedef enum { Z_CONGESTION_CONTROL_BLOCK = 1, Z_CONGESTION_CONTROL_DROP = 0 } z_congestion_control_t;
#define Z_CONGESTION_CONTROL_DEFAULT Z_CONGESTION_CONTROL_DROP

static inline z_congestion_control_t z_internal_congestion_control_default_push(void) {
return Z_CONGESTION_CONTROL_DROP;
}
static inline z_congestion_control_t z_internal_congestion_control_default_request(void) {
return Z_CONGESTION_CONTROL_BLOCK;
}
static inline z_congestion_control_t z_internal_congestion_control_default_response(void) {
return Z_CONGESTION_CONTROL_BLOCK;
}

/**
* Priority of Zenoh messages values.
Expand Down
4 changes: 2 additions & 2 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zenoh-pico",
"version": "1.0.0.0",
"version": "1.2.1.0",
"description": "The Eclipse Zenoh: Zero Overhead Pub/sub, Store/Query and Compute. It unifies data in motion, data in-use, data at rest and computations. It carefully blends traditional pub/sub with geo-distributed storages, queries and computations, while retaining a level of time and space efficiency that is well beyond any of the mainstream stacks. Zenoh-Pico is the implementation able to scale down to extremely constrainded devices and networks.",
"keywords": [
"pubsub",
Expand Down Expand Up @@ -40,4 +40,4 @@
"build": {
"extraScript": "extra_script.py"
}
}
}
22 changes: 11 additions & 11 deletions src/api/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ _Z_OWNED_FUNCTIONS_VALUE_NO_COPY_IMPL(_z_publisher_t, publisher, _z_publisher_ch
_z_publisher_drop)

void z_put_options_default(z_put_options_t *options) {
options->congestion_control = Z_CONGESTION_CONTROL_DEFAULT;
options->congestion_control = z_internal_congestion_control_default_push();
options->priority = Z_PRIORITY_DEFAULT;
options->encoding = NULL;
options->is_express = false;
Expand All @@ -868,7 +868,7 @@ void z_put_options_default(z_put_options_t *options) {
}

void z_delete_options_default(z_delete_options_t *options) {
options->congestion_control = Z_CONGESTION_CONTROL_DEFAULT;
options->congestion_control = z_internal_congestion_control_default_push();
options->is_express = false;
options->timestamp = NULL;
options->priority = Z_PRIORITY_DEFAULT;
Expand Down Expand Up @@ -936,7 +936,7 @@ z_result_t z_delete(const z_loaned_session_t *zs, const z_loaned_keyexpr_t *keye

void z_publisher_options_default(z_publisher_options_t *options) {
options->encoding = NULL;
options->congestion_control = Z_CONGESTION_CONTROL_DEFAULT;
options->congestion_control = z_internal_congestion_control_default_push();
options->priority = Z_PRIORITY_DEFAULT;
options->is_express = false;
#ifdef Z_FEATURE_UNSTABLE_API
Expand Down Expand Up @@ -1159,7 +1159,7 @@ _Z_OWNED_FUNCTIONS_VALUE_IMPL(_z_reply_t, reply, _z_reply_check, _z_reply_null,
void z_get_options_default(z_get_options_t *options) {
options->target = z_query_target_default();
options->consolidation = z_query_consolidation_default();
options->congestion_control = Z_CONGESTION_CONTROL_DEFAULT;
options->congestion_control = z_internal_congestion_control_default_request();
options->priority = Z_PRIORITY_DEFAULT;
options->is_express = false;
options->encoding = NULL;
Expand Down Expand Up @@ -1225,7 +1225,7 @@ void z_querier_get_options_default(z_querier_get_options_t *options) {
void z_querier_options_default(z_querier_options_t *options) {
options->target = z_query_target_default();
options->consolidation = z_query_consolidation_default();
options->congestion_control = Z_CONGESTION_CONTROL_DEFAULT;
options->congestion_control = z_internal_congestion_control_default_request();
options->priority = Z_PRIORITY_DEFAULT;
options->is_express = false;
options->timeout_ms = Z_GET_TIMEOUT_DEFAULT;
Expand Down Expand Up @@ -1467,7 +1467,7 @@ z_result_t z_undeclare_queryable(z_moved_queryable_t *queryable) {

void z_query_reply_options_default(z_query_reply_options_t *options) {
options->encoding = NULL;
options->congestion_control = Z_CONGESTION_CONTROL_DEFAULT;
options->congestion_control = z_internal_congestion_control_default_response();
options->priority = Z_PRIORITY_DEFAULT;
options->timestamp = NULL;
options->is_express = false;
Expand Down Expand Up @@ -1505,7 +1505,7 @@ z_result_t z_query_reply(const z_loaned_query_t *query, const z_loaned_keyexpr_t
}

void z_query_reply_del_options_default(z_query_reply_del_options_t *options) {
options->congestion_control = Z_CONGESTION_CONTROL_DEFAULT;
options->congestion_control = z_internal_congestion_control_default_response();
options->priority = Z_PRIORITY_DEFAULT;
options->timestamp = NULL;
options->is_express = false;
Expand Down Expand Up @@ -1730,8 +1730,8 @@ z_result_t zp_batch_flush(const z_loaned_session_t *zs) {
if (_Z_RC_IS_NULL(zs)) {
return _Z_ERR_SESSION_CLOSED;
}
// Send current batch
return _z_send_n_batch(session, Z_CONGESTION_CONTROL_DEFAULT);
// Send current batch without dropping
return _z_send_n_batch(session, Z_CONGESTION_CONTROL_BLOCK);
}

z_result_t zp_batch_stop(const z_loaned_session_t *zs) {
Expand All @@ -1740,8 +1740,8 @@ z_result_t zp_batch_stop(const z_loaned_session_t *zs) {
return _Z_ERR_SESSION_CLOSED;
}
_z_transport_stop_batching(&session->_tp);
// Send remaining batch
return _z_send_n_batch(session, Z_CONGESTION_CONTROL_DEFAULT);
// Send remaining batch without dropping
return _z_send_n_batch(session, Z_CONGESTION_CONTROL_BLOCK);
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion tests/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def check_output(tx_status, tx_output, rx_status, rx_output):
# Expected rx output & status
z_rx_expected_status = 0
z_rx_expected_output = (
"[rx]: Received packet on test/zenoh-pico-fragment, len: 10000, validity: 1, qos {priority: 4, cong_ctrl: 0}")
"[rx]: Received packet on test/zenoh-pico-fragment, len: 10000, validity: 1, qos {priority: 4, cong_ctrl: 1}")

# Check the exit status of tx
if tx_status == z_tx_expected_status:
Expand Down
2 changes: 1 addition & 1 deletion zenohpico.pc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ prefix=/usr/local
Name: zenohpico
Description:
URL:
Version: 1.0.20241210dev
Version: 1.2.20250212dev
Cflags: -I${prefix}/include
Libs: -L${prefix}/lib -lzenohpico

0 comments on commit 5d7a490

Please sign in to comment.