frame relay 抓包分析

# frame relay (幀中繼)
# 經常使用拓撲結構 hub-spoke 和 full mesh
# 通道vc(virtual circuit) 將劃分一根物理線路劃分爲多個邏輯線路,大大下降成本
# 數據鏈路連接標識 DLCI(data link connection identifier)用於標識不一樣的通道,
# 能夠理解爲二層編址方法,給對端使用,本地有效

# DLCI最多可支持1024條虛電路 10 bit (0-1023)
# 0 - 15  保留
# 16 - 1007 可用
# 1008- 1023 保留

9 35.550726   Inverse ARP 34 Who is 1861? Tell 0000      #   計算DLCI號 102 對應 1861              

Frame 9: 34 bytes on wire (272 bits), 34 bytes captured (272 bits) on interface 0
Frame Relay
    First address octet: 0x18
        0001 10.. = Upper DLCI: 0x06              # DLCI 前6 bit爲 0001 10,對應 0x18
        .... ..0. = CR: Response
        .... ...0 = EA: More Follows
    Second address octet: 0x61, EA                # DLCI 後4 bit爲 0110 , 對應 0x61,DLCI十六進制爲 0x1861
        0110 .... = Second DLCI: 0x6
        .... 0... = FECN: False
        .... .0.. = BECN: False
        .... ..0. = DE: False
        .... ...1 = EA: Last Octet
    DLCI: 102                                     # DLCI 號共10bit爲 0001 100110, 對應十進制爲 102
    Control field: U, func=UI (0x03)
    Padding
    NLPID: SNAP (0x80)
    Organization Code: Encapsulated Ethernet (0x000000)
    Type: ARP (0x0806)
Address Resolution Protocol (inverse request)
# frame relay幀結構
# 開始Flag:指示幀的開始,也叫作幀中繼的第一地址,使用一個八位組表示。
# LMI DLCI:指示幀中繼的LMI信令所使用的DLCI號碼,須要注意的是,LMI的DLCI號碼並不是虛擬電路(VC)所使用的DLCI號碼,
# LMI DLCI 與信令的類型有關,若是LMI的信令型類採用cisco的LMI類型,那麼DLCI號就是1023;若是採用ANSI或ITU(q33a)類型的LMI,那麼DLCI號就是0。
# C/R:(Command/Response)命令響應,該字段一般不用。
# EA:擴展地址用來指示包含EA字段的是不是最後一個幀標記,若是該字段的值爲1則表示這是最後一個結束幀標記,
#    由於幀中繼有兩個幀標記,一個開始Flag,一個結束Flag 。它會出如今兩個地方,開始Flag和結束Flag中,
#    因此當EA標記出如今圖9中的開始標記部分其值爲0;而在結束標記部分其值爲1。
# FECN:前向顯式擁塞通知,該字段使用在幀中繼網絡發生擁塞的時候,
#    幀中繼交換機(DCE設備)會將該字段設置爲1併發送給幀中繼的目標接入設備(DTE),指示網絡擁塞## ,收到FECN的設備會實施適當的流量控制措施。
# BECN:後向顯式擁塞通知,該字段使用在幀中繼網絡發生擁塞的時候,
#    幀中繼交換機(DCE設備)會將該字段設置爲1併發送給幀中繼的源接入設備(DTE),指示網絡擁塞,收到BECN的設備會下降25%左右的發送速率。
# DE:可丟棄標記,若是該字段被設置爲1的幀中繼數據報文在遇到網絡擁塞時會被丟棄。
#    須要注意的是該標記通常由幀中繼的接入設備(DTE)設置,而且被設置了DE標誌的數據不是當即被丟棄,只會在網絡擁塞時會被優先丟棄。
# Data:指示在幀中繼中被封裝的上層數據。
# 結束Flag:指示幀的結束,也叫作幀中繼的第二地址,使用一個八位組表示。
# FCS:用於檢測傳輸錯誤。

# 
Frame 689: 13 bytes on wire (104 bits), 13 bytes captured (104 bits) on interface 0
Frame Relay
    First address octet: 0x00
        0000 00.. = Upper DLCI: 0x00
        .... ..0. = CR: Response
        .... ...0 = EA: More Follows
    Second address octet: 0x01, EA
        0000 .... = Second DLCI: 0x0
        .... 0... = FECN: False
        .... .0.. = BECN: False
        .... ..0. = DE: False
        .... ...1 = EA: Last Octet
    DLCI: 0
    Control field: U, func=UI (0x03)
        000. 00.. = Command: Unnumbered Information (0x00)
        .... ..11 = Frame type: Unnumbered frame (0x3)

        
# LMI幀結構:
# 標誌:包括幀中繼的起始標誌與結束標誌,用於標記數據幀的開始與結束。
# 未編號信息標誌(UII):未編號信息標誌用於將輪詢最後位設置爲0。
# 協議標識符(NLPID):協議標識符字段說明該數據幀是一個幀中繼LMI的數據幀。
# 呼叫參考(call Ref):呼叫參考暫時不使用,其值通常爲0。
# 消息類型(messagetype):該字段有兩種可能,一個是指示狀態查詢(enquiry),另外一個是狀態響應(Stauts)。
# 消息元素(informationElement):包括數量指定的獨立信息元素,如IE標識符和IE長度。
# FCS :數據幀校驗序列,用於數據的驗證,保證數據傳輸的完整性。
# 使用LMI維護幀中繼的信令分爲狀態查詢(enquiry)和狀態響應(Stauts),以每10秒爲一個間隔週期完成,幀中繼交換機間隔60秒發送 Status進行響應

# lmi-type支持的三種類型 cisco ansi q933a
R1(config-if)#frame-relay lmi-type ?                                              
  cisco  
  ansi   
  q933a 
  
# 以ANSI類型爲例
Frame 698: 14 bytes on wire (112 bits), 14 bytes captured (112 bits) on interface 0
Frame Relay
Q.933
    Protocol discriminator: Q.933
    Call reference value length: 0
    Message type: STATUS ENQUIRY (0x75)
    .... .101 = Locking shift to codeset: Information elements for national use (5)
    Report type (ANSI)
        Information element: Report type (ANSI)
        Length: 1
        Report type: Full Status (0)
    Keep Alive (ANSI)
        Information element: Keep Alive (ANSI)
        Length: 2
        TX Sequence: 1
        RX Sequence: 0
# frame relay 動態協商過程(獲取DLCI號的過程)分析

# R1接口配置
R1(config-if)#do sh run int s3/1
Building configuration...
Current configuration : 121 bytes
!
interface Serial3/1
 ip address 202.100.123.1 255.255.255.0
 encapsulation frame-relay        # 二層封裝類型爲,frame-relay
 frame-relay lmi-type ansi        # lmi-type封裝類型,默認爲ansi
end

R1(config-if)#do sh int s3/1 
Serial3/1 is up, line protocol is up 
  Hardware is M4T
  Internet address is 202.100.123.1/24
  MTU 1500 bytes, BW 1544 Kbit/sec, DLY 20000 usec, 
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation FRAME-RELAY, crc 16, loopback not set                             # 接口封裝類型 Encapsulation FRAME-RELAY
  Keepalive set (10 sec)
  LMI enq sent  462, LMI stat recvd 424, LMI upd recvd 0, DTE LMI up
  LMI enq recvd 0, LMI stat sent  0, LMI upd sent  0
  LMI DLCI 0  LMI type is ANSI Annex D  frame relay DTE  segmentation inactive    # 接口lmi-type類型 LMI type is ANSI
  FR SVC disabled, LAPF state down
  Broadcast queue 0/64, broadcasts sent/dropped 23/0, interface broadcasts 0
  Last input 00:00:02, output 00:00:02, output hang never
  Last clearing of "show interface" counters 01:17:03
  
# 當端口配置爲frame-relay模式後,端口向幀中繼交換機主動發送三種不一樣lmi二層 status enquiry 數據包,進行協商
# 若是協商成功,幀中繼交換機會響應 STATUS
# 若是協商不成功,幀中繼交換機不會響應,端口進入協議down

# lmi協商成功後,響應STATUS
262 1393.007120   Q.933 14 STATUS ENQUIRY        # ansi STATUS ENQUIRY
263 1393.007292   Q.933 13 STATUS ENQUIRY        # q933a STATUS ENQUIRY
264 1393.007323   LMI 13 Status Enquiry          # cisco Status Enquiry
265 1393.007605   Q.933 19 STATUS                # 幀中繼響應類型爲 ansi

# 發送端發送 ANSI類型 STATUS ENQUIRY 
Frame 262: 14 bytes on wire (112 bits), 14 bytes captured (112 bits) on interface 0
Frame Relay
    First address octet: 0x00
    Second address octet: 0x01, EA
    DLCI: 0                        # 採用ANSI或ITU(q33a)類型的LMI,那麼LMI DLCI號就是0
    Control field: U, func=UI (0x03)
Q.933
    Protocol discriminator: Q.933
    Call reference value length: 0
    Message type: STATUS ENQUIRY (0x75)
    .... .101 = Locking shift to codeset: Information elements for national use (5)
    Report type (ANSI)            # lmi 類型爲 ANSI
        Information element: Report type (ANSI)
        Length: 1
        Report type: Full Status (0)
    Keep Alive (ANSI)
        Information element: Keep Alive (ANSI)
        Length: 2
        TX Sequence: 1            # ANSI 第一次發送的數據包
        RX Sequence: 0

# 發送端發送q933a類型 STATUS ENQUIRY 
Frame 263: 13 bytes on wire (104 bits), 13 bytes captured (104 bits) on interface 0
Frame Relay
    First address octet: 0x00
    Second address octet: 0x01, EA
    DLCI: 0                # 採用ANSI或ITU(q33a)類型的LMI,那麼LMI DLCI號就是0
    Control field: U, func=UI (0x03)
Q.933            
    Protocol discriminator: Q.933
    Call reference value length: 0
    Message type: STATUS ENQUIRY (0x75)
    Report type
        Information element: Report type
        Length: 1
        Report type: Full Status (0)
    Link integrity verification
        Information element: Link integrity verification
        Length: 2
        Data: 0100

# 發送端發送 cisco 類型 Status Enquiry    
Frame 264: 13 bytes on wire (104 bits), 13 bytes captured (104 bits) on interface 0
Frame Relay
    First address octet: 0xfc
    Second address octet: 0xf1, EA
    DLCI: 1023            # 採用cisco的LMI類型,那麼LMI DLCI號就是1023
    Control field: U, func=UI (0x03)
    NLPID: LMI (0x09)
Local Management Interface
    Call reference: 0x00
    Message Type: Status Enquiry (0x75)
    Information Element: Report
        Type: Report (1)
        Length: 1
        Record Type: Full Status (0)
    Information Element: Keep Alive
        Type: Keep Alive (3)
        Length: 2
        Send Seq: 1        # cisco 第一次發送的數據包
        Recv Seq: 0

# 幀中繼交換機響應 ANSI STATUS,指定鏈接的 VC類型和DLCI號,並存在Keep-alive機制
Frame 265: 19 bytes on wire (152 bits), 19 bytes captured (152 bits) on interface 0
Frame Relay
    First address octet: 0x00
    Second address octet: 0x01, EA
    DLCI: 0
    Control field: U, func=UI (0x03)
Q.933
    Protocol discriminator: Q.933
    Call reference value length: 0
    Message type: STATUS (0x7d)
    .... .101 = Locking shift to codeset: Information elements for national use (5)
    Report type (ANSI)        
        Information element: Report type (ANSI)
        Length: 1
        Report type: Full Status (0)
    Keep Alive (ANSI)        # ANSI的 keep alive機制
        Information element: Keep Alive (ANSI)
        Length: 2
        TX Sequence: 1
        RX Sequence: 1
    PVC Status (ANSI)        # 幀中繼交換機響應VC類型爲 PVC ,分配鏈路DLCI號爲 301
        Information element: PVC Status (ANSI)
        Length: 3
        DLCI: 301            # DLCI號爲 301
        .... 0.1. = Status: Unknown (1)
        
# lmi協商不成功,則幀中繼交換機不會響應,端口進入協議down
R3(config-if)#fram lmi-type cisco
*Aug 27 13:39:29.557: %LINK-5-CHANGED: Interface Serial3/3, changed state to administratively down
# frame relay爲NBMA技術(none broadcast multiple access 非廣播多路接入)
# 不支持廣播和組播,不使用三層技術能夠創建多個鏈接
# inverse ARP用於 IP 查找 DLCI 號,經過三層ip地址 轉換爲二層DLCI 動態映射,
# 幀中繼的逆向ARP解析與局域網環境中的ARP地址解析協議很是類似,局域網中的ARP解析是知道目標IP地址後,去解析目標的MAC地址;
# 而幀中繼的ARP逆向解析是路由器將已知的二層地址(本地的DLCI號碼)去映射遠程端設備的三層IP地址。

# Inverse ARP是對原有ARP協議的擴展,
# request幀結構
# hrd - 0x000F the value assigned to Frame Relay
# pro - protocol type for which you are searching
#          (i.e.  IP = 0x0800)
# hln - 2,3, or 4 byte addressing length
# pln - byte length of protocol address for which you
#          are searching (for IP = 4)
# op  - 8; InARP request
# sha - Q.922 [6] address of requesting station
# spa - protocol address of requesting station
# tha - Q.922 address of newly announced virtual circuit
# tpa - 0; This is what is being requested

# response幀結構
# hrd - 0x000F the value assigned to Frame Relay
# pro - protocol type for which you are searching
#         (i.e.  IP = 0x0800)
# hln - 2,3, or 4 byte addressing length
# pln - byte length of protocol address for which you
#         are searching (for IP = 4)
# op  - 9; InARP response
# sha - Q.922 address of responding station
# spa - protocol address requested
# tha - Q.922 address of requesting station
# tpa - protocol address of requesting station


# lmi協商成功後,每隔60秒發送InARP請求獲取;並將目的ip地址用 0.0.0.0 填充
Frame 1005: 34 bytes on wire (272 bits), 34 bytes captured (272 bits) on interface 0
Frame Relay
    First address octet: 0x48
        0100 10.. = Upper DLCI: 0x12
        .... ..0. = CR: Response
        .... ...0 = EA: More Follows
    Second address octet: 0xd1, EA
        1101 .... = Second DLCI: 0xd
        .... 0... = FECN: False
        .... .0.. = BECN: False
        .... ..0. = DE: False
        .... ...1 = EA: Last Octet
    DLCI: 301               # 發送者的DLCI爲 301                 
    Control field: U, func=UI (0x03)
        000. 00.. = Command: Unnumbered Information (0x00)
        .... ..11 = Frame type: Unnumbered frame (0x3)
    Padding
    NLPID: SNAP (0x80)
    Organization Code: Encapsulated Ethernet (0x000000)
    Type: ARP (0x0806)
Address Resolution Protocol (inverse request)
    Hardware type: Frame Relay DLCI (15)
    Protocol type: IPv4 (0x0800)
    Hardware size: 2
    Protocol size: 4
    Opcode: inverse request (8)
    Sender hardware address: 0000
    Sender IP address: 202.100.123.1    # 發送者的IP爲 202.100.123.1
    Target hardware address: 1871       # 請求響應設備的DLCI號 103對應0X1871,00011000(前6bit) 01110001(前4bit)即二進制 0001100111對應DLCI 103
    Target IP address: 0.0.0.0          # 請求DLCI號 103設備的IP地址,用0.0.0.0表示 
    
    
# inverse ARP協商過程 
# InARP與ARP運行機制基本相同,最大的區別在於InARP不須要廣播request,由於目的hardware address(DLCI)已知

# 發送端R1 依據目的DLCI號 發送InARP request,包括髮送端的 DLCI 和 IP
Frame 53: 34 bytes on wire (272 bits), 34 bytes captured (272 bits) on interface 0
Frame Relay
    First address octet: 0x18
    Second address octet: 0x71, EA
    DLCI: 103
    Control field: U, func=UI (0x03)
    Padding
    NLPID: SNAP (0x80)
    Organization Code: Encapsulated Ethernet (0x000000)
    Type: ARP (0x0806)
Address Resolution Protocol (inverse request)
    Hardware type: Frame Relay DLCI (15)
    Protocol type: IPv4 (0x0800)
    Hardware size: 2
    Protocol size: 4
    Opcode: inverse request (8)
    Sender hardware address: 0000
    Sender IP address: 202.100.123.3
    Target hardware address: 48d1     
    Target IP address: 0.0.0.0
    
# 接收端R3 接收到InARP request後,生成發送端的map表項
Frame 57: 34 bytes on wire (272 bits), 34 bytes captured (272 bits) on interface 0
Frame Relay
    First address octet: 0x48
    Second address octet: 0xd1, EA
    DLCI: 301
    Control field: U, func=UI (0x03)
    Padding
    NLPID: SNAP (0x80)
    Organization Code: Encapsulated Ethernet (0x000000)
    Type: ARP (0x0806)
Address Resolution Protocol (inverse request)
    Hardware type: Frame Relay DLCI (15)
    Protocol type: IPv4 (0x0800)
    Hardware size: 2
    Protocol size: 4
    Opcode: inverse request (8)
    Sender hardware address: 0000
    Sender IP address: 202.100.123.3
    Target hardware address: 48d1
    Target IP address: 0.0.0.0
        
# 接收端R3 依據目的ip地址 發送InARP reply,並將R1的ip地址封裝
Frame 58: 34 bytes on wire (272 bits), 34 bytes captured (272 bits) on interface 0
Frame Relay
    First address octet: 0x48
    Second address octet: 0xd1, EA
    DLCI: 301
    Control field: U, func=UI (0x03)
    Padding
    NLPID: SNAP (0x80)
    Organization Code: Encapsulated Ethernet (0x000000)
    Type: ARP (0x0806)
Address Resolution Protocol (inverse reply)
    Hardware type: Frame Relay DLCI (15)
    Protocol type: IPv4 (0x0800)
    Hardware size: 2
    Protocol size: 4
    Opcode: inverse reply (9)
    Sender hardware address: 0000
    Sender IP address: 202.100.123.1
    Target hardware address: 48d1
    Target IP address: 202.100.123.3

# 發送端R1 接收InARP reply後生成map表項
Frame 54: 34 bytes on wire (272 bits), 34 bytes captured (272 bits) on interface 0
Frame Relay
    First address octet: 0x18
    Second address octet: 0x71, EA
    DLCI: 103
    Control field: U, func=UI (0x03)
    Padding
    NLPID: SNAP (0x80)
    Organization Code: Encapsulated Ethernet (0x000000)
    Type: ARP (0x0806)
Address Resolution Protocol (inverse reply)
    Hardware type: Frame Relay DLCI (15)
    Protocol type: IPv4 (0x0800)
    Hardware size: 2
    Protocol size: 4
    Opcode: inverse reply (9)
    Sender hardware address: 0000
    Sender IP address: 202.100.123.1
    Target hardware address: 48d1
    Target IP address: 202.100.123.3
相關文章
相關標籤/搜索