aboutsummaryrefslogtreecommitdiff
path: root/example/ndpiReader.c
diff options
context:
space:
mode:
authorLuca Deri <deri@ntop.org>2021-02-04 23:52:33 +0100
committerLuca Deri <deri@ntop.org>2021-02-04 23:52:33 +0100
commit1eedf734be7b2cfe2ac5e0d497c19c77b877ae2f (patch)
tree5c30c0b644bb68cc333fe0be59eb33682403922a /example/ndpiReader.c
parent54636a32131b4cc348b3e2154c2f441cb7678e4c (diff)
Implemented API for computing RSI (Relative Strenght Index)
void ndpi_init_rsi(struct ndpi_rsi_struct *s, u_int16_t num_learning_values); void ndpi_free_rsi(struct ndpi_rsi_struct *s); float ndpi_rsi_add_value(struct ndpi_rsi_struct *s, const u_int32_t value);
Diffstat (limited to 'example/ndpiReader.c')
-rw-r--r--example/ndpiReader.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/example/ndpiReader.c b/example/ndpiReader.c
index 5fbf9ebe2..a4fb74246 100644
--- a/example/ndpiReader.c
+++ b/example/ndpiReader.c
@@ -3690,6 +3690,30 @@ void rulesUnitTest() {
/* *********************************************** */
+void rsiUnitTest() {
+ struct ndpi_rsi_struct s;
+ unsigned int v[] = {
+ 2227, 2219, 2208, 2217, 2218, 2213, 2223, 2243, 2224, 2229,
+ 2215, 2239, 2238, 2261, 2336, 2405, 2375, 2383, 2395, 2363,
+ 2382, 2387, 2365, 2319, 2310, 2333, 2268, 2310, 2240, 2217,
+ };
+ u_int i, n = sizeof(v) / sizeof(unsigned int);
+
+ ndpi_init_rsi(&s, 8);
+
+ for(i=0; i<n; i++) {
+ float rsi = ndpi_rsi_add_value(&s, v[i]);
+
+#if 0
+ printf("%2d) RSI = %f\n", i, rsi);
+#endif
+ }
+
+ ndpi_free_rsi(&s);
+}
+
+/* *********************************************** */
+
void hashUnitTest() {
ndpi_str_hash *h = ndpi_hash_alloc(16384);
char* dict[] = { "hello", "world", NULL };
@@ -3731,6 +3755,7 @@ int orginal_main(int argc, char **argv) {
/* Internal checks */
// binUnitTest();
+ rsiUnitTest();
hashUnitTest();
dgaUnitTest();
hllUnitTest();