# SDN Architecture for 6 LoWPAN Wireless Sensor Networks
## 3 SD6 WSN Architecture
SD6 WSN does the same: it uses the control plane protocol (SD6 WSNP) to store in the nodes the rules that the drive communication in the data plane. In SD6 WSN, networking applications are responsible for solving possible connectivity problems. Thus, it is very important that the controller maintains the unified view of the network as close to reality as possible. To do this, it needs to have a continuous connection with the nodes, to be able to receive the notifications and to send corrections to the entries in the flow tables. SD6 WSNP messages are transported by a reliable protocol stack (6 LoWPAN-RPL), assuring that the information of every node is continuously sent to the controller, which in turn can continuously update the contents of the flow tables, according to the decisions made by networking applications. Flow tables are composed of two fields: match, where the characteristics of the incoming packet header that identifies the corresponding flow are defined, and action, where the forwarding behavior for a matching package is defined. A reduced set of attributes (with respect to standard SDN flow table entries) is included in the match field: IPv6 source address, IPv6 destination address, TCP source port, TCP destination port, UDP source port and UDP destination port. Each entry has a unique identifier, ranging from one to 255. Because the attributes can contain wild-cards, the header of an incoming packet can match multiple entries in the flow table. When this occurs, the more specific entry, that is the one that matches more non wild-card attributes, has the higher priority. When there are multiple entries with equivalent matching, the tiebreaker is the identification number of the flow entry (flowid), the lowest having the highest priority. IP address aggregation techniques can use the destination IP address mask (dstmask)to decrease the number of entries in the tables. If this field is not specified, mask/128 is assumed. Table 1 describes possible attributes in SD6 WSN flow table entries. The action field has three attributes: type, nhipaddr and rfpwr. The first defines the kind of action to be taken, the second the is the next-hop address in data plane forwarding and the third is the transmission power to be adopted for specific flows. If not present, the default transmission power is assumed. Table 2 describes the attributes of the action, field, and Figure 3 shows the format of flow-table entries. \begin{table}
\begin{tabular}{l c l} \hline \hline
**Match** & **Length (Bits)** & **Description** \\ \hline ipv6 src & 128 & Origin address (IPv6) \\ srcmask & 8 & Mask of origin address (default/128)) \\ ipv6 dst & 128 & Destination address (IPv6) \\ dstmask & 8 & Mask of destination address (default/128) \\ srcport & 16 & Origin transport port \\ dstport & 16 & Destination transport port \\ ipproto & 8 & IP protocol (19-UDP, 6-TCP, ICMPv6) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Match field of SD6 WSN flow table entry. Messages of SD6 WSNP are constructed over CoAP confirmed messages. The CoAP protocol was initially designed as a client-server protocol, with the communication initiatives taken by the client. It was later extended with the observe option [27], activated by a flag in GET messages sent by the client, which instructs the server to register the request and send notifications back under certain conditions. The controller assumes the role of CoAP client, while the nodes assume the role of server The observe option is used whenever a relevant change state occurs or when a node receives a packet that does not match any existing flow. Three events are considered relevant changes: node failure, significant improvement of the quality of a link and deterioration of the quality of a link. The first is identified when a percentage of one node's neighbors fail to report it on their neighborhood lists. The change in the quality of links is evaluated by the ETX metric.