Add network emulation feature.
[sim/o1-interface.git] / ntsimulator / ntsim-ng / utils / network_emulation.h
1 /*************************************************************************
2 *
3 * Copyright 2020 highstreet technologies GmbH and others
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 ***************************************************************************/
17
18 #pragma once
19
20 #include <stdint.h>
21
22 typedef struct {
23     uint16_t limit;
24
25     struct {
26         uint16_t time;
27         uint16_t jitter;
28         uint16_t correlation;
29         char *distribution;
30     } delay;
31
32     uint16_t loss;
33
34     struct {
35         uint16_t percentage;
36         uint16_t correlation;
37     } corruption;
38
39     struct {
40         uint16_t percentage;
41         uint16_t correlation;
42     } duplication;
43
44     struct {
45         uint16_t percentage;
46         uint16_t correlation;
47     } reordering;
48
49     uint16_t rate;
50 } network_emultation_settings_t;
51
52 #define NETWORK_EMULATION_DEFAULT_LIMIT         "1000"
53
54 int network_emulation_init(void);
55 int network_emulation_update(const network_emultation_settings_t *s);