Skip to content

Commit 2f93551

Browse files
authored
Merge pull request #74 from insa-unyte/development
v0.5.0
2 parents fb722db + 3ab8c86 commit 2f93551

32 files changed

+985
-147
lines changed

.gitignore

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ sender_sample
55
test_seg
66
test_queue
77
test_malloc
8+
test_segmentation
89
test_version
910
sender_json
1011
libunyte-udp-notif.so
1112
scripts/resources
13+
examples/resources
1214
sender_continuous
1315
client_continuous
1416
client_monitoring
17+
client_socket
1518

1619
docker/tmp
1720

@@ -23,3 +26,57 @@ vgcore.*
2326
unyte-udp-notif.pc
2427
scripts/graph.eps
2528
.editorconfig
29+
30+
Makefile.in
31+
/ar-lib
32+
/mdate-sh
33+
/py-compile
34+
/test-driver
35+
/ylwrap
36+
.deps/
37+
.libs/
38+
.dirstamp
39+
build-aux/
40+
build/
41+
libtool
42+
config.h
43+
44+
# http://www.gnu.org/software/autoconf
45+
46+
autom4te.cache
47+
/autoscan.log
48+
/autoscan-*.log
49+
/aclocal.m4
50+
/compile
51+
/config.cache
52+
/config.guess
53+
/config.h.in
54+
/config.log
55+
/config.status
56+
/config.sub
57+
/configure
58+
/configure.scan
59+
/depcomp
60+
/install-sh
61+
/missing
62+
/stamp-h1
63+
64+
# https://www.gnu.org/software/libtool/
65+
66+
/ltmain.sh
67+
68+
# http://www.gnu.org/software/texinfo
69+
70+
/texinfo.tex
71+
72+
# http://www.gnu.org/software/m4/
73+
74+
m4/libtool.m4
75+
m4/ltoptions.m4
76+
m4/ltsugar.m4
77+
m4/ltversion.m4
78+
m4/lt~obsolete.m4
79+
80+
*.lo
81+
Makefile
82+
libunyte-udp-notif.la

CONTRIBUTING

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Contributing
2+
3+
When contributing to this repository, please first discuss the change you wish to make via issue,
4+
email, or any other method with the owners of this repository before making a change.
5+
6+
Please note we have a code of conduct, please follow it in all your interactions with the project.
7+
8+
## Pull Request Process
9+
10+
1. Ensure any install or build dependencies are removed before the end of the layer when doing a
11+
build.
12+
2. Update the README.md with details of changes to the interface, this includes new environment
13+
variables, exposed ports, useful file locations and container parameters.
14+
3. Increase the version numbers in any examples files and the README.md to the new version that this
15+
Pull Request would represent if a bump version is required.
16+
17+
## Code of Conduct
18+
19+
### Our Pledge
20+
21+
In the interest of fostering an open and welcoming environment, we as
22+
contributors and maintainers pledge to making participation in our project and
23+
our community a harassment-free experience for everyone, regardless of age, body
24+
size, disability, ethnicity, gender identity and expression, level of experience,
25+
nationality, personal appearance, race, religion, or sexual identity and
26+
orientation.
27+
28+
### Our Standards
29+
30+
Examples of behavior that contributes to creating a positive environment
31+
include:
32+
33+
* Using welcoming and inclusive language
34+
* Being respectful of differing viewpoints and experiences
35+
* Gracefully accepting constructive criticism
36+
* Focusing on what is best for the community
37+
* Showing empathy towards other community members
38+
39+
Examples of unacceptable behavior by participants include:
40+
41+
* The use of sexualized language or imagery and unwelcome sexual attention or
42+
advances
43+
* Trolling, insulting/derogatory comments, and personal or political attacks
44+
* Public or private harassment
45+
* Publishing others' private information, such as a physical or electronic
46+
address, without explicit permission
47+
* Other conduct which could reasonably be considered inappropriate in a
48+
professional setting
49+
50+
### Our Responsibilities
51+
52+
Project maintainers are responsible for clarifying the standards of acceptable
53+
behavior and are expected to take appropriate and fair corrective action in
54+
response to any instances of unacceptable behavior.
55+
56+
Project maintainers have the right and responsibility to remove, edit, or
57+
reject comments, commits, code, wiki edits, issues, and other contributions
58+
that are not aligned to this Code of Conduct, or to ban temporarily or
59+
permanently any contributor for other behaviors that they deem inappropriate,
60+
threatening, offensive, or harmful.
61+
62+
### Scope
63+
64+
This Code of Conduct applies both within project spaces and in public spaces
65+
when an individual is representing the project or its community. Examples of
66+
representing a project or community include using an official project e-mail
67+
address, posting via an official social media account, or acting as an appointed
68+
representative at an online or offline event. Representation of a project may be
69+
further defined and clarified by project maintainers.
70+
71+
### Enforcement
72+
73+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
74+
reported by contacting the project team at alex.huang-feng@insa-lyon.fr. All
75+
complaints will be reviewed and investigated and will result in a response that
76+
is deemed necessary and appropriate to the circumstances. The project team is
77+
obligated to maintain confidentiality with regard to the reporter of an incident.
78+
Further details of specific enforcement policies may be posted separately.
79+
80+
Project maintainers who do not follow or enforce the Code of Conduct in good
81+
faith may face temporary or permanent repercussions as determined by other
82+
members of the project's leadership.
83+
84+
### Attribution
85+
86+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
87+
available at [http://contributor-covenant.org/version/1/4][version]
88+
89+
[homepage]: http://contributor-covenant.org
90+
[version]: http://contributor-covenant.org/version/1/4/

INSTALL.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Compiling and installing UDP-notif collector
2+
3+
## Dependencies
4+
This project uses autotools and gcc to compile and package the library.
5+
6+
On Ubuntu:
7+
```shell
8+
$ sudo apt-get install autoconf libtool make automake gcc pkg-config
9+
```
10+
11+
On Centos (tested on `Centos 8`):
12+
```shell
13+
$ sudo yum install autoconf libtool make automake pkgconf
14+
```
15+
16+
### Optional Dependencies
17+
#### Using tcmalloc (Optional)
18+
This project can use tcmalloc for memory management allowing better performance.
19+
20+
On Ubuntu:
21+
```shell
22+
$ sudo apt-get install libgoogle-perftools-dev
23+
```
24+
25+
On Centos (tested on `Centos 8`):
26+
```shell
27+
$ sudo yum install gperftools gperftools-devel
28+
```
29+
30+
## Installing
31+
To install the library on a linux machine.
32+
```shell
33+
$ ./bootstrap
34+
$ ./configure # See ./configure --help for options
35+
$ make
36+
$ make install # Usually needs sudo permissions
37+
$ ./export.sh # Optional: export LD_LIBRARY_PATH with /usr/local/lib in global variable to allow linking process
38+
```
39+
40+
### Configure options
41+
There are some custom `./configure` options :
42+
- `--with-examples`: compile examples directory. Not compiled by default.
43+
- `--with-test`: compile testdirectory. Not compiled by default.
44+
- `--with-pkgconfigdir=[/own_path/pkgconfig]`: overwrite pkgconfig directory to install .pc file [default: ${PREFIX}/lib/pkgconfig]
45+
- `--enable-tcmalloc`: enable compilation with tcmalloc instead of native malloc. tcmalloc should be installed first.
46+
47+
## Uninstalling
48+
```shell
49+
$ make uninstall # Usually need sudo permissions
50+
```
51+
You should remove the export of the lib in your bashrc manually yourself to fully remove the lib.

Makefile.am

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
AM_LDFLAGS = $(EXTRA_LDFLAGS)
2+
3+
SUBDIRS = src
4+
5+
if EXAMPLES
6+
SUBDIRS += examples
7+
endif
8+
9+
if TEST_FILES
10+
SUBDIRS += test
11+
endif
12+
13+
ACLOCAL_AMFLAGS = -I m4
14+
15+
# PKGCONFIG_USER comes from configure.ac
16+
pkgconfigdir = $(PKGCONFIG_USER)
17+
pkgconfig_DATA = \
18+
unyte-udp-notif.pc \
19+
$(NULL)

README.md

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,21 @@
11
# C-Collector for UDP-notif
2-
Library for collecting UDP-notif protocol messages defined in the IETF draft [draft-ietf-netconf-udp-notif-01](https://tools.ietf.org/html/draft-ietf-netconf-udp-notif-01).
2+
Library for collecting UDP-notif protocol messages defined in the IETF draft [draft-ietf-netconf-udp-notif-03](https://datatracker.ietf.org/doc/html/draft-ietf-netconf-udp-notif-03).
33

4-
## Build & install
5-
To build the project and test example clients, just `make` on root folder. Il will compile with gcc all dependencies and the clients.
6-
7-
### Installing
8-
To install the library on a machine, run `make install` with sudo and `export.sh` without sudo. Export script will export the LD_LIBRARY_PATH on user space.
9-
```
10-
$ make
11-
$ sudo make install
12-
$ ./export.sh
13-
```
14-
15-
### Uninstalling
16-
```
17-
$ sudo make uninstall
18-
```
19-
You should remove the export of the lib in your bashrc manually yourself to fully remove the lib.
4+
## Compiling and installing project
5+
See [INSTALL](INSTALL.md)
206

217
## Usage
228
### Usage of the UDP-notif collector
239
The collector allows to read and parse UDP-notif protocol messages from a ip/port specified on the parameters. It allows to get directly the buffer and the metadata of the message in a struct.
2410

25-
The api is in `unyte_udp_collector.h` :
11+
The api is in `unyte_udp_collector.h`:
2612
- `unyte_udp_collector_t *unyte_udp_start_collector(unyte_udp_options_t *options)` from `unyte_udp_collector.h`: Initialize the UDP-notif messages collector. It accepts a struct with different options: address (the IP address to listen to), port (port to listen to), recvmmsg_vlen (vlen used on recvmmsg syscall meaning how many messages to receive on every syscall, by default 10)
13+
- `unyte_udp_collector_t *unyte_udp_start_collector_sk(unyte_udp_sk_options_t *options)` from `unyte_udp_collector.h`: Initialize the UDP-notif messages collector binded to a socket. It accepts a struct with different options: socket file descriptor to listen on, recvmmsg_vlen (vlen used on recvmmsg syscall meaning how many messages to receive on every syscall, by default 10)
2714
- `void *unyte_udp_queue_read(unyte_udp_queue_t *queue)` from `unyte_udp_queue.h` : read from a queue a struct with all the message buffer and metadata.
2815
- `int unyte_udp_free_all(unyte_seg_met_t *seg)` from `unyte_udp_collector.h`: free all struct used on a message received.
2916

3017
Simple example of usage :
31-
```
18+
```c
3219
#include <stdio.h>
3320
#include <stdlib.h>
3421
#include <pthread.h>
@@ -42,7 +29,7 @@ Simple example of usage :
4229
#include <unyte-udp-notif/unyte_udp_utils.h>
4330
#include <unyte-udp-notif/unyte_udp_queue.h>
4431

45-
#define PORT 10001
32+
#define PORT "10001"
4633
#define ADDR "192.168.0.17"
4734

4835
int main()
@@ -75,9 +62,8 @@ int main()
7562
printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg));
7663
printf("unyte_udp_get_generator_id: %u\n", unyte_udp_get_generator_id(seg));
7764
printf("unyte_udp_get_message_id: %u\n", unyte_udp_get_message_id(seg));
78-
printf("unyte_udp_get_src_port: %u\n", unyte_udp_get_src_port(seg));
79-
printf("unyte_udp_get_src_addr: %u\n", unyte_udp_get_src_addr(seg));
80-
printf("unyte_udp_get_dest_addr: %u\n", unyte_udp_get_dest_addr(seg));
65+
printf("unyte_udp_get_src[family]: %u\n", unyte_udp_get_src(seg)->ss_family); // AF_INET for IPv4 or AF_INET6 for IPv6
66+
printf("unyte_udp_get_dest_addr[family]: %u\n", unyte_udp_get_dest_addr(seg)->ss_family); // AF_INET for IPv4 or AF_INET6 for IPv6
8167
printf("unyte_udp_get_payload: %s\n", unyte_udp_get_payload(seg));
8268
printf("unyte_udp_get_payload_length: %u\n", unyte_udp_get_payload_length(seg));
8369

@@ -100,7 +86,7 @@ int main()
10086

10187
#### Segments data
10288
To process the message data, all the headers, meta-data and payload are found on the struct unyte_seg_met_t defined on unyte_udp_utils.h:
103-
```
89+
```c
10490
typedef struct unyte_segment_with_metadata
10591
{
10692
unyte_metadata_t *metadata; // source/port
@@ -116,20 +102,19 @@ typedef struct unyte_segment_with_metadata
116102
- `uint16_t unyte_udp_get_message_length(unyte_seg_met_t *message);` : total length of the message within one UDP datagram, measured in octets, including the message header
117103
- `uint32_t unyte_udp_get_generator_id(unyte_seg_met_t *message);` : observation domain id of the message
118104
- `uint32_t unyte_udp_get_message_id(unyte_seg_met_t *message);` : message id of the message
119-
- `uint16_t unyte_udp_get_src_port(unyte_seg_met_t *message);` : source port of the message
120-
- `uint32_t unyte_udp_get_src_addr(unyte_seg_met_t *message);` : source address of the message
121-
- `uint32_t unyte_udp_get_dest_addr(unyte_seg_met_t *message);` : collector address
105+
- `struct sockaddr_storage * unyte_udp_get_src(unyte_seg_met_t *message);` : source IP and port of the message. Could be IPv4 or IPv6.
106+
- `struct sockaddr_storage * unyte_udp_get_dest_addr(unyte_seg_met_t *message);` : collector address. Could be IPv4 or IPv6.
122107
- `char *unyte_udp_get_payload(unyte_seg_met_t *message);` : payload buffer
123108
- `uint16_t unyte_udp_get_payload_length(unyte_seg_met_t *message);` : payload length
124109

125110
#### Monitoring of the lib
126111
There is a monitoring thread that could be started to monitor packets loss and packets received in bad order.
127112
To activate this thread, you must initiate the monitoring thread queue size (`monitoring_queue_size`):
128-
```
113+
```c
129114
typedef struct
130115
{
131116
char *address;
132-
uint16_t port;
117+
char *port;
133118
...
134119
uint monitoring_queue_size; // monitoring queue size if wanted to activate the monitoring thread. Default: 0. Recommended: 500.
135120
uint monitoring_delay; // monitoring queue frequence in seconds. Default: 5 seconds
@@ -152,7 +137,7 @@ The sender allows the user to send UDP-notif protocol to a IP/port specified. It
152137

153138
The api is in `unyte_sender.h`.
154139
The message to send have the following structure:
155-
```
140+
```c
156141
typedef struct unyte_message
157142
{
158143
uint used_mtu; // MTU to use for cutting the message to segments
@@ -169,15 +154,15 @@ typedef struct unyte_message
169154
```
170155

171156
Simple usage of the sender :
172-
```
157+
```c
173158
#include <pthread.h>
174159
#include <stdio.h>
175160
#include <stdlib.h>
176161

177162
#include <unyte-udp-notif/unyte_sender.h>
178163
#include <unyte-udp-notif/unyte_udp_utils.h>
179164

180-
#define PORT 10001
165+
#define PORT "10001"
181166
#define ADDR "192.168.0.17"
182167
#define MTU 1500
183168

@@ -218,8 +203,10 @@ int main()
218203
```
219204

220205
### Examples
221-
There are some samples implemented during the development of the project [here](samples).
206+
There are some samples implemented during the development of the project [here](examples).
222207
- `client_sample.c` : simple example for minimal usage of the collector library.
208+
- `client_monitoring.c` : sample implementing the monitoring thread to read packets statistics.
209+
- `client_socket.c` : example using a custom socket instead of creating a new one from the library.
223210
- `sender_sample.c` : simple example for minimal usage of the sender library.
224211
- `sender_json.c` : sample reading a json file and sending the bytes by the library.
225212

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.5.0-git

bootstrap

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
3+
# create m4 directory if does not exist
4+
[ -d m4 ] || mkdir m4
5+
6+
AUTORECONF=${AUTORECONF:-autoreconf}
7+
8+
# Check we have all tools installed
9+
check_command() {
10+
command -v "${1}" > /dev/null 2>&1 || {
11+
>&2 echo "./bootstrap: could not find \`$1'. \`$1' is required to run bootstrap."
12+
exit 1
13+
}
14+
}
15+
16+
check_command "$AUTORECONF"
17+
18+
autoreconf --install
19+
20+
exit 0

0 commit comments

Comments
 (0)