19.0 APPENDIX A: Link-State Database Synchronization

spf25

In the above diagram, routers on the same segment go through a series of states before forming a successful adjacency. The neighbor and DR election are done via the Hello protocol. Whenever a router sees itself in his neighbor's Hello packet, the state transitions to "2-Way". At that point DR and BDR election is performed on multi-access segments. A router continues forming an adjacency with a neighbor if either of the two routers is a DR or BDR or they are connected via a point-to-point or virtual link.

In the Exstart state,the two neighbors form a Master/Slave relationship where they agree on a initial sequence number. The sequence number is used to detect old or duplicate Link-State Advertisements (LSA).

In the Exchange state, Database Description Packets (DD) will get exchanged. These are abbreviated link-state advertisements in the form of link-state headers. The header supplies enough information to identify a link. The master node sends DD packets which are acknowledged with DD packets from the slave node. All adjacencies in exchange state or greater are used by the flooding procedure. These adjacencies are fully capable of transmitting and receiving all types of OSPF routing protocol packets.

In the Loading state, link-state request packets are sent to neighbors, asking for more recent advertisements that have been discovered but not yet received. Each router builds a list of required LSAs to bring its adjaceny up to date. A Retransmission List is maintained to make sure that every LSA is acknowledged. Link-state update packets are sent in response to request packets. The link-state update packets will be flooded over all adjacencies. In the Full state, the neighbor routers are fully adjacent. The databases for a common area are an exact match between adjacent routers.

Each LSA has an age field that gets periodically incremented while it is contained in the database or as it gets flooded throughout the area. When an LSA reaches a Maxage it gets flushed from the database if that LSA is not on any neighbors retransmission list.


19.1 Link-State Advertisements

spf26

Link-state advertisements are broken into five types. Router Links (RL) are generated by all routers. These links describe the state of the router interfaces inside a particular area. These links are only flooded inside the router's area. Network Links (NL) are generated by a DR of a particular segment; these are an indication of the routers connected to that segment. Summary Links (SL) are the inter-area links (type 3); these links will list the networks inside other areas but still belonging to the autonomous system. Summary links are injected by the ABR from the backbone into other areas and from other areas into the backbone. These links are used for aggregation between areas. Other types of summary links are the asbr-summary links. These are type 4 links that point to the ASBR. This is to make sure that all routers know the way to exit the autonomous system. The last type is type 5, External Links (EL), these are injected by the ASBR ! into the domain. These links are The above diagram illustrates the different link types. RTA generates a router link (RL) into area 1, and it also generates a network link (NL) since it happens the be the DR on that particular segment. RTB is an ABR, and it generates RL into area 1 and area 0. RTB also generates summary links into area 1 and area 0. These links are the list of networks that are interchanged between the two areas. An ASBR summary link is also injected by RTB into area 1. This is an indication of the existence of RTD, the autonomous system border router. Similarly RTC, which is another ABR, generates RL for area 0 and area 2, and a SL (3) into area 2 (since it is not announcing any ASBR), and a SL (3,4) into area 0 announcing RTD. RTD generates a RL for area 2 and generates an EL for external routes learned via BGP. The external routers will be flooded all over the domain.

The following table is a summary of the link state advertisements.

LINK STATE ADVERTISEMENTS

LS type Advertisement Description
1 Router Link advertisements. Generated by each router for each area it belongs to. They describe the states of the router's link to the area. These are only flooded within a particular area.
2 Network Link advertisements. Generated by Designated Routers. They describe the set of routers attached to a particular network. Flooded in the area that contains the network.
3 or 4 Summary Link advertisements. Generated by Area Border routers. They describe inter-area (between areas) routes. Type 3 describes routes to networks, also used for aggregating routes. Type 4 describes routes to ASBR.
5 AS external link advertisements. Originated by ASBR. They describe routes to destinations external to the AS. Flooded all over except stub areas.

If you look at the OSPF database in detail, using sh ip ospf d d, you will see different keywords such as Link-Data, Link-ID, and Link-state ID. These terms become confusing as the value of each depends on the link state type and the link-type. We will go over this terminology and will provide a detailed example on the OSPF database as seen from the router.

The Link-State ID basically defines the identity of the link-state depending on the LS type. Router Links are identified by the router ID (RID) of the router that originated the advertisement. Network Links are identified by the relative IP address of the DR. This makes sense because Network Links are originated by the Designated Router. Summary Links (type 3)are identified by the IP network numbers of the destinations they are pointing at. ASBR Summary Links (Summary Links type 4) are identified by the RID of the ASBR. Finally, External Links are identified by the IP network numbers of the external destinations they are pointing at. The following table summarizes this information:

LS type Link State ID

(In the high level view of the database when referencing a router this is called Link ID)

1 The originating Router's Router ID (RID).
2 The IP interface address of the network's Designated Router.
3 The destination network number.
4 The router ID of the described AS boundary router.
5 The external network number.

Next, we will describe the different links available:

Stub network links: This term has nothing to do with Stub areas. A stub segment is a segment that has one router only attached to it. An Ethernet or Token Ring segment that has one attached router is considered a link to a stub network. A loopback interface is also considered a link to stub network with a 255.255.255.255 mask (Host route).

Point-to-point links: These could be physical or logical (subinterfaces) point-to-point serial link connections. These links could be numbered (an IP address is configured on the link) or unnumbered.

Transit links: These are interfaces connected to networks that have more than one router attached, hence the name transit.

Virtual links: These are logical links that connect areas that do not have physical connections to the backbone. Virtual links are treated as numbered point-to-point links.

The link-ID is an identification of the link itself. This is different for each link type. A transit link is identified by the IP address of the DR on that link. A numbered point-to-point link is identified by the RID of the neighbor router on the point-to-point link. Virtual links are identical to point-to-point links. Finally, links to stub networks are identified by the IP address of the interface to the stub network. The following table summarizes this information:

Link type Link ID

(This applies to individual Links)

Point-to-Point Neighbor Router ID
Link to transit network Interface address of DR
Link to stub network

(In case of loopback mask is 255.255.255.255)

Network/subnet number
Virtual Link Neighbor Router ID

The Link Data is the IP address of the link, except for stub network where the link data is the network mask.

Link type Link Data
Stub network Network Mask
Other networks (applies to router links only) Router's associated IP interface address

Finally, an Advertising Router is the RID of the router that has sent the LSA.


19.2 OSPF database example

spf27

Given the above topology, and the following configs, and the IP route tables, let us look at different ways of understanding the OSPF database.


19.2.1 General view of the database


 RTC#sh ip ospf database

       OSPF Router with ID (203.250.15.67) (Process ID 10)

                Router Link States (Area 1)

Link ID         ADV Router      Age    Seq#       Checksum Link count
203.250.15.67   203.250.15.67   48     0x80000008 0xB112   2
203.250.16.130  203.250.16.130  212    0x80000006 0x3F44   2

                Summary Net Link States (Area 1)

Link ID         ADV Router      Age    Seq#       Checksum
203.250.13.41   203.250.15.67   602    0x80000002 0x90AA
203.250.15.64   203.250.15.67   620    0x800000E9 0x3E3C
203.250.15.192  203.250.15.67   638    0x800000E5 0xA54E

                Router Link States (Area 0)

Link ID         ADV Router      Age    Seq#       Checksum Link count
203.250.13.41   203.250.13.41   179    0x80000029 0x9ADA   3
203.250.15.67   203.250.15.67   675    0x800001E2 0xDD23   1

                Net Link States (Area 0)

Link ID         ADV Router      Age    Seq#       Checksum
203.250.15.68   203.250.13.41   334    0x80000001 0xB6B5

                Summary Net Link States (Area 0)

Link ID         ADV Router      Age    Seq#       Checksum
203.250.15.0    203.250.15.67   792    0x80000002 0xAEBD

                Summary ASB Link States (Area 0)

Link ID         ADV Router      Age    Seq#       Checksum
203.250.16.130  203.250.15.67   579    0x80000001 0xF9AF

                AS External Link States

Link ID         ADV Router      Age    Seq#       Checksum Tag
0.0.0.0         203.250.16.130  1787   0x80000001 0x98CE   10
203.250.16.128  203.250.16.130  5      0x80000002 0x93C4   0
 

This is a general look at the whole OSPF database. The database is listed according to the areas. In this case, we are looking at RTC's database which is an ABR. Both area 1 and area 0's databases are listed. Area 1 is composed of router links and summary links. No network links exist because no DR exists on any of the segments in area 1. No Summary ASBR links exist in area 1 because the only ASBR happens to be in area 0. External links do not belong to any particular area as they are flooded all over. Note that all the links are the cumulative links collected from all routers in an area.

We will mainly concentrate on the database in area 0. The Link-ID indicated here is actually the Link-State ID. This is a representation of the whole router, not a particular link. This is a bit confusing, but just remember that this high level Link-ID (should be Link-State ID) represents the whole router and not just a link.


19.2.2 Router Links

                 Router Link States (Area 0)

 Link ID         ADV Router      Age    Seq#       Checksum Link count
 203.250.13.41   203.250.13.41   179    0x80000029 0x9ADA   3
 203.250.15.67   203.250.15.67   675    0x800001E2 0xDD23   1

 

We will start with the router links. There are two entries listed for 203.250.13.41 and 203.250.15.67, these are the RIDs of the two routers in area 0. The number of links in area 0 for each router is also indicated. RTA has three links to area 0 and RTC has one link. A detailed view of RTC's router links follows:


RTC#sh ip ospf database router 203.250.15.67 

     OSPF Router with ID (203.250.15.67) (Process ID 10)

                Router Link States (Area 1)

  LS age: 1169
  Options: (No TOS-capability)
  LS Type: Router Links
  Link State ID: 203.250.15.67
  Advertising Router: 203.250.15.67
  LS Seq Number: 80000008
  Checksum: 0xB112
  Length: 48
  Area Border Router
   Number of Links: 2

    Link connected to: another Router (point-to-point)
     (Link ID) Neighboring Router ID: 203.250.16.130
     (Link Data) Router Interface address: 203.250.15.1
      Number of TOS metrics: 0
       TOS 0 Metrics: 64
 
    Link connected to: a Stub Network
     (Link ID) Network/subnet number: 203.250.15.0
     (Link Data) Network Mask: 255.255.255.192
      Number of TOS metrics: 0
       TOS 0 Metrics: 64
  

One thing to note here is that OSPF generates an extra stub link for each point-to-point interface. Do not get confused if you see the link count larger than the number of physical interfaces.

                 Router Link States (Area 0)

  LS age: 1227
  Options: (No TOS-capability)
  LS Type: Router Links
  Link State ID: 203.250.15.67
  Advertising Router: 203.250.15.67
  LS Seq Number: 80000003
  Checksum: 0xA041
  Length: 36
  Area Border Router
   Number of Links: 1

    Link connected to: a Transit Network
     (Link ID) Designated Router address: 203.250.15.68
     (Link Data) Router Interface address: 203.250.15.67
      Number of TOS metrics: 0
       TOS 0 Metrics: 10
 

Note that the Link ID is equal to the IP address (not the RID) of the attached DR; in this case it is 203.250.15.68. The Link Data is RTC's own IP address.


19.2.3 Network Links

                 Net Link States (Area 0)
  

 Link ID         ADV Router      Age    Seq#       Checksum
 203.250.15.68   203.250.13.41   334    0x80000001 0xB6B5

One network Link is listed, indicated by the interface IP address (not the RID) of the DR, in this case 203.250.15.68. A detailed view of this entry follows:


RTC#sh ip ospf database network

       OSPF Router with ID (203.250.15.67) (Process ID 10)

                Net Link States (Area 0)

  Routing Bit Set on this LSA
  LS age: 1549
  Options: (No TOS-capability)
  LS Type: Network Links
  Link State ID: 203.250.15.68 (address of Designated Router)
  Advertising Router: 203.250.13.41
  LS Seq Number: 80000002
  Checksum: 0xB4B6
  Length: 32
  Network Mask: 255.255.255.192

        Attached Router: 203.250.13.41
        Attached Router: 203.250.15.67

Note that the network link lists the RIDs of the routers attached to the transit network; in this case the RIDs of RTA and RTC are listed.


19.2.4 Summary Links


                  Summary Net Link States (Area 0)

Link ID         ADV Router      Age    Seq#       Checksum
203.250.15.0    203.250.15.67   792    0x80000002 0xAEBD
Area 0 has one summary link represented by the IP network address of the
link 203.250.15.0. This link was injected by the ABR RTC from area 1 into
area 0. A detailed view of this summary link follows, summary links for
area 1 are not listed here:

RTC#sh ip ospf database summary (area 1 is not listed)

              Summary Net Link States (Area 0)

  LS age: 615
  Options: (No TOS-capability)
  LS Type: Summary Links(Network)
  Link State ID: 203.250.15.0 (summary Network Number)
  Advertising Router: 203.250.15.67
  LS Seq Number: 80000003
  Checksum: 0xACBE
  Length: 28
  Network Mask: 255.255.255.192 TOS: 0  Metric: 64
 


19.2.5 Summary ASBR Links

                 Summary ASB Link States (Area 0)

 Link ID         ADV Router      Age    Seq#       Checksum
 203.250.16.130  203.250.15.67   579    0x80000001 0xF9AF

 

This is an indication of who the ASBR is. In this case the ASBR is RTE represented by its RID 203.250.16.130. The advertising router for this entry into area 0 is RTC with RID 203.250.15.67. A detailed view of the summary ASBR entry follows:


 RTC#sh ip ospf database asbr-summary

        OSPF Router with ID (203.250.15.67) (Process ID 10)

                 Summary ASB Link States (Area 0)

   LS age: 802
   Options: (No TOS-capability)
   LS Type: Summary Links(AS Boundary Router)
   Link State ID: 203.250.16.130 (AS Boundary Router address)
   Advertising Router: 203.250.15.67
   LS Seq Number: 80000003
   Checksum: 0xF5B1
   Length: 28
   Network Mask: 0.0.0.0 TOS: 0  Metric: 64
  


19.2.6 External Links

                 AS External Link States

 Link ID         ADV Router      Age    Seq#       Checksum Tag
 0.0.0.0         203.250.16.130  1787   0x80000001 0x98CE   10
 203.250.16.128  203.250.16.130  5      0x80000002 0x93C4   0
 

We have two external Links, the first one is the 0.0.0.0 injected into OSPF via t he default-information originate command. The other entry is network 203.250.16.12 8 which is injected into OSPF by redistribution. The router advertising these networks is 203.250.16.130, the RID of RTE. The foll owing is the detailed view of the external routes:


 RTC#sh ip o database external

        OSPF Router with ID (203.250.15.67) (Process ID 10)

                 AS External Link States

   Routing Bit Set on this LSA
   LS age: 208
   Options: (No TOS-capability)
   LS Type: AS External Link
   Link State ID: 0.0.0.0 (External Network Number )
   Advertising Router: 203.250.16.130
   LS Seq Number: 80000002
   Checksum: 0x96CF
   Length: 36
   Network Mask: 0.0.0.0
         Metric Type: 2 (Larger than any link state path)
         TOS: 0
         Metric: 10 
         Forward Address: 0.0.0.0
         External Route Tag: 10

  Routing Bit Set on this LSA
   LS age: 226
   Options: (No TOS-capability)
   LS Type: AS External Link
   Link State ID: 203.250.16.128 (External Network Number)
   Advertising Router: 203.250.16.130
   LS Seq Number: 80000002
   Checksum: 0x93C4
   Length: 36
   Network Mask: 255.255.255.192
         Metric Type: 2 (Larger than any link state path)
         TOS: 0
         Metric: 10
         Forward Address: 0.0.0.0
         External Route Tag: 0

 

Please note the forward address. Whenever this address is 0.0.0.0 it indicates th at the external routes are reachable via the advertising router, in this case 203. 250.16.130. This is why the identity of the ASBR is injected by ABRs into other ar eas using ASBR summary links.

This forward address is not always 0.0.0.0. In some cases, it could be the IP add ress of another router on the same segment. The following diagram will illustrate this situation:

spf28

In the above situation RTB, is running BGP with RTA, and OSPF with the rest of th e domain. RTA is not running OSPF. RTB is redistributing BGP routes into OSPF. Acc ording to OSPF, RTB is an ASBR advertising external routes. The forwarding address in this case is set to 125.211.1.1 and not to the advertising router (0.0.0.0) RT B. This makes sense because there is no need to make the extra hop. An important t hing to remember is that routers inside the OSPF domain should be able to reach th e forwarding address via OSPF in order for the external routes to be put in the IP routing table. If the forwarding address is reached via some other protocol or no t accessible, the external entries would be in the database but not in the IP rout ing table.

Another situation would arise if both RTB and RTC are ASBRs (RTC is also running BGP with RTA). In this situation, in order to eliminate the duplication of the eff ort, one of the two routers will not advertise (will flush) the external routes. T he router with the higher RID will win.


19.2.7 The Full Database

Finally, this is a listing of the whole database as an exercise. You should now b e able to go over each entry and explain what is going on:

 RTC#sh ip ospf database router

         OSPF Router with ID (203.250.15.67) (Process ID 10)

                 Router Link States (Area 1)

   LS age: 926
   Options: (No TOS-capability)
   LS Type: Router Links
   Link State ID: 203.250.15.67
   Advertising Router: 203.250.15.67
   LS Seq Number: 80000035
   Checksum: 0x573F
   Length: 48
   Area Border Router
    Number of Links: 2
 
Link connected to: another Router (point-to-point) (Link ID) Neighboring Router ID: 203.250.16.130 (Link Data) Router Interface address: 203.250.15.1 Number of TOS metrics: 0 TOS 0 Metrics: 64 Link connected to: a Stub Network (Link ID) Network/subnet number: 203.250.15.0 (Link Data) Network Mask: 255.255.255.192 Number of TOS metrics: 0 TOS 0 Metrics: 64 Routing Bit Set on this LSA LS age: 958 Options: (No TOS-capability) LS Type: Router Links Link State ID: 203.250.16.130 Advertising Router: 203.250.16.130 LS Seq Number: 80000038 Checksum: 0xDA76 Length: 48 AS Boundary Router Number of Links: 2 Link connected to: another Router (point-to-point) (Link ID) Neighboring Router ID: 203.250.15.67 (Link Data) Router Interface address: 203.250.15.2 Number of TOS metrics: 0 TOS 0 Metrics: 64 Link connected to: a Stub Network (Link ID) Network/subnet number: 203.250.15.0 (Link Data) Network Mask: 255.255.255.192 Number of TOS metrics: 0 TOS 0 Metrics: 64 Router Link States (Area 0) Routing Bit Set on this LSA LS age: 1107 Options: (No TOS-capability) LS Type: Router Links Link State ID: 203.250.13.41 Advertising Router: 203.250.13.41 LS Seq Number: 8000002A Checksum: 0xC0B0 Length: 60 AS Boundary Router Number of Links: 3 Link connected to: a Stub Network (Link ID) Network/subnet number: 203.250.13.41 (Link Data) Network Mask: 255.255.255.255 Number of TOS metrics: 0 TOS 0 Metrics: 1 Link connected to: a Stub Network (Link ID) Network/subnet number: 203.250.15.192 (Link Data) Network Mask: 255.255.255.192 Number of TOS metrics: 0 TOS 0 Metrics: 10 Link connected to: a Transit Network (Link ID) Designated Router address: 203.250.15.68 (Link Data) Router Interface address: 203.250.15.68 Number of TOS metrics: 0 TOS 0 Metrics: 10 LS age: 1575 Options: (No TOS-capability) LS Type: Router Links Link State ID: 203.250.15.67 Advertising Router: 203.250.15.67 LS Seq Number: 80000028 Checksum: 0x5666 Length: 36 Area Border Router Number of Links: 1 Link connected to: a Transit Network (Link ID) Designated Router address: 203.250.15.68 (Link Data) Router Interface address: 203.250.15.67 Number of TOS metrics: 0 TOS 0 Metrics: 10 RTC#sh ip ospf database network OSPF Router with ID (203.250.15.67) (Process ID 10) Net Link States (Area 0) Routing Bit Set on this LSA LS age: 1725 Options: (No TOS-capability) LS Type: Network Links Link State ID: 203.250.15.68 (address of Designated Router) Advertising Router: 203.250.13.41 LS Seq Number: 80000026 Checksum: 0x6CDA Length: 32 Network Mask: 255.255.255.192 Attached Router: 203.250.13.41 Attached Router: 203.250.15.67 RTC#sh ip ospf database summary OSPF Router with ID (203.250.15.67) (Process ID 10) Summary Net Link States (Area 1) LS age: 8 Options: (No TOS-capability) LS Type: Summary Links(Network) Link State ID: 203.250.13.41 (summary Network Number) Advertising Router: 203.250.15.67 LS Seq Number: 80000029 Checksum: 0x42D1 Length: 28 Network Mask: 255.255.255.255 TOS: 0 Metric: 11 LS age: 26 Options: (No TOS-capability) LS Type: Summary Links(Network) Link State ID: 203.250.15.64 (summary Network Number) Advertising Router: 203.250.15.67 LS Seq Number: 80000030 Checksum: 0xB182 Length: 28 Network Mask: 255.255.255.192 TOS: 0 Metric: 10 LS age: 47 Options: (No TOS-capability) LS Type: Summary Links(Network) Link State ID: 203.250.15.192 (summary Network Number) Advertising Router: 203.250.15.67 LS Seq Number: 80000029 Checksum: 0x1F91 Length: 28 Network Mask: 255.255.255.192 TOS: 0 Metric: 20 Summary Net Link States (Area 0) LS age: 66 Options: (No TOS-capability) LS Type: Summary Links(Network) Link State ID: 203.250.15.0 (summary Network Number) Advertising Router: 203.250.15.67 LS Seq Number: 80000025 Checksum: 0x68E0 Length: 28 Network Mask: 255.255.255.192 TOS: 0 Metric: 64 RTC#sh ip ospf asbr-summary OSPF Router with ID (203.250.15.67) (Process ID 10) Summary ASB Link States (Area 0) LS age: 576 Options: (No TOS-capability) LS Type: Summary Links(AS Boundary Router) Link State ID: 203.250.16.130 (AS Boundary Router address) Advertising Router: 203.250.15.67 LS Seq Number: 80000024 Checksum: 0xB3D2 Length: 28 Network Mask: 0.0.0.0 TOS: 0 Metric: 64 RTC#sh ip ospf database external OSPF Router with ID (203.250.15.67) (Process ID 10) AS External Link States Routing Bit Set on this LSA LS age: 305 Options: (No TOS-capability) LS Type: AS External Link Link State ID: 0.0.0.0 (External Network Number) Advertising Router: 203.250.16.130 LS Seq Number: 80000001 Checksum: 0x98CE Length: 36 Network Mask: 0.0.0.0 Metric Type: 2 (Larger than any link state path) TOS: 0 Metric: 10 Forward Address: 0.0.0.0 External Route Tag: 10 Routing Bit Set on this LSA LS age: 653 Options: (No TOS-capability) LS Type: AS External Link Link State ID: 203.250.16.128 (External Network Number) Advertising Router: 203.250.16.130 LS Seq Number: 80000024 Checksum: 0x4FE6 Length: 36 Network Mask: 255.255.255.192 Metric Type: 2 (Larger than any link state path) TOS: 0 Metric: 10 Forward Address: 0.0.0.0 External Route Tag: 0

20.0 APPENDIX B: OSPF and IP Multicast Addressing

OSPF used IP multicast to exchange Hello packets and Link State Updates. An IP mu lticast address is implemented using class D addresses. A class D address ranges from 224.0.0.0 to 239.255.255.255.

spf29



Some special IP multicast addresses are reserved for OSPF:

224.0.0.5: All OSPF routers should be able to transmit and listen to this address .

224.0.0.6: All DR and BDR routers should be able to transmit and listen to this a ddress.

The mapping between IP multicast addresses and MAC addresses has the following ru le:

For multiaccess networks that support multicast, the low order 23 bits of the IP address are used as the low order bits of the MAC multicast address 01-005E-00-00- 00.

Example:

 224.0.0.5 would be mapped to 01-00-5E-00-00-05 and

 224.0.0.6 would be mapped to 01-00-5E-00-00-06.
 

OSPF uses broadcast on Token Ring networks.


21.0 APPENDIX C: Variable Length Subnet Masks (VLSM)

Binary/Decimal Conversion Chart
  0000   0001   0010   0011   0100   0101   0110   0111
0 0000 16 0000 32 0000 48 0000 64 0000 80 000 0 96 0000 112 0000
1 0001 17 0001 33 0001 49 0001 65 0001 81 000 1 97 0001 113 0001
2 0010 18 0010 34 0010 50 0010 66 0010 82 001 0 98 0010 114 0010
3 0011 19 0011 35 0011 51 0011 67 0011 83 001 1 99 0011 115 0011
4 0100 20 0100 36 0100 52 0100 68 0100 84 010 0 100 0100 116 0100
5 0101 21 0101 37 0101 53 0101 69 0101 85 010 1 101 0101 117 0101
6 0110 22 0110 38 0110 54 0110 70 0110 86 011 0 102 0110 118 0110
7 0111 23 0111 39 0111 55 0111 71 0111 87 011 1 103 0111 119 0111
8 1000 24 1000 40 1000 56 1000 72 1000 88 100 0 104 1000 120 1000
9 1001 25 1001 41 1001 57 1001 73 1001 89 100 1 105 1001 121 1001
10 1010 26 1010 42 1010 58 1010 74 1010 90 10 10 106 1010 122 1010
11 1011 27 1011 43 1011 59 1011 75 1011 91 10 11 107 1011 123 1011
12 1100 28 1100 44 1100 60 1100 76 1100 92 11 00 108 1100 124 1100
13 1101 29 1101 45 1101 61 1101 77 1101 93 11 01 109 1101 125 1101
14 1110 30 1110 46 1110 62 1110 78 1110 94 11 10 110 1110 126 1110
15 1111 31 1111 47 1111 63 1111 79 1111 95 11 11 111 1111 127 1111
  1000   1001   1010   1011   1100   1101   1110   1111
128 0000 144 0000 160 0000 176 0000 192 0000 208 0000 224 0000 240 0000
129 0001 145 0001 161 0001 177 0001 193 0001 209 0001 225 0001 241 0001
130 0010 146 0010 162 0010 178 0010 194 0010 210 0010 226 0010 242 0010
131 0011 147 0011 163 0011 179 0011 195 0011 211 0011 227 0011 243 0011
132 0100 148 0100 164 0100 180 0100 196 0100 212 0100 228 0100 244 0100
133 0101 149 0101 165 0101 181 0101 197 0101 213 0101 229 0101 245 0101
134 0110 150 0110 166 0110 182 0110 198 0110 214 0110 230 0110 246 0110
135 0111 151 0111 167 0111 183 0111 199 0111 215 0111 231 0111 247 0111
136 1000 152 1000 168 1000 184 1000 200 1000 216 1000 232 1000 248 1000
137 1001 153 1001 169 1001 185 1001 201 1001 217 1001 233 1001 249 1001
138 1010 154 1010 170 1010 186 1010 202 1010 218 1010 234 1010 250 1010
139 1011 155 1011 171 1011 187 1011 203 1011 219 1011 235 1011 251 1011
140 1100 156 1100 172 1100 188 1100 204 1100 220 1100 236 1100 252 1100
141 1101 157 1101 173 1101 189 1101 205 1101 221 1101 237 1101 253 1101
142 1110 158 1110 174 1110 190 1110 206 1110 222 1110 238 1110 254 1110
143 1111 159 1111 175 1111 191 1111 207 1111 223 1111 239 1111 255 1111

The idea behind variable length subnet masks is to offer more flexibility in deal ing with dividing a major net into multiple subnets and still being able to mainta in an adequate number of hosts in each subnet. Without VLSM one subnet mask only c an be applied to a major network. This would restrict the number of hosts given th e number of subnets required. If we pick the mask such that we have enough subnets , we wouldn't be able to allocate enough hosts in each subnet. The same is true fo r the hosts; a mask that allows enough hosts might not provide enough subnet space .

For example, suppose you were assigned a class C network 192.214.11.0 and you nee d to divide that network into three subnets with 100 hosts in one subnet and 50 ho sts for each of the remaining subnets. Ignoring the two end limits 0 and 255, you have theoretically available to you 256 addresses (192.214.11.0 - 192.214.11.255). This can not be done without VLSM.

spf30

There are a handful of subnet masks that can be used; remember that a mask should have a contiguous number of ones starting from the left and the rest of the bits being all 0s.

 -252 (1111 1100) The address space is divided into 64.
 -248 (1111 1000) The address space is divided into 32.
 -240 (1111 0000) The address space is divided into 16.
 -224 (1110 0000) The address space is divided into 8.
 -192 (1100 0000) The address space is divided into 4.
 -128 (1000 0000) The address space is divided into 2.
 

Without VLSM we have the choice of using mask 255.255.255.128 and dividing the ad dresses into 2 subnets with 128 hosts each or using 255.255.255.192 and dividing t he space into 4 subnets with 64 hosts each. This would not meet the requirement. B y using multiple masks we can use mask 128 and further subnet the second chunk of addresses with mask 192. The following table shows how we have divided the address space accordingly.

spf31

Now, be careful in allocating the IP addresses to each mask. Once you assign an I P address to the router or to a host you have used up the whole subnet for that se gment. For example, if you assign 192.214.11.10 255.255.255.128 to E2, the whole r ange of addresses between 192.214.11.0 and 192.214.11.127 is consumed by E2. In th e same way if you assign 192.214.11.160 255.255.255.128 to E2, the whole range of addresses between 192.214.11.128 and 192.214.11.255 is consumed by the E2 segment.

The following is an illustration of how the router will interpret these addresses . Please remember that any time you are using a mask different than the natural ma sk, for instance you are subnetting, the router will complain if the combination I P address and mask will result in a subnet zero. To resolve this issue use the com mand ip subnet-zero on the router.

 RTA#
 ip subnet-zero
 interface Ethernet2
  ip address 192.214.11.10 255.255.255.128
 interface Ethernet3
  ip address 192.214.11.160 255.255.255.192
 interface Ethernet4
  ip address 192.214.11.226 255.255.255.192

 RTA# sh ip route connected
      192.214.11.0 is variably subnetted, 3 subnets, 2 masks
 C       192.214.11.0 255.255.255.128 is directly connected, Ethernet2
 C       192.214.11.128 255.255.255.192 is directly connected, Ethernet3
 C       192.214.11.192 255.255.255.192 is directly connected, Ethernet4
 



Section 1  Section 2  Section 3  Section 4  Section 5