Loading...
Searching...
No Matches
congure.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Freie Universität Berlin
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
29#ifndef NET_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE_H
30#define NET_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE_H
31
32#include <stdbool.h>
33#include <stdlib.h>
34
35#include "congure.h"
36#include "modules.h"
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
46#define GNRC_SIXLOWPAN_FRAG_SFR_CONGURE_UNIT (1U)
47
48#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE) || DOXYGEN
68#else
70{
71 return NULL;
72}
73#endif
74
90{
91#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE)
92 c->driver = NULL;
93#else
94 (void)c;
95#endif
96}
97
108{
109#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE)
111 fb->sfr.congure = NULL;
112#else
113 (void)fb;
114#endif
115}
116
126{
127#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE)
128 fb->sfr.congure->driver->init(fb->sfr.congure, fb);
129#else
130 (void)fb;
131#endif
132}
133
144{
145#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE)
146 if (fb->sfr.congure == NULL) {
147 fb->sfr.congure = gnrc_sixlowpan_frag_sfr_congure_snd_get();
148 assert(fb->sfr.congure);
150 if (fb->sfr.congure->cwnd > CONFIG_GNRC_SIXLOWPAN_SFR_MAX_WIN_SIZE) {
151 fb->sfr.congure->cwnd = CONFIG_GNRC_SIXLOWPAN_SFR_MAX_WIN_SIZE;
152 }
153 }
154#else
155 (void)fb;
156#endif
157}
158
176{
177#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE)
178 return fb->sfr.frags_sent < fb->sfr.congure->cwnd;
179#else
180 return fb->sfr.frags_sent < CONFIG_GNRC_SIXLOWPAN_SFR_OPT_WIN_SIZE;
181#endif
182}
183
201{
202#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE)
203 return (fb->sfr.frags_sent + GNRC_SIXLOWPAN_FRAG_SFR_CONGURE_UNIT)
204 < fb->sfr.congure->cwnd;
205#else
206 return (fb->sfr.frags_sent + GNRC_SIXLOWPAN_FRAG_SFR_CONGURE_UNIT)
208#endif
209}
210
221{
223 IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE);
224}
225
247 )
248{
249#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE)
250 if (fb != NULL) {
251 congure_snd_t *c = fb->sfr.congure;
252 int32_t res = c->driver->inter_msg_interval(
254 );
255
256 if ((res >= 0) &&
258 return (uint32_t)res;
259 }
260 }
261#else
262 (void)fb;
263#endif
265}
266
280 )
281{
282#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE)
283 congure_snd_t *c = fb->sfr.congure;
284
286#else
287 (void)fb;
288#endif
289}
290
304 )
305{
306#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE)
307 congure_snd_t *c = fb->sfr.congure;
308
310#else
311 (void)fb;
312#endif
313}
314
328 )
329{
330#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE)
331 congure_snd_t *c = fb->sfr.congure;
332
333 c->driver->report_msgs_timeout(c, (congure_snd_msg_t *)(&fb->sfr.window));
334#else
335 (void)fb;
336#endif
337}
338
354 )
355{
356#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE)
357 congure_snd_t *c = fb->sfr.congure;
358
359 c->driver->report_msgs_lost(c, frags);
360#else
361 (void)fb;
362 (void)frags;
363#endif
364}
365
381 congure_snd_msg_t *frag,
383 )
384{
385#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE)
386 congure_snd_t *c = fb->sfr.congure;
387
388 c->driver->report_msg_acked(c, frag, ack);
391 }
392#else
393 (void)fb;
394 (void)frag;
395 (void)ack;
396#endif
397}
398
413 gnrc_sixlowpan_frag_fb_t *fb, uint32_t time
414 )
415{
416#if IS_USED(MODULE_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE)
417 congure_snd_t *c = fb->sfr.congure;
418
419 c->driver->report_ecn_ce(c, (ztimer_now_t)time);
420#else
421 (void)fb;
422 (void)time;
423#endif
424}
425
426#ifdef __cplusplus
427}
428#endif
429
430#endif /* NET_GNRC_SIXLOWPAN_FRAG_SFR_CONGURE_H */
#define assert(cond)
abort the program if assertion is false
Definition assert.h:137
6LoWPAN selective fragment recovery definitions for GNRC
#define CONFIG_GNRC_SIXLOWPAN_SFR_OPT_WIN_SIZE
Default value of window size that the sender should start with (OptWindowSize)
Definition config.h:251
#define CONFIG_GNRC_SIXLOWPAN_SFR_INTER_FRAME_GAP_US
Default minimum amount of time between transmissions in microseconds (InterFrameGap)
Definition config.h:267
#define CONFIG_GNRC_SIXLOWPAN_SFR_MAX_WIN_SIZE
Default maximum value of window size that the sender can use (MaxWindowSize)
Definition config.h:239
static void gnrc_sixlowpan_frag_sfr_congure_snd_report_frags_timeout(gnrc_sixlowpan_frag_fb_t *fb)
Report to CongURE that the ACK for a fragment timed out.
Definition congure.h:326
static bool gnrc_sixlowpan_frag_sfr_congure_snd_next_in_cwnd(gnrc_sixlowpan_frag_fb_t *fb)
Checks if given fragmentation buffer entry would still be within congestion window after next send.
Definition congure.h:200
static void gnrc_sixlowpan_frag_sfr_congure_snd_setup(gnrc_sixlowpan_frag_fb_t *fb)
Retrieve CongURE state object when not retrieved and initialize it for a fragmentation buffer entry.
Definition congure.h:143
static void gnrc_sixlowpan_frag_sfr_congure_snd_report_frags_lost(gnrc_sixlowpan_frag_fb_t *fb, congure_snd_msg_t *frags)
Report to CongURE that a number of fragments are known to be lost.
Definition congure.h:352
static void gnrc_sixlowpan_frag_sfr_congure_snd_free(congure_snd_t *c)
Frees the CongURE state object.
Definition congure.h:89
static bool gnrc_sixlowpan_frag_sfr_congure_snd_has_inter_frame_gap(void)
Checks if inter-frame gap is provided.
Definition congure.h:220
static void gnrc_sixlowpan_frag_sfr_congure_snd_report_frag_sent(gnrc_sixlowpan_frag_fb_t *fb)
Report to CongURE that a fragment was sent.
Definition congure.h:278
static void gnrc_sixlowpan_frag_sfr_congure_snd_destroy(gnrc_sixlowpan_frag_fb_t *fb)
Frees the CongURE state object of a fragmentation buffer and set's it to NULL
Definition congure.h:107
congure_snd_t * gnrc_sixlowpan_frag_sfr_congure_snd_get(void)
Retrieve CongURE state object from a pool of free objects.
static void gnrc_sixlowpan_frag_sfr_congure_snd_report_frag_discard(gnrc_sixlowpan_frag_fb_t *fb)
Report to CongURE that a fragment as discarded.
Definition congure.h:302
static void gnrc_sixlowpan_frag_sfr_congure_snd_init(gnrc_sixlowpan_frag_fb_t *fb)
Initializes a CongURE state object in a fragmentation buffer entry.
Definition congure.h:125
static uint32_t gnrc_sixlowpan_frag_sfr_congure_snd_inter_frame_gap(gnrc_sixlowpan_frag_fb_t *fb)
Returns inter-frame gap if provided by CongURE implementation.
Definition congure.h:245
static void gnrc_sixlowpan_frag_sfr_congure_snd_report_ecn(gnrc_sixlowpan_frag_fb_t *fb, uint32_t time)
Report to CongURE that ECN bit was set in an ACK.
Definition congure.h:412
static bool gnrc_sixlowpan_frag_sfr_congure_snd_in_cwnd(gnrc_sixlowpan_frag_fb_t *fb)
Checks if given fragmentation buffer entry is within congestion window.
Definition congure.h:175
static void gnrc_sixlowpan_frag_sfr_congure_snd_report_frag_acked(gnrc_sixlowpan_frag_fb_t *fb, congure_snd_msg_t *frag, congure_snd_ack_t *ack)
Report to CongURE that a number of fragments are known to be lost.
Definition congure.h:379
#define GNRC_SIXLOWPAN_FRAG_SFR_CONGURE_UNIT
The user-defined window unit for congure is one fragment with SFR.
Definition congure.h:46
uint32_t ztimer_now_t
type for ztimer_now() result
Definition ztimer.h:323
Common macros and compiler attributes/pragmas configuration.
#define IS_USED(module)
Checks whether a module is being used or not.
Definition modules.h:71
Congure definitions for 6LoWPAN selective fragment recovery.
Object to represent an ACK to a message.
Definition congure.h:86
void(* report_msg_sent)(congure_snd_t *c, unsigned msg_size)
Report that a message was sent.
Definition congure.h:150
void(* report_msgs_lost)(congure_snd_t *c, congure_snd_msg_t *msgs)
Report that a collection of messages that is known to be lost.
Definition congure.h:196
void(* report_ecn_ce)(congure_snd_t *c, ztimer_now_t time)
Report that "congestion encountered" CE signals were received for a message by means of explicit cong...
Definition congure.h:217
void(* report_msgs_timeout)(congure_snd_t *c, congure_snd_msg_t *msgs)
Report that the ACKs for a collection of messages timed out.
Definition congure.h:177
int32_t(* inter_msg_interval)(congure_snd_t *c, unsigned msg_size)
Get current interval between messages for pacing.
Definition congure.h:142
void(* report_msg_discarded)(congure_snd_t *c, unsigned msg_size)
Report message as discarded.
Definition congure.h:162
void(* report_msg_acked)(congure_snd_t *c, congure_snd_msg_t *msg, congure_snd_ack_t *ack)
Report that the ACK for a message was received.
Definition congure.h:205
Object to represent a collection of sent messages.
Definition congure.h:68
Base state object for CongURE implementations.
Definition congure.h:51
const congure_snd_driver_t * driver
Driver for the state object.
Definition congure.h:55
congure_wnd_size_t cwnd
Congestion window size.
Definition congure.h:62
6LoWPAN fragmentation buffer entry.
Definition fb.h:47