New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large BGP Communities support #16

Merged
merged 1 commit into from Oct 29, 2016

Conversation

Projects
None yet
2 participants
@pierky
Contributor

pierky commented Oct 27, 2016

Download the .pcap file containing Large BGP Communities attributes:

$ curl -Ls -o large_communities.pcap
https://github.com/pierky/large-bgp-communities-playground/raw/master/tests/01/exabgp.pcap

Human readable format:

$ cat large_communities.pcap | ./pbgpp.py -
[BGPMessage UPDATE] - 75 Bytes
|- MAC: 02:42:c0:00:02:02 -> 02:42:c0:00:02:03
|- IP: 192.0.2.2:46605 -> 192.0.2.3:179
|- Timestamp: 2016-10-27 07:21:26.812466 (1477552886.812466)
|
|- Update Message Sub-Type: ANNOUNCE
|- Withdrawn Routes Length: 0 Bytes
|- Total Path Attribute Length: 47 Bytes
|- Prefix (NLRI):
|--- 203.0.113.16/32
|- Path Attributes:
|--- ORIGIN: IGP
|- Path Attributes:
|--- AS_PATH: 65536
|- Path Attributes:
|--- NEXT_HOP: 192.0.2.2
|- Path Attributes:
|--- LARGE_COMMUNITIES: 65535:1:1 4294967295:4294967295:4294967295


[BGPMessage UPDATE] - 75 Bytes
|- MAC: 02:42:c0:00:02:02 -> 02:42:c0:00:02:03
|- IP: 192.0.2.2:46605 -> 192.0.2.3:179
|- Timestamp: 2016-10-27 07:21:26.812466 (1477552886.812466)
|
|- Update Message Sub-Type: ANNOUNCE
|- Withdrawn Routes Length: 0 Bytes
|- Total Path Attribute Length: 47 Bytes
|- Prefix (NLRI):
|--- 203.0.113.12/32
|- Path Attributes:
|--- ORIGIN: IGP
|- Path Attributes:
|--- AS_PATH: 65536
|- Path Attributes:
|--- NEXT_HOP: 192.0.2.2
|- Path Attributes:
|--- LARGE_COMMUNITIES: 65536:1:1 65536:1:2


[BGPMessage UPDATE] - 63 Bytes
|- MAC: 02:42:c0:00:02:02 -> 02:42:c0:00:02:03
|- IP: 192.0.2.2:46605 -> 192.0.2.3:179
|- Timestamp: 2016-10-27 07:21:26.812466 (1477552886.812466)
|
|- Update Message Sub-Type: ANNOUNCE
|- Withdrawn Routes Length: 0 Bytes
|- Total Path Attribute Length: 35 Bytes
|- Prefix (NLRI):
|--- 203.0.113.11/32
|- Path Attributes:
|--- ORIGIN: IGP
|- Path Attributes:
|--- AS_PATH: 65536
|- Path Attributes:
|--- NEXT_HOP: 192.0.2.2
|- Path Attributes:
|--- LARGE_COMMUNITIES: 65536:1:1


[BGPMessage UPDATE] - 75 Bytes
|- MAC: 02:42:c0:00:02:02 -> 02:42:c0:00:02:03
|- IP: 192.0.2.2:46605 -> 192.0.2.3:179
|- Timestamp: 2016-10-27 07:21:26.812466 (1477552886.812466)
|
|- Update Message Sub-Type: ANNOUNCE
|- Withdrawn Routes Length: 0 Bytes
|- Total Path Attribute Length: 47 Bytes
|- Prefix (NLRI):
|--- 203.0.113.15/32
|- Path Attributes:
|--- ORIGIN: IGP
|- Path Attributes:
|--- AS_PATH: 65536
|- Path Attributes:
|--- NEXT_HOP: 192.0.2.2
|- Path Attributes:
|--- LARGE_COMMUNITIES: 65536:0:1 65536:1:0


[BGPMessage UPDATE] - 87 Bytes
|- MAC: 02:42:c0:00:02:02 -> 02:42:c0:00:02:03
|- IP: 192.0.2.2:46605 -> 192.0.2.3:179
|- Timestamp: 2016-10-27 07:21:26.812466 (1477552886.812466)
|
|- Update Message Sub-Type: ANNOUNCE
|- Withdrawn Routes Length: 0 Bytes
|- Total Path Attribute Length: 59 Bytes
|- Prefix (NLRI):
|--- 203.0.113.13/32
|- Path Attributes:
|--- ORIGIN: IGP
|- Path Attributes:
|--- AS_PATH: 65536
|- Path Attributes:
|--- NEXT_HOP: 192.0.2.2
|- Path Attributes:
|--- LARGE_COMMUNITIES: 65536:1:1 65536:1:2 65536:1:3

JSON format:

$ cat large_communities.pcap | ./pbgpp.py - -f JSON
{"source_mac": "0242c0000202", "length": 75, "message_type_string": "UPDATE", "destination_ip": "192.0.2.3", "message_data": {"path_attributes": [{"origin": 0, "type_string": "ORIGIN", "origin_string": "IGP", "type": 1, "error": false}, {"asn_byte_length": 4, "type_string": "AS_PATH", "type": 2, "error": false, "path_segments": [{"segment_type": 2, "segments": [65536], "segment_type_string": "Sequence"}]}, null, {"large_communities": [{"global_administrator": "65535", "local_data_part_1": "1", "local_data_part_2": "1"}, {"global_administrator": "4294967295", "local_data_part_1": "4294967295", "local_data_part_2": "4294967295"}], "type_string": "LARGE_COMMUNITIES", "type": 32, "error": false}], "withdrawn_routes_length": 0, "withdrawn_routes": [], "sub_type_string": "ANNOUNCE", "nlri": ["203.0.113.16/32"], "path_attributes_length": 47}, "timestamp": "1477552886.812466", "message_type": 2, "source_ip": "192.0.2.2", "destination_mac": "0242c0000203"}
{"source_mac": "0242c0000202", "length": 75, "message_type_string": "UPDATE", "destination_ip": "192.0.2.3", "message_data": {"path_attributes": [{"origin": 0, "type_string": "ORIGIN", "origin_string": "IGP", "type": 1, "error": false}, {"asn_byte_length": 4, "type_string": "AS_PATH", "type": 2, "error": false, "path_segments": [{"segment_type": 2, "segments": [65536], "segment_type_string": "Sequence"}]}, null, {"large_communities": [{"global_administrator": "65536", "local_data_part_1": "1", "local_data_part_2": "1"}, {"global_administrator": "65536", "local_data_part_1": "1", "local_data_part_2": "2"}], "type_string": "LARGE_COMMUNITIES", "type": 32, "error": false}], "withdrawn_routes_length": 0, "withdrawn_routes": [], "sub_type_string": "ANNOUNCE", "nlri": ["203.0.113.12/32"], "path_attributes_length": 47}, "timestamp": "1477552886.812466", "message_type": 2, "source_ip": "192.0.2.2", "destination_mac": "0242c0000203"}
{"source_mac": "0242c0000202", "length": 63, "message_type_string": "UPDATE", "destination_ip": "192.0.2.3", "message_data": {"path_attributes": [{"origin": 0, "type_string": "ORIGIN", "origin_string": "IGP", "type": 1, "error": false}, {"asn_byte_length": 4, "type_string": "AS_PATH", "type": 2, "error": false, "path_segments": [{"segment_type": 2, "segments": [65536], "segment_type_string": "Sequence"}]}, null, {"large_communities": [{"global_administrator": "65536", "local_data_part_1": "1", "local_data_part_2": "1"}], "type_string": "LARGE_COMMUNITIES", "type": 32, "error": false}], "withdrawn_routes_length": 0, "withdrawn_routes": [], "sub_type_string": "ANNOUNCE", "nlri": ["203.0.113.11/32"], "path_attributes_length": 35}, "timestamp": "1477552886.812466", "message_type": 2, "source_ip": "192.0.2.2", "destination_mac": "0242c0000203"}
{"source_mac": "0242c0000202", "length": 75, "message_type_string": "UPDATE", "destination_ip": "192.0.2.3", "message_data": {"path_attributes": [{"origin": 0, "type_string": "ORIGIN", "origin_string": "IGP", "type": 1, "error": false}, {"asn_byte_length": 4, "type_string": "AS_PATH", "type": 2, "error": false, "path_segments": [{"segment_type": 2, "segments": [65536], "segment_type_string": "Sequence"}]}, null, {"large_communities": [{"global_administrator": "65536", "local_data_part_1": "0", "local_data_part_2": "1"}, {"global_administrator": "65536", "local_data_part_1": "1", "local_data_part_2": "0"}], "type_string": "LARGE_COMMUNITIES", "type": 32, "error": false}], "withdrawn_routes_length": 0, "withdrawn_routes": [], "sub_type_string": "ANNOUNCE", "nlri": ["203.0.113.15/32"], "path_attributes_length": 47}, "timestamp": "1477552886.812466", "message_type": 2, "source_ip": "192.0.2.2", "destination_mac": "0242c0000203"}
{"source_mac": "0242c0000202", "length": 87, "message_type_string": "UPDATE", "destination_ip": "192.0.2.3", "message_data": {"path_attributes": [{"origin": 0, "type_string": "ORIGIN", "origin_string": "IGP", "type": 1, "error": false}, {"asn_byte_length": 4, "type_string": "AS_PATH", "type": 2, "error": false, "path_segments": [{"segment_type": 2, "segments": [65536], "segment_type_string": "Sequence"}]}, null, {"large_communities": [{"global_administrator": "65536", "local_data_part_1": "1", "local_data_part_2": "1"}, {"global_administrator": "65536", "local_data_part_1": "1", "local_data_part_2": "2"}, {"global_administrator": "65536", "local_data_part_1": "1", "local_data_part_2": "3"}], "type_string": "LARGE_COMMUNITIES", "type": 32, "error": false}], "withdrawn_routes_length": 0, "withdrawn_routes": [], "sub_type_string": "ANNOUNCE", "nlri": ["203.0.113.13/32"], "path_attributes_length": 59}, "timestamp": "1477552886.812466", "message_type": 2, "source_ip": "192.0.2.2", "destination_mac": "0242c0000203"}

Line format:

$ cat large_communities.pcap | ./pbgpp.py - -f LINE --fields
type,subtype,prefixes,large_communities
UPDATE  ANNOUNCE        203.0.113.16/32
65535:1:1;4294967295:4294967295:4294967295
UPDATE  ANNOUNCE        203.0.113.12/32 65536:1:1;65536:1:2
UPDATE  ANNOUNCE        203.0.113.11/32 65536:1:1
UPDATE  ANNOUNCE        203.0.113.15/32 65536:0:1;65536:1:0
UPDATE  ANNOUNCE        203.0.113.13/32 65536:1:1;65536:1:2;65536:1:3

Filters:

$ ./pbgpp.py - --filter-large-community 65535:1:1 -f LINE --fields prefixes,large_communities < large_communities.pcap
203.0.113.16/32 65535:1:1;4294967295:4294967295:4294967295
$ ./pbgpp.py - --filter-large-community 65536:1:2 -f LINE --fields prefixes,large_communities < large_communities.pcap
203.0.113.12/32 65536:1:1;65536:1:2
203.0.113.13/32 65536:1:1;65536:1:2;65536:1:3
$ ./pbgpp.py - --filter-large-community 4294967295:*:* -f LINE --fields prefixes,large_communities < large_communities.pcap
203.0.113.16/32 65535:1:1;4294967295:4294967295:4294967295
$ ./pbgpp.py - --filter-large-community *:0:* -f LINE --fields prefixes,large_communities < large_communities.pcap
203.0.113.15/32 65536:0:1;65536:1:0
$ ./pbgpp.py - --filter-large-community *:*:3 -f LINE --fields prefixes,large_communities < large_communities.pcap
203.0.113.13/32 65536:1:1;65536:1:2;65536:1:3
$ ./pbgpp.py - --filter-large-community *:*:* -f LINE --fields prefixes,large_communities < large_communities.pcap
203.0.113.16/32 65535:1:1;4294967295:4294967295:4294967295
203.0.113.12/32 65536:1:1;65536:1:2
203.0.113.11/32 65536:1:1
203.0.113.15/32 65536:0:1;65536:1:0
203.0.113.13/32 65536:1:1;65536:1:2;65536:1:3
$ ./pbgpp.py - --filter-large-community *:*:2 -f LINE --fields prefixes,large_communities < large_communities.pcap
203.0.113.12/32 65536:1:1;65536:1:2
203.0.113.13/32 65536:1:1;65536:1:2;65536:1:3
$ ./pbgpp.py - --filter-large-community *:*:2 --filter-large-community *:*:4294967295 -f LINE --fields prefixes,large_communities < large_communities.pcap
203.0.113.16/32 65535:1:1;4294967295:4294967295:4294967295
203.0.113.12/32 65536:1:1;65536:1:2
203.0.113.13/32 65536:1:1;65536:1:2;65536:1:3
@de-cix

This comment has been minimized.

Show comment
Hide comment
@de-cix

de-cix Oct 29, 2016

Owner

Verified and tested. Thanks for the contribution, much appreciated.

Owner

de-cix commented Oct 29, 2016

Verified and tested. Thanks for the contribution, much appreciated.

@de-cix de-cix merged commit 0b81f6c into de-cix:master Oct 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment