Filter unwanted LoRaWAN packets
Table of Contents:
1. Introduction
This feature is to filter the unwanted LoRaWAN packets. Purpose is to save the upstream traffic especially for a 4G cellular connection. If configured, gateway will process filter for below two types of message:
- Unconfirmed Data Up
- Confirmed Data Up
2. FWD Filter Mechanism
Support Devices:
- All existing models of Gateways
Filtering rules:
Fport Filters | DevAddr Filter | NwkID Filter | |||
---|---|---|---|---|---|
Level 0 | Do nothing | Level 0 | Do nothing | Level 0 | Do nothing |
Level 1 | Filter only the Fport in the list | Level 1 | Filter only the DevAddr in the list | Level 1 | Filter only the NwkID in the list |
Level 2 | Filter Fport that are not in the database | Level 2 | Filter DevAddr that are not in the database | Level 2 | Filter NWkID that are not in the database |
Check if the filter is running
2.1 Filter By Fport
The Gateway FPort filter will check all the below LoRaWAN messages: Unconfirmed Data Up & Confirmed Data Up.
Important Notice:
- By default, Fport Filter Level=0. which means do nothing
- Fport Filter configured to Level=1. If the Fport in the list matches the Fport received by the gateway, it will be dropped.
- Fport Filter configured to Level=2. If the Fport in the list does not match the Fport received by the gateway, it will be dropped.
If you want to forward only a certain Fport, use level=2 and add the desired fport in the Filter value textbox. Add Filter Value 0 to forward Join requests.
2.2 Filter By DevAddr
The Gateway DevAddr filter will check all the below LoRaWAN messages: Unconfirmed Data Up & Confirmed Data Up.
Important Notice:
- By default, DevAddr Filter Level=0. which means do nothing
- DevAddr Filter configured to Level=1. If the DevAddr in the list matches the DevAddr received by the gateway, it will be dropped.
- DevAddr Filter configured to Level=2. If the DevAddr in the list does not match the DevAddr received by the gateway, it will be dropped.
In this case, we set DevAddr Filter Level=1 and add the filter (server | DevAddr | 12664787 ), when the gateway receives a Lorawan packet with DevAddr=12664787, it will be dropped.
2.3 Filter By NwkID
The Gateway NwkID filter will check all the below LoRaWAN messages: Unconfirmed Data Up & Confirmed Data Up.
Important Notice:
- By default, NwkID Filter Level=0. which means do nothing
- NwkID Filter configured to Level=1. If the NwkID in the list matches the NwkID received by the gateway, it will be dropped.
- NwkID Filter configured to Level=2. If the NwkID in the list does not match the NwkID received by the gateway, it will be dropped.
In this case, we set NwkID Filter Level=0 and add the filter (server | NwkID | 13 ), when the gateway receives a packet that is not NwkID=00000013, it will be dropped.
NwkID is calculated as follows: DevAddr counts shifted right by 25 bits
For example, Devaddr=01CC1907,NwkID= 01CC1907 >> 25 = 0
Devaddr=260B748A,NwkID= 260B748A >> 25 = 13
If user need to set the Secondary LoRaWAN Server Packet Filter, the configuration is similar to that above.
2.4 Add Filter rules via Linux Command.
eg:
sqlite3 /etc/lora/devskey "INSERT INTO filter (name, type, value ) VALUES ('server1', 'fport', '1');"
sqlite3 /etc/lora/devskey "INSERT INTO filter (name, type, value ) VALUES ('server1', 'devaddr', '00000000');"
sqlite3 /etc/lora/devskey "SELECT *from filter"
2.5 Check results
After the configuration is complete, you can enable Logread Debug level on System-->General, return to LoRaWAN-->Semtech UDP, and click "Save&Apply".
3. PKT_FWD Filter Mechanism
Support Devices:
- Firmware Version > lgw--build-v5.4.1602379434-20201011-0926 Firmware Download
- LG308, DLOS8
- LPS8
Fport & DevAddr Filter
Check if the filter is running
3.1 Filter By Fport
The Gateway FPort filter will check all the below LoRaWAN message: Unconfirmed Data Up & Confirmed Data Up. If the packet's FPort doesn't match the FPort setting, it will be dropped.
By default , this value is 0 means can upstream all packets with any FPort. We can set to other FPort so specify only one FPort works.
In case we set the FPort filter to 45, and the End Node send a packet with Fport other than 45, it will be dropped.
3.2 Filter By DevAddr
Gateway will use a DevAddr mask to check if the Unconfirmed Data Up & Confirmed Data Up packets match the mask . If not, gateway will drop it.
This screenshot shows packets is dropped if DevAddr mask doesn't match.