OSPF Simulation Tutorial for Beginners (Interactive, Visual)

OpenVPN tutorials ranging from configuration to hacks to compilation will be posted here.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
vl1111
OpenVpn Newbie
Posts: 2
Joined: Sun Feb 13, 2011 2:10 pm

OSPF Simulation Tutorial for Beginners (Interactive, Visual)

Post by vl1111 » Sun Feb 13, 2011 2:12 pm

OSPF Simulation Tutorial for Beginners (Interactive, Visual)

OSPF is a complex protocol. To help beginners grasp abstract its concepts, a different approach is taken -- Visualizing OSPF simulation. This tutorial, OSPF basic, simulates the basic OSPF activities on a simple topology: H1-R1-R2-H2. R1 and R2 are routers. H1 and H2 are hosts. This simulation shows 4 stages:
1) R1 and R2 are not running OSPF. H1 ping H2. It fails.
2) Start OSPF on two routers. R1 and R2 discover each other as neighbors by flooding Hello.
3) R1 and R2 develop Full relationship and synchronize their LSA (Link State Advertisement) database by sending DD, Request, and Update. R1 and R2 refresh their routing tables. H1 and H2 become reachable.
4) H1 pings H2 again. It succeeds this time.
Q1. What is OSPF?
Answer: OSPF is a link state routing protocol. OSPF routers exchange their Link State Advertisement (OSPF LSA) to learn interface IP addresses from each other. Each router saves its LSAs in its Link State Database (LSDB.) Neighboring nodes synchronize their LSDBs. With consistent LSDBs, OSPF routers are able to calculate shortest paths to reach destinations.
Q2. What does OSPF do?
Answer: Roughly, OSPF is going through the following stages:
1) OSPF node creates a Router LSA to describe its interface IP addresses. This LSA is the most basic LSA.
2) Routers discover neighbors by flooding Hello. When a pair find each other, they are in 2-way state.
3) Neighbors synchronize their LSDBs in three steps:
i. Send DD to get LSDB catalog from each other.
ii. Send Request to ask for missing LSAs.
iii. Send Update to transmit LSAs requested.
When two neighbors have the same LSDB, they are in Full Adjacency state.
4) With the same LSDB, routers have consistent knowledge of the network topology and interface IP addresses. They can calculate routing paths independently and update their routing tables. The collection of routing tables from OSPF routers provides the shortest paths between destinations.
Q3. What is Router LSA?
Answer: Each OSPF router creates a Router LSA to describe its interfaces' IP addresses. In a very simple OSPF network, only Router LSAs are needed to calculate shortest paths.
Q4. What does Router LSA do?
Answer: In a simple OSPF network (no LAN, no area), neighboring nodes exchange their Router LSAs and learn how many links its neighbor has, and their interface IP addresses. After neighbor propagation, all OSPF nodes have the same set of Router LSAs in their LSDBs. Now they have the same knowledge of network topology.
Q5. How can a router use LSDB to calculate routing paths?
Answer: From LSDB, an OSPF node learns the complete topology of the network: the number of routers being connected; Individual router's interfaces and their IP addresses; Interface link costs (OSPF metric). With such detail information, OSPF calculates shortest paths to reach all destinations found in LSDB.
For example [a], in the OSPF simulation, R1's LSDB contains two Router LSAs:
1) R1 originated LSA contains two IP addresses: 192.168.1.0/24,192.168.3.0/30.
2) R2 originated LSA contains two IP addresses: 192.168.2.0/24,192.168.3.0/30.
After LSDB synchronization, R1 and R2 both have these two LSAs. And they know that R1 and R2 are connected by the link 192.168.3.0. Now R1 can calculate routing path to reach remote destination 192.11.68.2.2 and adds an entry (192.168.2.0/24, S1/0) to its routing table.
Note [a]: This article is the FAQ of OSPF simulation. After reading, you can play the interactive simulation listed in External Links. It visualize OSPF work flow with moving packets are changing tables.
External links for interactive OSPF simulations:
1. OSPF simulation for beginners (This article): http://www.visualland.net/view.php?cid= ... ic&ctype=1
2. List of additional interactive OSPF simulation (Table of Content): http://www.visualland.net/protocol.over ... ew&ctype=1

User avatar
Traffic
OpenVPN Protagonist
Posts: 4066
Joined: Sat Aug 09, 2014 11:24 am

Re: OSPF Simulation Tutorial for Beginners (Interactive, Vis

Post by Traffic » Sat Aug 01, 2015 8:06 pm

vl1111 wrote:Q3. What is Router LSA?
not sure you answered that ?

URLs are non-functional.

User avatar
Nucleardragon
OpenVpn Newbie
Posts: 8
Joined: Mon Sep 02, 2013 12:05 pm
Contact:

Re: OSPF Simulation Tutorial for Beginners (Interactive, Vis

Post by Nucleardragon » Tue Feb 16, 2016 1:01 pm

Can somebody explain me, how to run OSPF with OpenVPN?
In fact it is not simple,
when i use p2m topology I must specify "--iroute" on the OpenVPN server side, but in this case why i need dynamic routing (OSPF) if i need write irote
ok, i need to use p2p topology and in this case need not specify --iroute,
but what is can do if OpenVPN client has only dynamic IP or in general is behind a NAT?

User avatar
Traffic
OpenVPN Protagonist
Posts: 4066
Joined: Sat Aug 09, 2014 11:24 am

Re: OSPF Simulation Tutorial for Beginners (Interactive, Vis

Post by Traffic » Tue Feb 16, 2016 10:01 pm

Does OSPF require --dev tap or is it a routable protocol ?

User avatar
Nucleardragon
OpenVpn Newbie
Posts: 8
Joined: Mon Sep 02, 2013 12:05 pm
Contact:

Re: OSPF Simulation Tutorial for Beginners (Interactive, Vis

Post by Nucleardragon » Wed Feb 17, 2016 7:51 am

Step by step, how I solved this issues:
1. OpenVPN with p2p topology when one side is behind a sNAT:

Sever OpenVPN config:

Code: Select all

#Point-to-Point
dev tun30
proto udp
port 1195
topology subnet
nice -19
#link-mtu 1300
fragment 1340
mssfix
#mssfix 1200
replay-window 256 60
#replay-window  128 30
#hand-window 30
sndbuf 524288
rcvbuf 524288
fast-io
txqueuelen 1000
ifconfig 192.168.254.25 255.255.255.252
mtu-disc maybe
keepalive 5 30
mlock
secret /opt/openvpn-2.3.10/etc/keys/ovpn-ta.key
auth SHA1
cipher BF-CBC
user root
group root
persist-key
persist-tun
verb 4
Clien OpenVPN config:

Code: Select all

dev tun30
nobind
remote 19.24.20.3 1195
proto udp
topology subnet
nice -19
#link-mtu 1300
fragment 1300
mssfix
#mssfix 1200
replay-window 256 60
#replay-window  128 30
#hand-window 30
sndbuf 524288
rcvbuf 524288
txqueuelen 1000
fast-io
ifconfig 192.168.254.26 255.255.255.252
mtu-disc maybe
keepalive 2 10
mlock
secret /opt/openvpn-2.3.10/etc/ovpn-ta.key
auth SHA1
cipher BF-CBC
user root
group root
persist-key
persist-tun
verb 4
OSPF (quagga) can work with tun interface.
ospfd.conf:

Code: Select all

interface tun30
    description Internal_interface
    ip ospf authentication message-digest
    ip ospf message-digest-key 1 md5 123456789
    ip ospf cost 50
    ip ospf hello-interval 1
    ip ospf dead-interval 5
! (broadcast|non-broadcast|point-to-multipoint|point-to-point)
    ip ospf network point-to-point
    ip ospf priority 10
    ip ospf retransmit-interval 5
    ip ospf transmit-delay 1

router ospf
ospf router-id 10.10.10.10
    redistribute kernel metric 200
    redistribute connected metric 200
    redistribute static metric 200
!    default-information originate
    network 192.168.254.0/24 area 0
 
Proof that OSPF works:

Code: Select all

tcpdump -ni tun30 proto ospf
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on tun30, link-type RAW (Raw IP), capture size 262144 bytes
02:33:27.035727 IP 192.168.254.25 > 224.0.0.5: OSPFv2, Hello, length 48
02:33:27.201675 IP 192.168.254.26 > 224.0.0.5: OSPFv2, Hello, length 48

Code: Select all

ip route list|grep tun30
default via 192.168.254.25 dev tun30  proto zebra  metric 10
10.134.0.0/16 via 192.168.254.25 dev tun30  proto zebra  metric 100
192.168.11.0/24 via 192.168.254.25 dev tun30  proto zebra  metric 100
192.168.11.3 via 192.168.254.25 dev tun30  proto zebra  metric 100
192.168.11.4 via 192.168.254.25 dev tun30  proto zebra  metric 100
192.168.11.5 via 192.168.254.25 dev tun30  proto zebra  metric 100
192.168.254.24/30 dev tun30  proto kernel  scope link  src 192.168.254.26
192.241.207.0/24 via 192.168.254.25 dev tun30  proto zebra  metric 100

Post Reply