Skip to content

Commit d4535b4

Browse files
Lukas955sedmicha
andauthored
Sedlak forwarder rework (#60)
* Forwarder: refactor v1 * Forwarder: improve config * Forwarder: improve main * Forwarder: removed old files * Forwarder: updated CMakeLists * Forwarder: added common * Forwarder: added forwarder * Forwarder: added host * Forwarder: added connection * Forwarder: added sender * Forwarder: added message * Forwarder: improve docs * Forwarder: resend templates when connection reconnects * Forwarder: skip hosts with waiting transfers * Forwarder: changed how reconnections work * Forwarder: indicate lost messages in SendToAll mode * Forwarder: fixes in message creation * Forwarder: use MSG_DONTSIGNAL when sending over socket * Forwarder: remove debugging printfs * Forwarder: minor fixes * Forwarder: atomic sockfd when reconnecting from another thread * Forwarder: atomic finished flag * Forwarder: drop unfinished transfers on connection lost for TCP * Forwarder: fix build on gcc 4.8 * Forwarder: skip data sets with unknown templates * Forwarder: add non-blocking socket connect * Forwarder: set export time to current time when forwarding * Forwarder: minor fixes in Connection * Forwarder: non-blocking socket connect v2 * Forwarder: fix reconnector Co-authored-by: Michal Sedlak <[email protected]>
1 parent 109e526 commit d4535b4

29 files changed

+3198
-1667
lines changed

src/plugins/output/forwarder/CMakeLists.txt

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,30 @@
11
# Create a linkable module
22
add_library(forwarder-output MODULE
33
src/main.cpp
4-
src/config.h
4+
src/Config.h
5+
src/Config.cpp
56
src/Forwarder.h
6-
src/ConnectionManager.h
7-
src/ConnectionManager.cpp
8-
src/ConnectionParams.h
7+
src/Forwarder.cpp
98
src/Connection.h
109
src/Connection.cpp
11-
src/ConnectionBuffer.h
12-
src/SyncPipe.h
13-
src/IPFIXMessage.h
14-
src/MessageBuilder.h
10+
src/Host.cpp
11+
src/Host.h
12+
src/common.h
13+
src/common.cpp
14+
src/Message.h
15+
src/Message.cpp
16+
src/Sender.h
17+
src/Sender.cpp
18+
src/connector/Connector.h
19+
src/connector/Connector.cpp
20+
src/connector/FutureSocket.h
21+
src/connector/FutureSocket.cpp
22+
src/connector/Pipe.h
23+
src/connector/Pipe.cpp
1524
)
1625

26+
target_include_directories(forwarder-output PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src)
27+
1728
install(
1829
TARGETS forwarder-output
1930
LIBRARY DESTINATION "${INSTALL_DIR_LIB}/ipfixcol2/"
Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Forwarder (output plugin) [Preview]
22
===================================
33

4-
This plugin allows forwarding incoming IPFIX messages to other collector in various modes.
4+
This plugin allows forwarding incoming flow records in IPFIX form to other collector in various modes.
55

66
It can be used to broadcast messages to multiple collectors (e.g. a main and a backup collector),
77
or to distribute messages across multiple collectors (e.g. for load balancing).
@@ -20,13 +20,18 @@ Example configuration
2020
<hosts>
2121
<host>
2222
<name>Subcollector 1</name>
23-
<address>127.0.0.1</address>
24-
<port>4751</port>
23+
<address>192.168.1.2</address>
24+
<port>4739</port>
2525
</host>
2626
<host>
2727
<name>Subcollector 2</name>
28+
<address>192.168.1.3</address>
29+
<port>4739</port>
30+
</host>
31+
<host>
32+
<name>Subcollector 3</name>
2833
<address>localhost</address>
29-
<port>4752</port>
34+
<port>4739</port>
3035
</host>
3136
</hosts>
3237
</params>
@@ -36,42 +41,48 @@ Parameters
3641
----------
3742

3843
:``mode``:
39-
The forwarding mode; round robin (messages are sent to one host at time and hosts are cycled through) or all (messages are broadcasted to all hosts)
44+
Flow distribution mode. **RoundRobin** (each record will be delivered to one of hosts) or **All** (each record will be delivered to all hosts).
4045
[values: RoundRobin/All]
4146

4247
:``protocol``:
43-
The transport protocol to use
48+
The transport protocol to use.
4449
[values: TCP/UDP]
4550

46-
:``connectionBufferSize``:
47-
Size of the buffer of each connection (Warning: number of connections = number of input exporters * number of hosts)
48-
[value: number of bytes, default: 4194304]
51+
:``templatesResendSecs``:
52+
Send templates again every N seconds (UDP only).
53+
[value: number of seconds, default: 600, 0 = never]
4954

50-
:``templateRefreshIntervalSecs``:
51-
Send templates again every N seconds (UDP only)
52-
[value: number of seconds, default: 600]
55+
:``templatesResendPkts``:
56+
Send templates again every N packets (UDP only).
57+
[value: number of packets, default: 5000, 0 = never]
5358

54-
:``templateRefreshIntervalBytes``:
55-
Send templates again every N bytes (UDP only)
56-
[value: number of bytes, default: 5000000]
59+
:``reconnectSecs``:
60+
Attempt to reconnect every N seconds in case the connection drops (TCP only).
61+
[value: number of seconds, default: 10, 0 = don't wait]
5762

58-
:``reconnectIntervalSecs``:
59-
Attempt to reconnect every N seconds in case the connection drops (TCP only)
60-
[value: number of seconds, default: 10]
63+
:``premadeConnections``:
64+
Keep N connections open with each host so there is no delay in connecting once a connection is needed.
65+
[value: number of connections, default: 5]
6166

6267
:``hosts``:
63-
The receiving hosts
68+
The receiving hosts.
6469

6570
:``host``:
6671
:``name``:
67-
Optional identification of the host
72+
Optional identification of the host.
6873
[value: string, default: <address>:<port>]
6974

7075
:``address``:
71-
The address of the host
76+
The address of the host.
7277
[value: IPv4/IPv6 address or a hostname]
7378

7479
:``port``:
75-
The port to connect to
80+
The port to connect to.
7681
[value: port number]
7782

83+
Known limitations
84+
-----------------
85+
86+
Export time of IPFIX messages is set to the current time when forwarding. This may cause issues with data fields using deltaTime relative to the export time!
87+
88+

src/plugins/output/forwarder/TODO.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)