Wiki source code of Filter unwanted LoRaWAN packets
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | **~ Table of Contents:** | ||
2 | |||
3 | {{toc/}} | ||
4 | |||
5 | |||
6 | |||
7 | |||
8 | |||
9 | = 1. Introduction = | ||
10 | |||
11 | |||
12 | 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: | ||
13 | |||
14 | * Unconfirmed Data Up | ||
15 | |||
16 | * Confirmed Data Up | ||
17 | |||
18 | = 2. FWD Filter Mechanism = | ||
19 | |||
20 | |||
21 | (% class="wikigeneratedid" id="H1.1SupportDevices" %) | ||
22 | **Support Devices:** | ||
23 | |||
24 | * Firmware Version > ** dragino-lgw~-~-v5.4.1658824252** | ||
25 | |||
26 | * LG308, DLOS8, LPS8, LIG16, LG308N, DLOS8N, LPS8N | ||
27 | |||
28 | **Filtering rules:** | ||
29 | |||
30 | (% border="1" style="background-color:#f2f2f2; width:728px" %) | ||
31 | |=(% colspan="2" style="width: 351px;background-color:#D9E2F3;color:#0070C0" %)Fport Filter|=(% colspan="2" style="width: 374px;background-color:#D9E2F3;color:#0070C0" %)DevAddr Filter | ||
32 | |(% style="width:66px" %)**Level 0**|(% style="width:284px" %)Do nothing|(% style="width:68px" %)**Level 0**|(% style="width:306px" %)Do nothing | ||
33 | |(% style="width:66px" %)**Level 1**|(% style="width:284px" %)Filter only the Fport in the list|(% style="width:68px" %)**Level 1**|(% style="width:306px" %)Filter only the DevAddr in the list | ||
34 | |(% style="width:66px" %)**Level 2**|(% style="width:284px" %)Filter Fport that are not in the database|(% style="width:68px" %)**Level 2**|(% style="width:306px" %)Filter DevAddr that are not in the database | ||
35 | |||
36 | ((( | ||
37 | [[image:image-20220726171434-6.png||height="628" width="692"]] | ||
38 | |||
39 | |||
40 | **Check if the filter is running** | ||
41 | |||
42 | [[image:image-20220726164533-3.png||height="465" width="982"]] | ||
43 | |||
44 | |||
45 | == 2.1 Filter By Fport == | ||
46 | |||
47 | |||
48 | The Gateway FPort filter will check all the below LoRaWAN messages: Unconfirmed Data Up & Confirmed Data Up. | ||
49 | |||
50 | |||
51 | (% style="color:red" %)**Important Notice:** | ||
52 | |||
53 | * By default, Fport Filter (% style="color:blue" %)**Level=0**(%%). which means do nothing | ||
54 | |||
55 | * Fport Filter configured to (% style="color:blue" %)**Level=1**(%%). If the Fport in the list matches the Fport received by the gateway, it will be dropped. | ||
56 | |||
57 | * Fport Filter configured to (% style="color:blue" %)**Level=2**(%%). If the Fport in the list does not match the Fport received by the gateway, it will be dropped. | ||
58 | |||
59 | 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**. | ||
60 | |||
61 | [[image:image-20221129101012-1.png]] | ||
62 | |||
63 | |||
64 | In this case, we set Fport Filter Level=1 and add the filter (server | fport | 0), when the gateway receives a Lorawan packet with Fport=0, it will be dropped. | ||
65 | |||
66 | [[image:image-20220726165311-4.png||height="718" width="798"]] | ||
67 | |||
68 | |||
69 | [[image:image-20220726170532-5.png]] | ||
70 | |||
71 | |||
72 | == 2.2 Filter By DevAddr == | ||
73 | |||
74 | |||
75 | The Gateway DevAddr filter will check all the below LoRaWAN messages: Unconfirmed Data Up & Confirmed Data Up. | ||
76 | |||
77 | |||
78 | (% style="color:red" %)**Important Notice:** | ||
79 | |||
80 | * By default, DevAddr Filter (% style="color:blue" %)**Level=0**(%%). which means do nothing | ||
81 | |||
82 | * DevAddr Filter configured to (% style="color:blue" %)**Level=1**(%%). If the DevAddr in the list matches the DevAddr received by the gateway, it will be dropped. | ||
83 | |||
84 | * DevAddr Filter configured to (% style="color:blue" %)**Level=2**(%%). If the DevAddr in the list does not match the DevAddr received by the gateway, it will be dropped. | ||
85 | |||
86 | In this case, we set DevAddr Filter Level=0 and add the filter (server | DevAddr | 12664787 ), when the gateway receives a Lorawan packet with DevAddr=12664787, it will be dropped. | ||
87 | |||
88 | |||
89 | [[image:image-20220726171555-7.png||height="754" width="765"]] | ||
90 | |||
91 | |||
92 | [[image:image-20220726171808-8.png]] | ||
93 | |||
94 | |||
95 | **If user need to set the Secondary LoRaWAN Server Packet Filter, the configuration is similar to that above.** | ||
96 | |||
97 | |||
98 | == 2.3 Add Filter rules via Linux Command. == | ||
99 | |||
100 | |||
101 | (% class="box infomessage" %) | ||
102 | ((( | ||
103 | $ sqlite3 /etc/lora/devskey "INSERT INTO filter (name, type, value ) VALUES ('$filter_name', '$filter_type', '$filter_value');" | ||
104 | |||
105 | |||
106 | |||
107 | name: server name. eg: server1/server2 | ||
108 | |||
109 | type: filter type. eg: fport/devaddr | ||
110 | |||
111 | value: 0,1,2,3/000000 | ||
112 | ))) | ||
113 | |||
114 | (% class="box" %) | ||
115 | ((( | ||
116 | eg: | ||
117 | |||
118 | sqlite3 /etc/lora/devskey "INSERT INTO filter (name, type, value ) VALUES ('server1', 'fport', '1');" | ||
119 | |||
120 | sqlite3 /etc/lora/devskey "INSERT INTO filter (name, type, value ) VALUES ('server1', 'devaddr', '00000000');" | ||
121 | |||
122 | sqlite3 /etc/lora/devskey "SELECT *from filter" | ||
123 | ))) | ||
124 | |||
125 | [[image:image-20230519104800-2.png]] | ||
126 | |||
127 | |||
128 | |||
129 | ))) | ||
130 | |||
131 | = 3. PKT_FWD Filter Mechanism = | ||
132 | |||
133 | |||
134 | (% class="wikigeneratedid" id="H1.1SupportDevices" %) | ||
135 | **Support Devices:** | ||
136 | |||
137 | * Firmware Version >** lgw~-~-build-v5.4.1602379434-20201011-0926** [[Firmware Download>>url:http://www.dragino.com/downloads/index.php?dir=LoRa_Gateway/LPS8/Firmware/Release/]] | ||
138 | |||
139 | * LG308, DLOS8 | ||
140 | |||
141 | * LPS8 | ||
142 | |||
143 | **Fport & DevAddr Filter** | ||
144 | |||
145 | [[image:image-20220527150138-1.png]] | ||
146 | |||
147 | |||
148 | Check if the filter is running | ||
149 | |||
150 | [[image:image-20220527150222-2.png||height="379" width="1062"]] | ||
151 | |||
152 | |||
153 | == 3.1 Filter By Fport == | ||
154 | |||
155 | |||
156 | 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. | ||
157 | |||
158 | ((( | ||
159 | 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. | ||
160 | ))) | ||
161 | |||
162 | [[image:image-20220527150303-3.png]] | ||
163 | |||
164 | |||
165 | 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. | ||
166 | |||
167 | |||
168 | == 3.2 Filter By DevAddr == | ||
169 | |||
170 | |||
171 | 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. | ||
172 | |||
173 | [[image:image-20220527150404-4.png]] | ||
174 | |||
175 | |||
176 | This screenshot shows packets is dropped if DevAddr mask doesn't match. | ||
177 | |||
178 |