802.11是現在部署非常廣泛的也是支持的客戶端最多的無線上網協議。
支持802.11協議的客戶端想要通過無線路由上網時,首先必須要知道有哪些無線接入點存在,這就想你想通過有線上網必須要
先找到網口一樣。在找到無線接入點之後,客戶端要和接入點進行綁定,並在得到接入點的認可之後,才能獲得
權限訪問網絡。整個過程涉及到很多內容,包括客戶端和接入點之間協商數據傳輸速度,協商認證方式等。
爲了搞清楚整個客戶端通過接入點連接網絡的整個過程,我用wireshark工具抓了筆記本和一個開放接入點之間
的網絡包,簡單分析後,使用mscgen工具描繪了大概的交互過程。
抓包的過程是這樣的:首先打開wireshark指定從wlan0抓包,然後在瀏覽器中輸入www.163.com. 當然上圖只是從大量的網絡包中提取
出來的我認爲能夠描述主要過程的包。實際上802.11協議需要大量的控制包來協助無線客戶端和接入點進行通信,同時你的無線網卡
也會收到大量的其他無線節點發過來的協議包,因爲空中的協議包是對任何人開放的。
下面是我畫這個交互圖的mscgen描述語言。
msc {
arcgradient = 10;
a [label="PC"],b [label="AP"];
a=>b [label="12468 probe request", textcolour="blue", linecolour="blue"];
a=>b [label="12487 authentication", textcolour="blue", linecolour="blue"];
b=>a [label="12490 authentication", textcolour="red", linecolour="red"];
a=>b [label="12492 associate request", textcolour="blue", linecolour="blue"];
b=>a [label="12494 associate response", textcolour="red", linecolour="red"];
a=>b [label="12678 dhcp request", textcolour="blue", linecolour="blue"];
b=>a [label="12687 dhcp ack", textcolour="red", linecolour="red"];
a=>b [label="12698 igmp/ipv4 mcast", textcolour="blue", linecolour="blue"];
a=>b [label="15195 dns query www.163.com", textcolour="blue", linecolour="blue"];
b=>a [label="15217 dns response", textcolour="red", linecolour="red"];
a=>b [label="15223 tcp [syn]", textcolour="blue", linecolour="blue"];
b=>a [label="15226 tcp [syn,ack]", textcolour="red", linecolour="red"];
a=>b [label="15229 tcp [ack]", textcolour="blue", linecolour="blue"];
a=>b [label="15232 http get", textcolour="blue", linecolour="blue"];
}
我之前用過visio,dia等圖形化工具來畫這種交互圖,但是感覺還是很麻煩,比如擺放箭頭,調整顏色
之類的,在發現mscgen這個工具後,我覺得可以放棄visio和dia了。mscgen的作者是受了graphviz的啓發纔開始開發這個工具的。
graphviz的dot語言也是畫各種結構圖的一件利器