Entries Tagged as ''

DSCP PHB Groups

PHB is per-hop behavior defined by RFC 2475. There are two types of PHB groups, AF and EF. AF is Assured Forwarding defined by RFC 2597. EF is Expedited Forwarding defined by RFC 2598.

AF group have 4 classes, each of them has 3 levels. The following table shows codepoint-to-PHB mapping.

AF-Table

Class Low Drop Precedence Medium Drop Precedence High Drop Precedence
AF1 AF11(001010) AF12(001100) AF13(001110)
AF2 AF21(010010) AF22(010100) AF23(010110)
AF3 AF31(011010) AF32(011100) AF33(011110)
AF4 AF41(100010) AF42(100100) AF43(100110)

EF group only has one level, which is DSCP 46. The main purpose of EF is to introduce as little delay and jitter as possible.

EF-Table

Class Precedence
EF DSCP 46 (101110)

The following are output for IP DSCP.

R3(config-cmap)#match ip dscp ?
<0-63>   Differentiated services codepoint value
af11     Match packets with AF11 dscp (001010)
af12     Match packets with AF12 dscp (001100)
af13     Match packets with AF13 dscp (001110)
af21     Match packets with AF21 dscp (010010)
af22     Match packets with AF22 dscp (010100)
af23     Match packets with AF23 dscp (010110)
af31     Match packets with AF31 dscp (011010)
af32     Match packets with AF32 dscp (011100)
af33     Match packets with AF33 dscp (011110)
af41     Match packets with AF41 dscp (100010)
af42     Match packets with AF42 dscp (100100)
af43     Match packets with AF43 dscp (100110)
cs1      Match packets with CS1(precedence 1) dscp (001000)
cs2      Match packets with CS2(precedence 2) dscp (010000)
cs3      Match packets with CS3(precedence 3) dscp (011000)
cs4      Match packets with CS4(precedence 4) dscp (100000)
cs5      Match packets with CS5(precedence 5) dscp (101000)
cs6      Match packets with CS6(precedence 6) dscp (110000)
cs7      Match packets with CS7(precedence 7) dscp (111000)
default  Match packets with default dscp (000000)
ef       Match packets with EF dscp (101110)

Split Horizon and Poison Reverse

In short, split horizon is to prohibit a router from advertising a route back out the interface from which it was learned. Why we need to introduce this approach? Let’s see the following example first.

Distance-Vector routing protocol like RIPv1 and RIPv2 have slow convergence and count-to-infinity issues. We assume the network is: A — B — C. A, B and C are three routers running RIP routing protocol. In the convergence status, B knows there is one hop to C and A knows there are two hops to C via B. If the link is broken between B and C, since B get advertisement from A that there are 2 hops can get to C from A. Then, B updates its routing table to set hop to 3. A get advertisement from B. Then A updates its routing table to set hop to 4, so on and so on until count to infinity. The network will never be convergence status.

Split horizon is useful in this situation. Following the definition, A will not send advertisement to B since A learned route to C from B. It effectively reduces the count-to-infinity problem. To speed up convergent in RIP network, it introduce the maximum hop number is 15. In the case above, when the link between B and C is broken, B sends advertisement to A that the hop to go to C is 16, which is called split horizon with poison reverse. Then, A knows that C is unreachable and updates its routing table.

However, split horizon with poison reverse does have disadvantages.

First, it increases the size of the routing messages. In a hub-spoke network, hub is as backbone router and each spoke is as gateway router. “If split horizon with poisoned reverse is used, the gateway must mention all routes that it learns from the backbone, with metrics of 16. If the system is large, this can result in a large update message, almost all of whose entries indicate unreachable networks.”

Second, it will prevent any routing loops that involve only two gateways engaged in mutual deception. It is highly possible that three or more gateways in this situation. So, RFC 1058 introduces “Triggered updates” approach. In short, it is required to send update messages almost immediately whenever a gateway changes the metric for a route. Split horizon processing is done when generating triggered updates as well as normal updates.

Since this is nature born characters of distance-vector routing protocol, more sophisticated routing protocols are applied in the industry such as OSPF.

Start to be network expert

Today is very meaningful to me. I have been Canadian Citizenship from now on. Although there are only 33 million people lived in here, I will be free as bird to be a citizenship.

Also, I decided to start to pursue to be a network expert. This blog will be my notes for every knowledge point.

The following will be my first one.

To prepare lab, we need Cisco simulators. All CCIEs around me, (I mean, truly, they are sitting around me), recommend dynamips. You can get some detailed information from dynagen. You can start your router simulators separately in one local machine, or, you can use dynagen to have central management from CLI interface. I prefer start router separately. The command is to start a brand new router (Cisco 3660) with NM-4T module. You also need to setup –idle-pc value if you don’t want to use the whole CPU. You can bind fa0/0 and fa0/1 to your physical interface. Then, just enjoy your trip.

dynamips -P 3600 -i 2 -X -r 256 ./3660.image -t 3660 –idle-pc=0×60680cb0 -s 0:0:linux_eth:eth3 -s 0:1:linux_eth:eth0 -p 1:NM-4T

Two’s-complement System

Two’s-complement system is the most common method of representing signed integers on computers. The alternatives are One’s complement, Sign-and-magnitude and Biased representation. An N-bit two’s-complement system can represent every signed interger in the range from -2^(N-1) to 2^(N-1)-1.

Negating a two’s complement number is simple: Invert all the bits and add one to the result. For 32-bit integer, negating 0xFFFF, we get 0×0000 + 1 = 1. Therefore, 0xFFFF must represent -1. Thus, when we use _mm_set1_epi8(-1), which is defined in SSE library, it will set 16 singned 8-bit integer value to 0xFF.

Right-shift negtive integer will always set the highest bit. So, right-shift -1 will always get -1. The following is the result after -1 left-shift 31 bit.

#include <stdio.h>
int main()
{
signed int a;
a = -1;
printf(“a is %d\n”,a);
a = a << 31;
printf(“a is now %d\n”,a);
return 0;
}

a is -1
a is now -2147483648