# 10/11 (CEF/dijkstra algorithm/OSPF
###### tags: `Networking` `CCNA`
[TOC]
## CEF(cisco express forwarding)
CEF is a CISCO default Rule, the Rule is True.
IF(CEF is True ){
it's not going to look up a routing table, it will only go one of these ways.
}

### CEF == TRUE(default)

### CEF == False
```
R1(config)#no ip cef
R2(config)#no ip cef
```
### Result
0/0

0/1

RIP-ECMP(equal cost multipathpaht routing) only consider the hop of numbers
OSPF-ECMP, only consider the bandwidth
EIGRP
It consider a bandwidth, delay,reliability,cost and MTU.
>
>- Advantage: Load balance
>- Disadvantage: It's going to increase the occurred rate of the out-of-order problem
## dijkstra algorithm
dijkstra is to find the shortest path between any two vertex in the graph
## Find the shortest path from vertex A to every other vertex.
### example
**TO get from A to C

## Generate the table
we use two list, one to keep track of the vertices that we visited and another to keep track of the vertices that we haven't visited yet.

Algorithm
```
let distance of start vertex from start vertex =0
let distance of all other vertices form start = infinity
while 1
Visit the unvisited vertex with the smallest known distance from the start vertex
For the current vertex examine its unvisited neighbourt from start vertex
if(the calculated distance of a vertex is less than known distance){
update the shortest path distance
}
Update the previous vertex for each of the updated distances
add the current vertex to the list of visited vertices
Until all vertices visited
```
## OSPF(Open Shortest Path First)
cost -> dijkstra algorithm


Configure OSFP
R1
```
r1(config)#router ospf 100 #A Process ID is a local remark, so each device can use a different Process ID
r1(config-router)#network 12.0.0.0 0.0.0.255 area 0
```
R2
```
r2(config)#router ospf 100
r2(config-router)#network 12.0.0.0 0.0.0.255 area 0
r2(config-router)#network 23.1.0.0 0.0.0.255 area 0
```
R3
```
r3(config)#router ospf 100
r3(config-router)#network 23.1.0.0 0.0.0.255 area 0
```
Wildcard mask: specify segment of IP address that needs to be checked, using deny or allow the IP whether it could go through or not.
Result

ad = 110
cost = 10**8 bps / bandwidth
Ethernet = 10 mps

10**8 / 10 * 10\**6 = 10
one hop = 10 (cost)
So, we could know there have two hops.
### Packet types
1.hello
2.Database Description
3.LSR(link state request)
4.LSU(link state update)
5.LSA(link state acknowlege)
### OSPF table
neighbor table
```
r1(config)#do show ip ospf neighbor
```
```
r2(config)#do show ip ospf database
```

---