code Service Chaining with Metadata Metadata is used in OpenFlow 1.1 to communicate the information among different tables and associated actions [109]. There are two types of metadata required in data paths. Some part of metadata is used as lookup action in further tables and some metadata is required by actions. Intermediate results from one table are communicated to other tables using some metadata, which can be used as part of a subsequent lookup key or be further modified later. We introduce two new types of metadata, the direction bit that rep- resents the direction of the flow and the set of inline services to be applied for the flow under process, called service set. This service set is encoded as a bit vector, one bit for each possible service. More sophis- ticated encodings can be used to enable more advanced features such as load balancing over multiple service instances. OpenFlow 1.1 sup- ports 64-bit metadata field [109]. This requires one bit for the direction and leaves up to 63 bits for encoding the service set, allowing a max- imum of 63 distinct services. The format of the metadata is shown in Figure 5.7, together with an example. The metadata field can be applied with arbitrary mask and is updated as follows: new_meta = (old_meta&-mask) Il (value&mask) (5.1) The value are the bits to be set and the mask is used to select these bits, which can be arbitrary 64 bit numbers. The first bit indicates whether it is upstream (0) or downstream (1). The following N-bit vector defines the service set, encoding for N number of services. The encoding in this example specifies that this packet should traverse the virus scan, DPI, and content cache. In the data path, this metadata is set, then modified, and finally used to search for the next service to be applied to this packet. 5 SDN and NFV in 5G 5.2.1.5 Summary of Dataplane Functions Figure 5.8 depicts the details of the forwarding steps in the data path. When a packet arrives, using its input port, a lookup in the direction table determines if this packe