Skip to content

Commit dc8e4f7

Browse files
committed
Initial v1.1.0
1 parent cb47299 commit dc8e4f7

28 files changed

+5703
-4
lines changed

LICENSE

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Apache License
23
Version 2.0, January 2004
34
http://www.apache.org/licenses/
@@ -178,15 +179,15 @@
178179
APPENDIX: How to apply the Apache License to your work.
179180

180181
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "{}"
182+
boilerplate notice, with the fields enclosed by brackets "[]"
182183
replaced with your own identifying information. (Don't include
183184
the brackets!) The text should be enclosed in the appropriate
184185
comment syntax for the file format. We also recommend that a
185186
file or class name and description of purpose be included on the
186187
same "printed page" as the copyright notice for easier
187188
identification within third-party archives.
188189

189-
Copyright {yyyy} {name of copyright owner}
190+
Copyright 2004-2017 Pascal Gloor
190191

191192
Licensed under the Apache License, Version 2.0 (the "License");
192193
you may not use this file except in compliance with the License.

README.md

+133-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,133 @@
1-
# piranha
2-
BGP route collector written in C
1+
# Piranha
2+
A highly efficient, single threaded, BGP route collector written in C.
3+
Piranha collects routes and dumps them into files for further processing mainly for the purpose of analysis.
4+
Piranha is NOT a BGP router and does NOT have the capability to announce routes nor does it interact with the kernel routing table.
5+
6+
Piranha supports:
7+
* BGP capabilities negociation.
8+
* BGP 4 octets ASN and AS_PATHs.
9+
* TCP MD5 BGP session protection.
10+
* IPv6 routes over IPv6 sockets.
11+
* IPv4 routes over IPv4 sockets.
12+
13+
## Installation
14+
15+
1. Download the latest version at http://xxx
16+
```user@piranha$ wget http://xxx```
17+
2. Unpack
18+
```user@piranha$ tar -zxvf piranha-1.1.0.tar.gz```
19+
3. Compilation
20+
```user@piranha$ [sudo] ./compile.sh <destination folder>```
21+
```user@piranha$ [sudo] ./compile.sh /opt/piranha/```
22+
*NOTE: Might need sudo if your destination is not writable by the user.*
23+
4. Done
24+
25+
## Configuration
26+
Piranha has one configuration file located in <destination folder>/etc/piranha.conf. In the same folder there is a sample configuration name piranha_sample.conf. Copy the file to piranha.conf and edit it.
27+
28+
### piranha.conf
29+
```
30+
# your local AS number
31+
local_as <ASN>
32+
33+
# Listening IP/Port for IPv4 peers. If omitted, piranha will not listen for IPv4 connections.
34+
local_ip4 <local IPv4>
35+
local_port4 <tcp port>
36+
37+
# Listening IP/Port for IPv6 peers. If omitted, piranha will not listen for IPv6 connections.
38+
local_ip6 <local IPv6>
39+
local_port6 <tcp port>
40+
41+
# Export options: Choose which route attributes will be exported to the dump files
42+
export origin # IGP/EGP/Unknown
43+
export aspath # AS_PATH
44+
export community # COMMUNITY
45+
export extcommunity # EXTENDED COMMUNITY
46+
47+
# BGP Router Identifier. This MUST be set and may not be 0.0.0.0.
48+
# If you don't know what to put in this option, just copy your public IPv4
49+
# address.
50+
bgp_router_id <ipv4>
51+
52+
# The user that piranha will run as. Because piranha needs
53+
# tcp port 179, it must be started as root. Piranha will then
54+
# operator a privilege downgrade to this use for obvious security
55+
# reasons.
56+
user nobody
57+
58+
# Finally you must configure your BGP neighbors
59+
# You may configure up to 128 neighbors
60+
# (this can be changed in inc/p_defs.h:#define MAX_PEERS 128)
61+
# The password is optional and is implemented as defined in RFC5425
62+
neighbor <IPv4 or IPv6 address> <asn> [password]
63+
```
64+
## Usage
65+
### Start/Stop/Restart
66+
<install dir>/etc/piranhactl <start|restart|stop>
67+
### Status (state of all neighbors)
68+
cat <install dir>/var/piranha.status
69+
### MAN Pages
70+
man -M <install dir>/man <ptoa|piranha|piranhactl|piranha.conf>
71+
72+
## Reading Piranha DUMP
73+
Piranha dumps the received BGP Updates into dump files located in <install dir>/dump/<neighbor IP>. Files are rotated by default every 60 seconds. If there was no BGP message during that time, the dump not created for performance reasons. The 60 seconds interval can be tuned prior to compilation in `inc/p_defs.h:#define DUMPINTERVAL 60`.
74+
Dump files ready to be read have the following format: `YYYYMMddhhmmss`.
75+
With the tool `<install dir>/bin/ptoa` data from the dump files can be exported in three different formats:
76+
77+
* `./ptoa -H <dump file>`: Human readable format
78+
* `./ptoa -m <dump file>`: Machine readable format
79+
* `./ptoa -j <dump file>`: JSON format
80+
81+
### Examples
82+
#### Human readable format
83+
```
84+
2017-10-21 21:31:54 peer ip 2a03:2260::5 AS 201701
85+
2017-10-21 21:31:54 prefix announce 2a06:dac0::/29 origin IGP aspath 201701 13030 25180 202939 community 5093:5349 6629:6885 7141:7397
86+
2017-10-21 21:31:55 eof
87+
```
88+
#### Machine readable format
89+
```
90+
1508621514|P|2a03:2260::5|201701
91+
1508621514|A|2a06:dac0::|29|O|I|AP|201701 13030 25180 202939|C|5093:5349 5605:5861 6629:6885 7141:7397
92+
1508621515|E
93+
```
94+
#### JSON format
95+
```
96+
{ "timestamp": 1508621514, "type": "peer", "msg": { "peer": { "proto": "ipv6", "ip": "2a03:2260::5", "asn": 201701 } } }
97+
{ "timestamp": 1508621514, "type": "announce", "msg": { "prefix": "2a06:dac0::/29", "origin": "IGP", "aspath": [ 201701, 13030, 25180, 202939 ], "community": [ "5093:5349", "5605:5861", "6629:6885", "7141:7397" ] } }
98+
{ "timestamp": 1508621515, "type": "footer" }
99+
```
100+
101+
### Message type tags in DUMPs
102+
Colons can be used to align columns.
103+
104+
| Human | Machine | JSON | Description |
105+
|-|-|-|-|
106+
| peer | P | peer | First message in any dump describing the neighbor |
107+
| announce | A | announce | BGP prefix announce, optional origin (O), aspath (AP), community (C) and extended community (EC) subcomponents |
108+
| withdrawn | W | withdrawn | BGP prefix withdrawn |
109+
| eof | E | footer | Last message in any dump, has no other value |
110+
111+
112+
## Conformity
113+
Piranha implements partially or completely the following RFCs:
114+
* RFC1997: BGP Communities Attribute
115+
* RFC4360: BGP Extended Communities Attribute
116+
* RFC4760: Multiprotocol Extensions for BGP-4
117+
* RFC4271: A Border Gateway Protocol 4 (BGP-4)
118+
* RFC5425: The TCP Authentication Option
119+
* RFC5492: Capabilities Advertisement with BGP-4
120+
* RFC6793: BGP Support for Four-Octet Autonomous System (AS) Number Space
121+
122+
## Limitations
123+
* Config reload does not work and may lead to a crash.
124+
* Extended communities are not yet supported.
125+
* Piranha is not able to communicate with BGP speakers not conforming to RFC5492 (old speakers).
126+
* Might not work on 32bits platforms (time_t handling must be improved).
127+
128+
## Copyright
129+
130+
*Copyright 2004-2017 Pascal Gloor*
131+
*Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0*
132+
*Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.*
133+

clean.sh

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
3+
# /*******************************************************************************/
4+
# /* */
5+
# /* Copyright 2004-2017 Pascal Gloor */
6+
# /* */
7+
# /* Licensed under the Apache License, Version 2.0 (the "License"); */
8+
# /* you may not use this file except in compliance with the License. */
9+
# /* You may obtain a copy of the License at */
10+
# /* */
11+
# /* http://www.apache.org/licenses/LICENSE-2.0 */
12+
# /* */
13+
# /* Unless required by applicable law or agreed to in writing, software */
14+
# /* distributed under the License is distributed on an "AS IS" BASIS, */
15+
# /* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
16+
# /* See the License for the specific language governing permissions and */
17+
# /* limitations under the License. */
18+
# /* */
19+
# /*******************************************************************************/
20+
21+
22+
23+
# Piranha source cleaning script
24+
25+
for file in bin/piranha bin/ptoa obj/*.o *.core utils/piranhactl
26+
do
27+
if [ -r "$file" ]
28+
then
29+
echo "deleting $file..."
30+
rm $file
31+
fi
32+
done
33+
34+
echo "cleaned";

0 commit comments

Comments
 (0)