Passion/Network

OSPF LSA분석

sunshout 2007. 8. 17. 13:30
LSA Header 구조
- 20 bytes
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1       
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     LS age                   |  Options       |  LS type      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Link State ID                                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Advertising Router                                 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            LS sequence number                                 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     LS checksum              |           length               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


zebra code (Language : c)
  1. /* OSPF LSA header. */
  2. struct lsa_header
  3. {
  4.   u_int16_t ls_age;
  5.   u_char options;
  6.   u_char type;
  7.   struct in_addr id;
  8.   struct in_addr adv_router;
  9.   int ls_seqnum;
  10.   u_int16_t checksum;
  11.   u_int16_t length;
  12. };
  13.  

* LS age : LSA가 생성된 시간(초)
* option :
* LS type : 1(Router-LSAs), 2(Network-LSAs), 3(Summary-LSAs , IP network), 4(Summary-LSAs , ASBR), 5(AS-external-LSAs)


A.4.2 Router-LSAs

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1       
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     LS age                   |  Options       |  LS type      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Link State ID                                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Advertising Router                                 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            LS sequence number                                 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     LS checksum              |           length               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  0      |V|E|B|    0         |       # links                  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                 Link ID                                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-+
|                 Link Data                                     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    Type       |  # TOS       |            metric              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    ...........                                |            
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   TOS         |     0        |         TOS metric             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                   Link ID                                     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                   Link Data                                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        ..........                             |

* bit V : virtual link endpoint
* bit E : AS boundary router (E is for external)
* bit B : area boundary router ( B is for border)

# links : number of router links


zebra code (Language : c)
  1. /* OSPF Router-LSAs structure. */
  2. struct router_lsa
  3. {
  4.   struct lsa_header header;
  5.   u_char flags;
  6.   u_char zero;
  7.   u_int16_t links;
  8.   struct
  9.   {
  10.     struct in_addr link_id;
  11.     struct in_addr link_data;
  12.     u_char type;
  13.     u_char tos;
  14.     u_int16_t metric;
  15.   } link[1];
  16. };
  17.  

위 zebra 코드를 보면 Protocol 포멧에 정의하고 있는 ... 이후 부분이 사용하지 않고 있음을 알 수 있다.


A.4.3 Network-LSAs

Network-LSA는 broadcast, NBMA 네트워크에서 DR이 생성하는 메시지 이다.
모든 네트워크까지의 거리가 0이기 때문에 distance field가 존재하지 않는다.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1       
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     LS age                   |  Options       |  LS type      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Link State ID                                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Advertising Router                                 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            LS sequence number                                 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     LS checksum              |           length               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                 Network Mask                                  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-+
|                 Attached Router                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     .................                                                        |

* Attached Router 는 DR에 붙어있는 라우터의 Router ID 값을 넣는다.
 

zebra code (Language : c)
  1. /* OSPF Network-LSAs structure. */
  2. struct network_lsa
  3. {
  4.   struct lsa_header header;
  5.   struct in_addr mask;
  6.   struct in_addr routers[1];
  7. };
  8.