Showing posts with label OSPF. Show all posts
Showing posts with label OSPF. Show all posts

Wednesday, September 19, 2012

OSPF Packet Format

Packet Format: Taken from,

http://docwiki.cisco.com/wiki/Open_Shortest_Path_First 

This is useful when you are looking at a packet capture of an OSPF packet. Same can be said for any packet format visualization of any protocol. I am reviewing some OSPF reading material and figured I would post this.

All OSPF packets begin with a 24-byte header, as illustrated in Figure: OSPF Packets Consist of Nine Fields.
Figure: OSPF Packets Consist of Nine Fields
CT844602.jpg
The following descriptions summarize the header fields:
  • Version number - Identifies the OSPF version used.
  • Type - Identifies the OSPF packet type as one of the following:
    • Hello - Establishes and maintains neighbor relationships.
    • Database description - Describes the contents of the topological database. These messages are exchanged when an adjacency is initialized.
    • Link-state request - Requests pieces of the topological database from neighbor routers. These messages are exchanged after a router discovers (by examining database-description packets) that parts of its topological database are outdated.
    • Link-state update - Responds to a link-state request packet. These messages also are used for the regular dispersal of LSAs. Several LSAs can be included within a single link-state update packet.
    • Link-state acknowledgment - Acknowledges link-state update packets.
  • Packet length - Specifies the packet length, including the OSPF header, in bytes.
  • Router ID - Identifies the source of the packet.
  • Area ID - Identifies the area to which the packet belongs. All OSPF packets are associated with a single area.
  • Checksum - Checks the entire packet contents for any damage suffered in transit.
  • Authentication type - Contains the authentication type. All OSPF protocol exchanges are authenticated. The authentication type is configurable on per-area basis.
  • Authentication - Contains authentication information.
  • Data - Contains encapsulated upper-layer information.

Monday, August 13, 2012

OSPF Packet Details & Dijkstra's Algorithm: Shortest Path Video

Taken from http://cisco.iphelp.ru/faq/5/ch08lev1sec1.html#ch08fig01

Dijkstra's Algorithm: Shortest Path - Easy To Understand


OSPF Packet Details

OSPF has five types of packets used for various reasons. Table 8-1 documents the different OSPF packet types and describes their functionality.

Table 8-1. OSPF Packet Types
Type Description Functionality
1 Hello To discover neighbors and form DR/BDR relationship and exchange neighbor capabilities.
2 Database description To elect master/slave for the database exchange process and to exchange the LSA headers and select the first sequence number for database exchange.
3 Link-state request To request a specific LSA that is seen during the DBD exchange process.
4 Link-state update To send the entire LSA to the neighbor who requested the particular LSA through the link request packet. This packet is also used in flooding.
5 Link-state acknowledge To acknowledge the receipt of the link-state update packet.
All the OSPF packet types share a common 20-byte OSPF protocol header. Figure 8-1 shows the common OSPF protocol header format.
Figure 8-1. Common OSPF Protocol Header Format
graphics/08fig01.gif
The list that follows describes the fields in the OSPF protocol header:
  • Version Number— This field represents the current version number of OSPF. The latest version is 2. Version 1 is not compatible with Version 2.
  • Type— This field indicates which of the five types of OSPF packets is appended at the end of this header.
  • Packet Length— This field contains the length of the entire OSPF packet, including the OSPF header.
  • Router ID— This field contains the 4-byte IP address. The router ID is used to uni-quely identify the router throughout the autonomous system. For a Cisco box, this field contains the highest IP address on the box. If loopbacks are configured, the highest loopback becomes the router ID.
    After the router ID is chosen, it will not change unless the router is restarted, the inter-face that is selected as a router ID is shut down, or the IP address has been removed or replaced on that interface.
  • Area ID— This field designates the area number to which this packet belongs. This is also a 4-byte number. The value must be the same on both sides to form neighbor relationships. There are two ways to write this: Area 1 or Area 0.0.0.1. There is no difference between the two.
  • Checksum— This field includes the checksum for the entire OSPF packet, excluding the authentication for data corruption.
  • AuType— This field contains the type code for the authentication:
    - 0 means that there is a null authentication.
    - 1 means that the authentication type is plain text.
    - 2 means that the authentication type is MD5.
  • Authentication— This 64-bit field contains the authentication key in case of plain-text authentication. In case of message digest, the 64-bit Authentication field is redefined into several other parameters. See Appendix D of RFC 2328 for more detail on the MD5 authentication scheme.

Hello Packets

Hello packets are the first type of packets in OSPF. Figure 8-2 illustrates the Hello packet format. Hello packets are used to form a neighbor relationship between two routers. In environments that include broadcast/nonbroadcast media, Hello packets are used to elect the designated (DR) and backup designated (BDR) routers. On broadcast media, the destination address of the Hello packets is 224.0.0.5. On nonbroadcast media, the destination address is unicast.
Figure 8-2. Hello Packet Format
graphics/08fig02.gif
The list that follows describes the fields in the Hello packet:
  • Network Mask— Represents the network mask of the interface on which OSPF is running. The network mask is checked only on broadcast media.
  • Hello Interval— Represents the number of seconds between two Hello packets. This interval must be the same for the two routers that are trying to form an adjacency. The Hello interval is 10 seconds on broadcast and point-to-point media, and 30 seconds on all other media.
  • Options— Represents the optional capabilities supported by the router. The Options field has the following format:
    * O DC EA N/P MC E T
    - O bit is used for opaque LSAs, mentioned in RFC 2370
    - DC is used for demand circuit capabilities, mentioned in RFC 1793
    - EA is the external attribute
    - N/P is used for not-so-stubby area (NSSA) option, mentioned in RFC 1587
    - MC designates multicast OSPF
    - E, when set, means that external LSA are allowed in this area
    - T bit is used for ToS capability (normally set to 0)
    The first bit in the Options field is reserved for future use. Cisco routers also do not use EA and MC bits.
  • Rtr Pri— Used for a router's priority. By default, this value is set to 1. This field plays an important role in electing the DR and the BDR. A higher priority increases the chances that the router will become the DR. A priority of 0 means that this router will not take part in DR election.
  • Router Dead Interval— Represents the number, in seconds, before a neighbor is declared dead. By default, the dead interval is four times the Hello interval.
  • Designated Router— Lists the IP address of the designated router. If there is no DR, this field has a value of 0.0.0.0. The DR is elected through the Hello protocol. The router with the highest priority becomes the DR. If the priorities are equal, the router with the highest router ID becomes the DR. The purpose of the DR is to reduce the amount of flooding on multiaccess media. The DR uses multicasting to reduce the amount of flooding. All routers flood their link-state database to the DR, and the DR then floods that information back to other routers on that segment. No DRs/BDRs exist on point-to-point or point-to-multipoint segments.
  • Backup Designated Router— Identifies the BDR and lists the interface IP address of the BDR. If no BDR exists, this field has a value of 0.0.0.0. The BDR is also elected through the Hello protocol. The purpose of the BDR is to serve as the backup of the DR, for a smoother transition in case the DR dies. BDR remains passive during flooding.
  • Neighbor— Contains the router ID of each neighbor from which a Hello is seen.

Database Description Packets

The second type of OSPF packet, the database description (DBD) packet, is used mostly during the database exchange. The first DBD packet is used to elect the master and slave relationship and to set the initial sequence number elected by the master. The router with the highest router ID becomes the master and initiates the database synchronization. The master sends the sequence number, and the slave acknowledges it. After the master and the slave are elected, the database synchronization starts; in this process, the headers of all the LSAs are exchanged with neighbors. Figure 8-3 illustrates the DBD packet format.
Figure 8-3. Database Description Packet Format
graphics/08fig03.gif
The list that follows describes the fields in the DBD packet:
  • Interface MTU— This field contains the largest data size, in bytes, that can be send through the associated interface. This option has been added starting from RFC 2178. This field must be set to 0 when sending the packet over a virtual link.
  • Options— Options for this field were discussed in the previous section on the Hello packet format.
  • I Bit— When set to 1, this means that this is the first packet in DBD exchange.
  • M Bit— When set to 1, this means that more packets will follow.
  • MS Bit— Use this for master and slave. When this bit is set, it means that the router is a master in the DBD exchange process. If this bit is set to 0, it means that the router is the slave.
  • DBD Sequence Number— This field contains a unique value set by the master. This sequence number is used during database exchange. Only a master can increment the sequence number.
  • LSA Header— This field consists of a list of the link-state database headers.

Link-State Request Packets

The Type 3 OSPF packet, a link-state request packet, is sent if part of the database is missing or out-of-date. The link-state request packet is used to retrieve that precise piece of database information that is missing. Link-state packets are also used after the DBD exchange is finished to request the LSAs that have been seen during the DBD exchange. Figure 8-4 illustrates the link-state request packet format.
Figure 8-4. Link-State Request Packet Format
graphics/08fig04.gif
The list that follows describes the fields in the link-state request packet:
  • LS Type— Identifies what type of LSA is being requested.
  • Link-State ID— Represents the link-state ID of that specific LSA. Link-state ID is discussed later in this chapter.
  • Advertising Router— Contains the router ID of the router that is originating this LSA.

Link-State Update Packets

OSPF packet Type 4, the link-state update packet, implements flooding. Several LSAs are included in a single packet. Link-state update packets are also sent in response to link-state request packets. Flooded LSAs are acknowledged in the LSA acknowledgment packet. If an LSA is not acknowledged, it is retransmitted every retransmit interval (5 seconds, by default). Figure 8-5 illustrates the link-state update packet format.
Figure 8-5. Link-State Update Packet Format
graphics/08fig04.gif
As Figure 8-5 shows, this packet contains the number of LSAs (for example, 10 or 20 LSAs), followed by the LSA itself.

Link-State Acknowledgment Packet

The last type of OSPF packet, the link-state acknowledgment packet, is used to acknow-ledge each LSA. This packet is sent in response to link-state update packets. Multiple LSAs can be acknowledged in a single link-state acknowledgment packet. This packet is respon-sible for the reliable delivery of link-state update packets. Figure 8-6 illustrates the link-state acknowledgment packet format.
Figure 8-6. Link-State Acknowledgment Packet Format
graphics/08fig06.gif
Link-state acknowledgment packets are sent as multicasts. If the state of the router is DR or BDR, the acknowledgment is sent to the OSPF router multicast address of 224.0.0.5. If the state of the router is not DR or BDR, the acknowledgment is sent to the all DR router multicast address of 224.0.0.6.



Saturday, August 4, 2012

Cisco Nexus3064 Debug - OSPF

While troubleshooting some OSPF issues, I notice that NX_OS has a nice feature for the debug command. You can debug on a per interface basis and you can also specify multiple interfaces as well. I always recommend when you run any debug command that you open up a second session into the device in case your current window gets overloaded with debug details. This allows you to issue a undebug all on the new window. This can be a lifesaver..

Cisco3064(config)# debug-filter ip ospf interface ethernet 1/29
Cisco3064(config)# debug ip ospf hello
Cisco3064(config)# debug ip ospf retransmission
Cisco3064(config)# 2012 Aug  4 10:40:34.366851 ospf: 64996 [14437] (default)  P2P hello out, ivl 5/15, options 0x02, mask /31 nbrs 1 on Ethernet1/29 (area 0.0.0.200)
2012 Aug  4 10:40:34.390927 ospf: 64996 [14437] (default) P2P hello in, ivl 5/15, options 0x12, mask /31, on Ethernet1/29 from 192.168.222.188
2012 Aug  4 10:40:38.787021 ospf: 64996 [14437] (default)  P2P hello out, ivl 5/15, options 0x02, mask /31 nbrs 1 on Ethernet1/29 (area 0.0.0.200)
2012 Aug  4 10:40:39.309019 ospf: 64996 [14437] (default) P2P hello in, ivl 5/15, options 0x12, mask /31, on Ethernet1/29 from 192.168.222.188
2012 Aug  4 10:40:43.097571 ospf: 64996 [14437] (default)  P2P hello out, ivl 5/15, options 0x02, mask /31 nbrs 1 on Ethernet1/29 (area 0.0.0.200)
2012 Aug  4 10:40:43.869513 ospf: 64996 [14437] (default) P2P hello in, ivl 5/15, options 0x12, mask /31, on Ethernet1/29 from 192.168.222.188
2012 Aug  4 10:40:46.867897 ospf: 64996 [14437] (default)  P2P hello out, ivl 5/15, options 0x02, mask /31 nbrs 1 on Ethernet1/29 (area 0.0.0.200)
2012 Aug  4 10:40:48.686036 ospf: 64996 [14437] (default) P2P hello in, ivl 5/15, options 0x12, mask /31, on Ethernet1/29 from 192.168.222.188
2012 Aug  4 10:40:50.887911 ospf: 64996 [14437] (default)  P2P hello out, ivl 5/15, options 0x02, mask /31 nbrs 1 on Ethernet1/29 (area 0.0.0.200)
2012 Aug  4 10:40:53.242538 ospf: 64996 [14437] (default) P2P hello in, ivl 5/15, options 0x12, mask /31, on Ethernet1/29 from 192.168.222.188

Additional Commands:

Cisco3064# show debug ip ospf
debug ip ospf hello
debug ip ospf retransmission

Cisco3064# show debug-filter  ip ospf
debug-filter ip ospf interface Ethernet1/29






Wednesday, March 21, 2012

OSPF Authentication - IPV4

In ospf you have three different authentication types and two different ways to configure them. The three types are in table 1 and very brief  description.

Table 1

Type #Description
Type 0 no authentication(Default)
Type 1Clear Text
Type 2MD5


We are going to use Diagram 1 for this write up.

Diagram 1
 Configuring Authentication:
You can enable MD5 authentication globally for the entire area via router configuration mode or you can enable it on a per interface and the per interface overrides the global configuration method. You also still need to define the key under the interface, I think it's just easier and more formal to configure it under the interface and not globally.

Enable MD5 Auth on all interface in Area 0

R1(config)#router ospf 1
R1(config-router)#area 0 authentication message-digest

Clear Text - Type 1

R1(config-if)#ip ospf authentication
R1(config-if)#ip ospf authentication-key joel

MD5 - Type 2

R1(config-if)#ip ospf authentication message-digest
R1(config-if)#ip ospf message-digest-key 1 md5 joel

You can also configure more then one key but note that you will send duplicate hello's out, one for each key. In eigrp you have the luxury of using a key-chain setup that allows you to configure expiration dates on keys. When you configure expiration dates, make sure your devices are using NTP for time sync configuration or PTP - 1588.

Verifying Authentiion Settings:

You can see all the way at the bottom of this output that we are using MD5. The only way to truly confirm all your configurations are correct is to verify you have established a neighborship.

R1#show ip ospf int f0/0
FastEthernet0/0 is up, line protocol is up
  Internet Address 192.168.10.1/24, Area 0
  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1
  Enabled by interface config, including secondary ip addresses
  Transmit Delay is 1 sec, State DR, Priority 10
  Designated Router (ID) 1.1.1.1, Interface address 192.168.10.1
  Backup Designated router (ID) 2.2.2.2, Interface address 192.168.10.2
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    oob-resync timeout 40
    Hello due in 00:00:01
  Supports Link-local Signaling (LLS)
  Index 1/1, flood queue length 0
  Next 0x0(0)/0x0(0)
  Last flood scan length is 1, maximum is 3
  Last flood scan time is 0 msec, maximum is 0 msec
  Neighbor Count is 1, Adjacent neighbor count is 1
    Adjacent with neighbor 2.2.2.2  (Backup Designated Router)
  Suppress hello for 0 neighbor(s)
  Message digest authentication enabled
    Youngest key id is 1


R1#show ip ospf neighbor
Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2           1   FULL/BDR        00:00:39    192.168.10.2    FastEthernet0/0
R1#