802.11幀格式


 

1.MAC幀格式

 

1.1 地址格式  

    addr1:接收地址(所有包都包含它)
    addr2:傳輸地址(除ACK和CTS包外的其他包都包含它)
    addr3:只用於管理包和數據包。
    addr4:無線分布系統模式下,FROM DS和TO DS都被置位時使用。
    下圖中,占兩個字節的Frame control ,其To DS和From Ds決定了這四個地址的使用。
   ;
    地址對應表如下:
    DS是分布式系統的簡稱,我們用它以區分不同類型幀中關於地址的解析方式。
        To DS=0,From DS=0:表示Station之間的AD Hoc類似的通信,或者控制偵、管理偵。
        To DS=0,From DS=1:Station接收的偵。
        To DS=1,From DS = 0:Station發送的偵。
        To DS=1,From DS = 1:無線橋接器上的數據偵。
     各地址的解釋:
        SRC:源地址(SA),和以太網中的一樣,就是發幀的最初地址,在以太網和wifi中幀格式轉換的時候,互相可以直接復制。
        DST:目的地址(DA),和以太網中的一樣,就是最終接受數據幀的地址,在以太網和wifi中幀格式轉換的時候,互相可以直接復制。
        TX:也就是Transmiter(TA),表示無線網絡中目前實際發送幀者的地址(可能是最初發幀的人,也可能是轉發時候的路由)。
        RX:也就是Receiver(RA),表示無線網絡中,目前實際接收幀者的地址(可能是最終的接收者,也可能是接收幀以便轉發給接收者的ap)。
    注:無線網絡中的 Station想要通信,必須經過AP來進行“轉發”。其實,Tx和Rx是無線網絡中的發和收,也就是Radio;而Src和Dst是真正的發送源和接收者

2 幀類型

    幀類型由frame control的type兩位決定,目前有三種類型的幀:
    00,管理幀。IEEE80211_TYPE_MGMT 用於執行管理操作,如關聯、身份驗證,掃描等。
    01,控制幀。IEEE80211_TYPE_CTL 通常與數據包相關。如:PS-poll包用於從AP緩沖區取回數據包;另一個例子,STA若想數據傳輸,首先會發送RTS的控制數據包,如果介質空閑,目標客戶端將發回一個名為允許發送(CTS)的控制數據包。
    10,數據幀。IEEE80211_TYPE_DATA 原始數據包。注:空數據包是特殊的數據幀,其用於電源管理。
    11,保留。

2.1 SubType

2.1.1 管理幀 type 00

    下表為管理幀的subType對應的類型(即type為00時,subType的取值)
    
Type   FrameType
00 0000 Association request (連接請求)
00 0001 Association response (連接響應)
00 0010 Reassociation request(重連接請求)
00 0011 Reassociation response(重連接聯響應)
00 0100 Probe request(探測請求)
00 0101 Probe response(探測響應)
00 1000 Beacon(信標,被動掃描時AP 發出,notify)
00 1001 ATIM(通知傳輸指示消息)
00 1010 Disassociation(解除連接,notify)
00 1011 Authentication(身份驗證)
00 1100 Deauthentication(解除認證,notify)
00 1101~1111 Reserved(保留,未使用)
 

2.1.1.1(Beacon(信標)幀)  subtype 1000

 
    抓包顯示的結果:
 
 
    由於Beacon是廣播包,因此DA為FF:FF:FF:FF:FF:FF。
    作用:向STA廣播AP的存在。也就是我們平時能夠搜到AP的原因,其包含了AP的相關信息。

 

2.1.1.2 (Probe Request(探測請求)幀) subtype 0100

    抓包顯示的結果:
    作用:STA廣播發出,與AP建立關聯的必然步驟,后面會具體說明。

2.1.1.3 (Probe Response(探測響應)幀) subtype 0101

    作用:STA請求探測幀后,AP的相對應的回應幀。
 

2.1.1.4 (ATIM幀)  subtype  1001

2.1.1.5 (Disassociation(解除關聯)與Deauthentication(解除認證)幀) subtype 1010

2.1.1.6 (Association Request(關聯請求)幀) subtype 0000

2.1.1.7 (Reassociation Request(重新關聯請求)幀) subtype 0010

                                                

2.1.1.8 (Authentication(身份認證)幀) subtype 1011

 

2.1.2 數據幀 type 10

Type Subtype Frametype
10 0000 Data(數據)
10 0001 Data+CF-ACK
10 0010 Data+CF-Poll
10 0011 Data+CF-ACK+CF-Poll
10 0100 Null data(無數據:未傳送數據)
10 0101 CF-ACK(未傳送數據)
10 0110 CF-Poll(未傳送數據)
10 0111 Data+CF-ACK+CF-Poll
10 1000 Qos Data
10 1001 Qos Data + CF-ACK
10 1010 Qos Data + CF-Poll
10 1011 Qos Data + CF-ACK+ CF-Poll
10 1100 QoS Null(未傳送數據)
10 1101 QoS CF-ACK(未傳送數據)
10 1110 QoS CF-Poll(未傳送數據)
10 1111 QoS CF-ACK+ CF-Poll(未傳送數據)
   
 
 
 
 
 
 
 
 
 
2.1.2.1 IBSS subtype  (0000 Data,0100NULL)
 
 
 
2.1.2.2  From AP  subtype如圖所示
 
2.1.2.3 To AP 
2.1.2.4 WDS幀 subtype null
 

2.1.3 控制幀 type 01

    主要用於數據傳輸前的控制,相關過程請看4.0 RTS/CTS。
 
Type Subtype Frametype
01 1010 Power Save(PS)- Poll(省電-輪詢)
01 1011 RTS(請求發送,即: Request To Send ,預約信道,幀長20字節)
01 1100 CTS(清除發送,即:Clear To Send ,同意預約,幀長14字節)
01 1101 ACK(確認)
01 1110 CF-End(無競爭周期結束)
01 1111
CF-End(無競爭周期結束)+CF-ACK(無競爭周期確認)
 
2.1.3.1 RTS幀 subtype 1011
 
2.1.3.2 CTS幀  subtype 1100
 
 
2.1.3.3 ACK幀 subtype 1101
2.1.3.4 PS-Poll幀  subtype  1010
    作用:當sta從省電模式中蘇醒,便發送一個PS-poll給基站。
 
 

3. Radiotap Header(monitor信息)

    在monitor模式時,內核在MAC幀前面提供額外的信息。稱為Radiotap Header,其包含的信息有MAC時間戳,SSI信號強度,頻道頻率等。
   
 
    這里的it_len表明了radiotap_header的長度,按上面抓到的包,這里的值為26。
    因此,在monitor模式得到的RAW包,我們首先要偏移it_len個字節,以此得到MAC頭。

4. RTS/CTS 幀 (數據發送原子性)

    這兩個幀出現的原因是 無線收發器(STA)通常無法同時收發數據。使用這兩個幀可以讓STA處於收或發狀態。
    這樣比較好理解,正是因為如此,當STA開始發送RTS,說明STA發數據;AP開始發送RTS,說明RTS接收數據。
    當其他STA收到RTS時,將延后數據包的發送。而具體延遲多久,由正在傳輸的MAC頭中的持續時間決定(Duration ID)。如:
    RTS(Request-to-Send):請求發送數據。
    CTS(Clear-to-Send):清空傳送區域。
    兩個幀的過程如圖:
    ①為 STA  ②為AP 
    抓的兩個包來看下,下面是STA作為請求方
    下面是STA作為接收方:
   上圖的223.252.199.6(00:36:76:54:b4:a2)是ap,172.21.11.2(a4:d1:d2:60:bb:0d)是STA,其Qos數據數據如下:
    RTS和CTS幀會延長幀傳輸過程,RTS,CTS,數據幀,以及ACK視為同一原子操作的一部分。
    用戶可以通過調整RTS閾值,來控制RTS/CTS交換過程。只要大於此閾值,RTS/CTS交換過程就會進行,小於該閾值就會直接傳送幀。
    對應的SOCK字段如下:
 
  1. #define SIOCSIWRTS 0x8B22 /* set RTS/CTS threshold (bytes) */
  2. #define SIOCGIWRTS 0x8B23 /* get RTS/CTS threshold (bytes) */
    

5. WIFI建立關聯過程

    建立連接認證的過程主要由管理幀負責。
序號 SubType 說明
1 1000 Beacon,STA接受AP信標幀,感知到AP,獲取SSID及AP參數
2 0100 STA主動發送Probe探測請求
3 0101 AP應答STA Prob Response
4 1011 STA發送Authentication請求認證
5   AP應答Authentication請求,指示STA認證成功或失敗
6 0000 STA發送Association請求
7 0001 AP應答Association Response
    以上是連接過程,當需要斷開連接時,STA發送 Disassociation
序號SubType說明81010斷開連接
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
*********************************************************
××抓包類型總結××
 
 
 
Type value Type description Subtype value Subtype description
Wireshark display filter
00 Management 0000 Association Request wlan.fc.type_subtype == 0x00
00 Management 0001 Association Response wlan.fc.type_subtype == 0x01
00 Management 0010 Reassociation Request wlan.fc.type_subtype == 0x02
00 Management 0011 Reassociation Response wlan.fc.type_subtype == 0x03
00 Management 0100 Probe Request wlan.fc.type_subtype == 0x04
00 Management 0101 Probe Response wlan.fc.type_subtype == 0x05
00 Management 0110-0111 Reserved  
00 Management 1000 Beacon wlan.fc.type_subtype == 0x08
00 Management 1001 ATIM wlan.fc.type_subtype == 0x09
00 Management 1010 Disassociation wlan.fc.type_subtype == 0x0A
00 Management 1011 Authentication wlan.fc.type_subtype == 0x0B
00 Management 1100 Deauthentication wlan.fc.type_subtype == 0x0C
00 Management 1101 Action wlan.fc.type_subtype == 0x0D
00 Management 1110-1111 Reserved  
 
Type value Type description Subtype value Subtype description
Wireshark display filter
01 Control 0000-0111 Reserved  
01 Control 1000 Block Ack Request wlan.fc.type_subtype == 0x18
01 Control 1001 Block Ack wlan.fc.type_subtype == 0x19
01 Control 1010 PS-Poll wlan.fc.type_subtype == 0x1A
01 Control 1011 RTS wlan.fc.type_subtype == 0x1B
01 Control 1100 CTS wlan.fc.type_subtype == 0x1C
01 Control 1101 ACK wlan.fc.type_subtype == 0x1D
01 Control 1110 CF-end  wlan.fc.type_subtype == 0x1E
01 Control 1111 CF-end + CF-ack wlan.fc.type_subtype == 0x1F
           
 
Type value Type description Subtype value Subtype description
Wireshark display filter
10 Data 0000 Data wlan.fc.type_subtype == 0x20
10 Data 0001 Data + CF-ack wlan.fc.type_subtype == 0x21
10 Data 0010 Data + CF-poll wlan.fc.type_subtype == 0x22
10 Data 0011 Data +CF-ack +CF-poll wlan.fc.type_subtype == 0x23
10 Data 0100 Null wlan.fc.type_subtype == 0x24
10 Data 0101 CF-ack wlan.fc.type_subtype == 0x25
10 Data 0110 CF-poll wlan.fc.type_subtype == 0x26
10 Data 0111 CF-ack +CF-poll wlan.fc.type_subtype == 0x27
10 Data 1000 QoS data wlan.fc.type_subtype == 0x28
10 Data 1001 QoS data + CF-ack wlan.fc.type_subtype == 0x29
10 Data 1010 QoS data + CF-poll wlan.fc.type_subtype == 0x2A
10 Data 1011 QoS data + CF-ack + CF-poll wlan.fc.type_subtype == 0x2B
10 Data 1100 QoS Null wlan.fc.type_subtype == 0x2C
10 Data 1101 Reserved wlan.fc.type_subtype == 0x2D
10 Data 1110 QoS + CF-poll (no data) wlan.fc.type_subtype == 0x2E
10 Data 1111 Qos + CF-ack (no data) wlan.fc.type_subtype == 0x2F
11 Reserved 0000-1111 Reserved  
 
 
文參考《802.11無線網絡 權威指南》


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM