Thursday, August 25, 2011

how to implement filter on linux machine using tc scripts for mpls?

The filter implemented in the RSVP-TE daemon for DiffServ over MPLS package was implemented using the CBQ qdisc, which is known to be complicated and inefficient [26]. This filter was rewritten using the HTB qdisc for the given network topology and can be viewed on a logical level as follows [19,25]:



 

Fig. 8.4 TC Filter
The tc script for the above qdisc can be found in appendix D. The explanation follows:
When this TC filter is used at the ingress, the TOS byte of the incoming AF12 packet is copied into to skbàtc_index. Then the DSMARK filter operates on the skbàtcindex and the following operation is done:
(skbàtc_index & mask) >> shift
For this DSMARK filter, mask=0xFC and shift=2. So for an AF12 packet:
(0x30 & 0xFC) >> 2 = 0xC
which is the corresponding value of the DSCP field. Now corresponding to this value 0xC, the tcindex classifier's element returns back to the dsmark queuing discipline the minor-value of its class identifier. So for AF12 packet, class identifier 112 will be returned to skbàtc_index; it is to be noted that 112 is in hex and is to be read as 0x0112.
After passing through the DSMARK qdisc, the packet again encounters the tcindex classifier at the HTB qdisc, with mask=0xF0 and shift=4. The skbàtc_index value is used for this operation and the following results for the AF12 packet:
(0x0112 & 0xF0) >> 4 = 1
which signifies that the packet belongs to AF1 and is to passed to class-id 2:10 which is for AF1 packets. Note that this time, the result of the bitwise operation is not returned back to the skbàtc_index (that can only be done inside a DSMRK qdisc).After this the packet goes through the corresponding GRED qdisc which learns about the packets drop precedence by checking out the last four bits of the skbÃtc_index; since for AF12 it is 0x0112 and the AF12 packet gets a drop precedence of 2.
The PFIFO qdisc for EF was chosen since it is the simplest and would serve the packets with minimum latency.
The RED qdisc for BE was chosen since it allows short-term bursts and is fair as far as the dropping of the packets is concerned.
The HTB qdisc was used since like CBQ it allows borrowing of bandwidth from the parent class, in case of availability of excess bandwidth and is more efficient than CBQ.

Now, when this AF12 packet reaches the core LSRs, the EXP-to-TC map (refer 8.3) is used by the mplsadm utility (provided by the MPLS patch) to map the EXP to skbÃtc_index, so that the tc filter used at the ingress can be used within the cores as well.
For the L-LSP operation, the PHB-ID for the LSP is converted to a number (which corresponds to ToS) by the function phbidtonumber() inside ds_mpls.c. This number is stored inside the skbàtc_index field and the tc filter does the rest.

Current problem with the filter 1:
Although the current tc filters provides QoS. But during the course of experimentation, the following problems were observed:
1. For high traffic rates (of the order of Mbps), it was observed that the PFIFO qdisc implemented for EF PHB, dropped considerable amount of packets and hence the QoS deteriorated even below the BE traffic.
2. On increasing the buffer size for PFIFO, the drops decreased but the delay and jitter rose very high.
3. Present filter uses HTB as root qdisc, which schedules using DRR and TBF and since the rate allotted to BE traffic was almost 40% of the total link bandwidth; it was observed that the BE traffic was given priority over EF and AF classes. Same problem was also encountered with AF1x, AF2x and AF3x flows.

The anomalies found with the filter have been exhibited in the graphs below.
Case 1: 3 UDP flows with each with same rate (CBR flows with 8.192Mbps) were sent.
Flow1 was given EF service,
Flow2 was given AF11 service,
Flow3 was given BE service.
Case 2: 2 UDP flows with each with same rate (CBR flows with 8.192Mbps) were sent.
Flow1 was given AF11 service,
Flow2 was given AF12 service.
In this case, the filters behave as expected.




Case 3: 3 UDP flows with each with same rate (CBR flows with 8.192Mbps) were sent.
Flow1 was given AF11 service,
Flow2 was given AF12 service,
Flow3 was given AF13 service.
The filters show the problem as discussed in point 3, although the packet loss for say AF11 is lesser but the delay is much higher. This problem can be mitigated by using priority within the AF subclasses.



New proposed filter:
The motivation for the new tc filter was discussed above. This filter gives priority to the EF, AFxy and BE classes, in that order using PRIO qdisc. In order that the lower classes are not starved, the EF queue uses a TBF qdisc.
The AF PHB has been implemented using HTB filter so that the subclasses will be able to borrow traffic from each other. Each subclass (say AF1), is again implemented using GRED qdisc.
The BE class has been implemented with RED qdisc, for the reasons discussed in the previous filter.
The script for this filter can be found in appendix E.
The logical diagram of the proposed filter is as follows:
Fig. 8.5 Proposed Filter



Fig:8.6 Proposed Filter (contd.)


http://www.mplstutorial.com/how-implement-filter-linux-machine-using-tc-script