1 /*
2  * Copyright (C) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef FILLP_FC_ALG0_H
17 #define FILLP_FC_ALG0_H
18 
19 #include "fillp/fillp_pcb.h"
20 #include "fillp/fillp.h"
21 #include "fillp_flow_control.h"
22 
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #define FILLP_FC0_DEFAULT_RATE 200000
29 
30 #define FILLP_FC0_PACK_RECV_INTERVAL_SAMPLE_NUM 20   /* num of the interval in two adjacent PACK received  */
31 
32 enum FillpFcAlg0State {
33     FILLP_FC0_STATE_INIT,
34     FILLP_FC0_STATE_BW_PROBE
35 };
36 
37 struct FillpRttSample {
38     FILLP_LLONG t; /* rtt time */
39     FILLP_LLONG v; /* rtt value */
40 };
41 
42 #define FILLP_FC0_PROBE_HISTORY_PACK_MAX_RATE_NUM 11
43 
44 struct FillpFlowControlAlg0 {
45     struct FillpFlowControl *flowControl;
46     FILLP_UINT32 maxRecvRate;          /* kbps */
47     FILLP_UINT32 maxRateAllowed;
48     FILLP_UINT8 fcState;             /* is rate detecting or stable */
49     FILLP_UINT8 historyMaxRecvRateIndex;
50     struct FillpMaxRateSample historyMaxRecvRate; /* State for the parameterized max tracker */
51     FILLP_UINT8 sendRateIncreaseGainIndex;
52     FILLP_UINT32 packDeltaUsArrayIndex;
53     FILLP_UINT32 packDeltaUsArray[FILLP_FC0_PACK_RECV_INTERVAL_SAMPLE_NUM];
54 };
55 
56 #ifdef __cplusplus
57 }
58 #endif
59 
60 #endif /* FILLP_FC_ALG0_H */
61