Skip to content

Commit

Permalink
Merge pull request #87 from insa-unyte/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
ahuangfeng authored May 30, 2022
2 parents 74bcb67 + 2c798a2 commit 3e89d7c
Show file tree
Hide file tree
Showing 29 changed files with 268 additions and 465 deletions.
6 changes: 3 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Copyright (c) 2020 Unyte Project members
Authors Tom Sampic, Axel Rosensthiel, Alex Huang, Pierre Francois, Stéphane Frénot
Authors Tom Sampic, Axel Rosensthiel, Alex Huang Feng, Pierre Francois, Stéphane Frénot
WIRED Team
Telecommunications Department
INSA Lyon
contact: <pierre-francois@insa-lyon.fr>
contact: <pierre-francois@insa-lyon.fr>;<alex.huang-feng@insa-lyon.fr>


Permission to use, copy, modify, and distribute this software for any
Expand All @@ -20,4 +20,4 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.


This code is an implementation of a collector for UDP-Notif messages as defined in
draft-ietf-netconf-udp-notif-01
draft-ietf-netconf-udp-notif-06
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# C-Collector for UDP-notif
Library for collecting UDP-notif protocol messages defined in the IETF draft [draft-ietf-netconf-udp-notif-04](https://datatracker.ietf.org/doc/html/draft-ietf-netconf-udp-notif-04).
Library for collecting UDP-notif protocol messages defined in the IETF draft [draft-ietf-netconf-udp-notif-06](https://datatracker.ietf.org/doc/html/draft-ietf-netconf-udp-notif-06).

## Compiling and installing project
See [INSTALL](INSTALL.md)
Expand All @@ -10,7 +10,7 @@ The collector allows to read and parse UDP-notif protocol messages from a ip/por

The api is in `unyte_udp_collector.h`:
- `int unyte_udp_create_socket(char *address, char *port, uint64_t buffer_size)` from `unyte_udp_utils.h`: Helper that creates and binds a socket to an address and port.
- `int unyte_udp_create_interface_bound_socket(char *interface, char *address, char *port, uint64_t buffer_size)` from `unyte_udp_utils.h`: Helper that creates a socket, binds it to an interface using SO_BINDTODEVICE option and binds it to an adress and port.
- `int unyte_udp_create_interface_bound_socket(char *interface, char *address, char *port, uint64_t buffer_size)` from `unyte_udp_utils.h`: Helper that creates a socket, binds it to an interface using SO_BINDTODEVICE option and binds it to an address and port.
- `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: socketfd of the socket to listen to, recvmmsg_vlen (vlen used on recvmmsg syscall meaning how many messages to receive on every syscall, by default 10)...
- `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.
- `int unyte_udp_free_all(unyte_seg_met_t *seg)` from `unyte_udp_collector.h`: free all struct used on a message received.
Expand Down Expand Up @@ -62,10 +62,10 @@ int main()
// TODO: Process the UDP-notif message here
printf("unyte_udp_get_version: %u\n", unyte_udp_get_version(seg));
printf("unyte_udp_get_space: %u\n", unyte_udp_get_space(seg));
printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg));
printf("unyte_udp_get_media_type: %u\n", unyte_udp_get_media_type(seg));
printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg));
printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg));
printf("unyte_udp_get_generator_id: %u\n", unyte_udp_get_generator_id(seg));
printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg));
printf("unyte_udp_get_message_id: %u\n", unyte_udp_get_message_id(seg));
printf("unyte_udp_get_src[family]: %u\n", unyte_udp_get_src(seg)->ss_family); // AF_INET for IPv4 or AF_INET6 for IPv6
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
Expand Down Expand Up @@ -100,12 +100,12 @@ typedef struct unyte_segment_with_metadata
} unyte_seg_met_t;
```
##### Getters for segments data
- `uint8_t unyte_udp_get_version(unyte_seg_met_t *message);` : encoding version
- `uint8_t unyte_udp_get_space(unyte_seg_met_t *message);` : space of encoding version
- `uint8_t unyte_udp_get_encoding_type(unyte_seg_met_t *message);` : dentifier to indicate the encoding type used for the Notification Message
- `uint8_t unyte_udp_get_version(unyte_seg_met_t *message);` : header encoding version
- `uint8_t unyte_udp_get_space(unyte_seg_met_t *message);` : space of media type version
- `uint8_t unyte_udp_get_media_type(unyte_seg_met_t *message);` : dentifier to indicate the media type used for the Notification Message
- `uint16_t unyte_udp_get_header_length(unyte_seg_met_t *message);` : length of the message header in octets
- `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
- `uint32_t unyte_udp_get_generator_id(unyte_seg_met_t *message);` : observation domain id of the message
- `uint32_t unyte_udp_get_observation_domain_id(unyte_seg_met_t *message);` : observation domain id of the message
- `uint32_t unyte_udp_get_message_id(unyte_seg_met_t *message);` : message id of the message
- `struct sockaddr_storage * unyte_udp_get_src(unyte_seg_met_t *message);` : source IP and port of the message. Could be IPv4 or IPv6.
- `struct sockaddr_storage * unyte_udp_get_dest_addr(unyte_seg_met_t *message);` : collector address. Could be IPv4 or IPv6.
Expand All @@ -124,7 +124,7 @@ typedef struct
uint monitoring_delay; // monitoring queue frequence in seconds. Default: 5 seconds
} unyte_udp_options_t;
```
The thread will every `monitoring_delay` seconds send all generators id's counters.
The thread will every `monitoring_delay` seconds send all observation domain id's counters.

##### Type of threads
The threads types are defined in `monitoring_worker.h`:
Expand Down Expand Up @@ -155,7 +155,7 @@ Limitations of udp-pub-channel-05:
- Same output `struct unyte_seg_met_t` is given to the user.
- Flags from the protocol are not parsed.
- No options are possible and thus no segmentation is supported
- The encoding type identifiers are taken from the IANA instead of the draft to maintain consistency in the different pipelines. IANA codes could be checked in the main [draft](https://datatracker.ietf.org/doc/html/draft-ietf-netconf-udp-notif-04#section-9).
- The media type identifiers are taken from the IANA instead of the draft to maintain consistency in the different pipelines. IANA codes could be checked in the main [draft](https://datatracker.ietf.org/doc/html/draft-ietf-netconf-udp-notif-04#section-9).
- Google protobuf is returned as RESERVED(0) encoding type.

### Usage of the sender
Expand All @@ -166,16 +166,16 @@ The message to send have the following structure:
```c
typedef struct unyte_message
{
uint used_mtu; // MTU to use for cutting the message to segments
void *buffer; // pointer to buffer to send
uint buffer_len; // length of the buffer to send
uint used_mtu; // MTU to use for cutting the message to segments
void *buffer; // pointer to buffer to send
uint buffer_len; // length of the buffer to send

// UDP-notif
uint8_t version : 3; // UDP-notif protocol version
uint8_t space : 1; // UDP-notif protocol space
uint8_t encoding_type : 4; // UDP-notif protocol encoding type
uint32_t generator_id; // UDP-notif protocol observation domain id
uint32_t message_id; // UDP-notif protocol message id
uint8_t version : 3; // UDP-notif protocol version
uint8_t space : 1; // UDP-notif protocol space
uint8_t media_type : 4; // UDP-notif protocol media type
uint32_t observation_domain_id; // UDP-notif protocol observation domain id
uint32_t message_id; // UDP-notif protocol message id
} unyte_message_t;
```

Expand Down Expand Up @@ -212,8 +212,8 @@ int main()
// UDP-notif
message->version = 0;
message->space = 0;
message->encoding_type = UNYTE_ENCODING_JSON; // json but sending string
message->generator_id = 1000;
message->media_type = UNYTE_MEDIATYPE_YANG_JSON; // json but sending string
message->observation_domain_id = 1000;
message->message_id = 2147483669;
message->used_mtu = 200; // If set to 0, the default mtu set on options is used, else, this one is used

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.2-git
0.6.0-git
83 changes: 0 additions & 83 deletions deprecated/2_makefile

This file was deleted.

57 changes: 0 additions & 57 deletions deprecated/mine_install.sh

This file was deleted.

47 changes: 0 additions & 47 deletions deprecated/uninstall.sh

This file was deleted.

4 changes: 2 additions & 2 deletions examples/client_interface_bind_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ int main(int argc, char *argv[])

// printf("unyte_udp_get_version: %u\n", unyte_udp_get_version(seg));
// printf("unyte_udp_get_space: %u\n", unyte_udp_get_space(seg));
// printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg));
// printf("unyte_udp_get_media_type: %u\n", unyte_udp_get_media_type(seg));
// printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg));
// printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg));
// printf("unyte_udp_get_generator_id: %u\n", unyte_udp_get_generator_id(seg));
// printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg));
// printf("unyte_udp_get_message_id: %u\n", unyte_udp_get_message_id(seg));
// printf("unyte_udp_get_src[family]: %u\n", unyte_udp_get_src(seg)->ss_family);
// printf("unyte_udp_get_dest_addr[family]: %u\n", unyte_udp_get_dest_addr(seg)->ss_family);
Expand Down
4 changes: 2 additions & 2 deletions examples/client_legacy_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ int main(int argc, char *argv[])

printf("unyte_udp_get_version: %u\n", unyte_udp_get_version(seg));
printf("unyte_udp_get_space: %u\n", unyte_udp_get_space(seg));
printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg));
printf("unyte_udp_get_media_type: %u\n", unyte_udp_get_media_type(seg));
printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg));
printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg));
printf("unyte_udp_get_generator_id: %u\n", unyte_udp_get_generator_id(seg));
printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg));
printf("unyte_udp_get_message_id: %u\n", unyte_udp_get_message_id(seg));
// printf("unyte_udp_get_src[family]: %u\n", unyte_udp_get_src(seg)->ss_family);
printf("unyte_udp_get_dest_addr[family]: %u\n", unyte_udp_get_dest_addr(seg) == NULL ? 0 : unyte_udp_get_dest_addr(seg)->ss_family); // NULL if options.msg_dst_ip is set to false (default)
Expand Down
2 changes: 1 addition & 1 deletion examples/client_monitoring.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int main(int argc, char *argv[])
// Getters
// printf("Thread id: %ld\n", unyte_udp_get_thread_id(counter));
// printf("Thread type: %d\n", unyte_udp_get_th_type(counter));
// printf("Generator id: %d\n", unyte_udp_get_gen_id(counter));
// printf("Observation domain id: %d\n", unyte_udp_get_od_id(counter));
// printf("Last msg id: %d\n", unyte_udp_get_last_msg_id(counter));
// printf("Received OK: %d\n", unyte_udp_get_received_seg(counter));
// printf("Dropped: %d\n", unyte_udp_get_dropped_seg(counter));
Expand Down
4 changes: 2 additions & 2 deletions examples/client_sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ int main(int argc, char *argv[])

// printf("unyte_udp_get_version: %u\n", unyte_udp_get_version(seg));
// printf("unyte_udp_get_space: %u\n", unyte_udp_get_space(seg));
// printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg));
// printf("unyte_udp_get_media_type: %u\n", unyte_udp_get_media_type(seg));
// printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg));
// printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg));
// printf("unyte_udp_get_generator_id: %u\n", unyte_udp_get_generator_id(seg));
// printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg));
// printf("unyte_udp_get_message_id: %u\n", unyte_udp_get_message_id(seg));
// printf("unyte_udp_get_src[family]: %u\n", unyte_udp_get_src(seg)->ss_family);
printf("unyte_udp_get_dest_addr[family]: %u\n", unyte_udp_get_dest_addr(seg) == NULL ? 0 : unyte_udp_get_dest_addr(seg)->ss_family); // NULL if options.msg_dst_ip is set to false (default)
Expand Down
4 changes: 2 additions & 2 deletions examples/client_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ int main(int argc, char *argv[])

// printf("unyte_udp_get_version: %u\n", unyte_udp_get_version(seg));
// printf("unyte_udp_get_space: %u\n", unyte_udp_get_space(seg));
// printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg));
// printf("unyte_udp_get_media_type: %u\n", unyte_udp_get_media_type(seg));
// printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg));
// printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg));
// printf("unyte_udp_get_generator_id: %u\n", unyte_udp_get_generator_id(seg));
// printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg));
// printf("unyte_udp_get_message_id: %u\n", unyte_udp_get_message_id(seg));
// printf("unyte_udp_get_src[family]: %u\n", unyte_udp_get_src(seg)->ss_family);
// printf("unyte_udp_get_dest_addr[family]: %u\n", unyte_udp_get_dest_addr(seg)->ss_family);
Expand Down
4 changes: 2 additions & 2 deletions examples/eBPF/client_ebpf_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ int main(int argc, char *argv[])

// printf("unyte_udp_get_version: %u\n", unyte_udp_get_version(seg));
// printf("unyte_udp_get_space: %u\n", unyte_udp_get_space(seg));
// printf("unyte_udp_get_encoding_type: %u\n", unyte_udp_get_encoding_type(seg));
// printf("unyte_udp_get_media_type: %u\n", unyte_udp_get_media_type(seg));
// printf("unyte_udp_get_header_length: %u\n", unyte_udp_get_header_length(seg));
// printf("unyte_udp_get_message_length: %u\n", unyte_udp_get_message_length(seg));
// printf("unyte_udp_get_generator_id: %u\n", unyte_udp_get_generator_id(seg));
// printf("unyte_udp_get_observation_domain_id: %u\n", unyte_udp_get_observation_domain_id(seg));
// printf("unyte_udp_get_message_id: %u\n", unyte_udp_get_message_id(seg));
// printf("unyte_udp_get_src[family]: %u\n", unyte_udp_get_src(seg)->ss_family);
// printf("unyte_udp_get_dest_addr[family]: %u\n", unyte_udp_get_dest_addr(seg)->ss_family);
Expand Down
4 changes: 2 additions & 2 deletions examples/sender_cbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ int main(int argc, char *argv[])
// UDP-notif
message->version = 0;
message->space = UNYTE_SPACE_STANDARD;
message->encoding_type = UNYTE_ENCODING_CBOR; // sending CBOR
message->generator_id = 1000;
message->media_type = UNYTE_MEDIATYPE_YANG_CBOR; // sending CBOR
message->observation_domain_id = 1000;
message->message_id = 2147483669;
message->used_mtu = 0; // use default configured
message->options = NULL; // no custom options sent
Expand Down
Loading

0 comments on commit 3e89d7c

Please sign in to comment.