linux 下VLAN資料包格式__linux

來源:互聯網
上載者:User
主要是對VLAN的資料包格式進行了抓包分析。同時對vconfig命令的適用進行了說明。

PC:10.10.107.168  AP:10.10.107.231(eth0.100)

1:添加VLAN,使用vconfig。

~# vconfig

BusyBoxv1.10.3 (2012-09-23 02:13:20 CST) multi-call binary

Usage:vconfig COMMAND [OPTIONS]...

Create andremove virtual ethernet devices

Options:

        add             [interface-name] [vlan_id]

        rem             [vlan-name]

        set_flag        [interface-name] [flag-num] [0 | 1]

        set_egress_map  [vlan-name] [skb_priority] [vlan_qos]

        set_ingress_map [vlan-name][skb_priority] [vlan_qos]

        set_name_type   [name-type]

 

tcpdump-i br0 -s 0 -w dump.pcap

./tcpdump-i eth0 -xxvv

 route -n

~ #vconfig add eth0 100

~ #ifconfig -a

br0       Link encap:Ethernet  HWaddr 00:03:7F:11:20:00 

          inet addr:192.168.1.2  Bcast:192.168.1.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500 Metric:1

          RX packets:8 errors:0 dropped:0overruns:0 frame:0

          TX packets:0 errors:0 dropped:0overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:410 (410.0 B)  TX bytes:0 (0.0 B)

 

eth0      Link encap:Ethernet  HWaddr 00:03:7F:11:20:00 

          UP BROADCAST RUNNING MULTICAST  MTU:1500 Metric:1

          RX packets:16 errors:0 dropped:0 overruns:0frame:0

          TX packets:0 errors:0 dropped:0overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:1108 (1.0 KiB)  TX bytes:0 (0.0 B)

 

eth0.100  Link encap:Ethernet  HWaddr 00:03:7F:11:20:00 

          BROADCAST MULTICAST  MTU:1500 Metric:1

          RX packets:0 errors:0 dropped:0overruns:0 frame:0

          TX packets:0 errors:0 dropped:0overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

 

lo        Link encap:Local Loopback 

          inet addr:127.0.0.1  Mask:255.0.0.0

          UP LOOPBACK RUNNING  MTU:16436 Metric:1

          RX packets:0 errors:0 dropped:0overruns:0 frame:0

          TX packets:0 errors:0 dropped:0overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

 

teql0     Link encap:UNSPEC  HWaddr00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 

          NOARP MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0overruns:0 frame:0

          TX packets:0 errors:0 dropped:0overruns:0 carrier:0

          collisions:0 txqueuelen:100

          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Ifconfig  eth0.100  10.10.107.231

         

~# ./tcpdump -i eth0 -xxvv

tcpdump:WARNING: can't create rx ring on packet socket 3: 99-Protocol not available

tcpdump:WARNING: eth0: no IPv4 address assigned

tcpdump:listening on eth0, link-type EN10MB (Ethernet), capture size 68 bytes

00:06:13.184401ARP, Ethernet (len 6), IPv4 (len 4),Request who-has 10.10.107.168 tell10.10.107.231, length 28

        0x0000: ffff ffff ffff 0003 7f112000 8100 0064

        0x0010: 08060001 08000604 0001 0003 7f11 2000

        0x0020: 0a0a 6be7 0000 0000 0000 0a0a 6ba8

00:06:13.184592ARP, Ethernet (len 6), IPv4 (len 4),Reply10.10.107.168 is-at e8:39:35:38:9e:4a(oui Unknown), length 46

        0x0000: 0003 7f11 2000e839 3538 9e4a0806 0001

        0x0010: 0800 0604 0002 e839 3538 9e4a 0a0a 6ba8

        0x0020: 0003 7f11 2000 0a0a 6be7 0000 0000 0000

        0x0030: 0000 0000 0000 0000 0000 0000

00:06:13.958903IP (tos 0x0, ttl 128, id 57182, offset 0, flags [none], proto ICMP (1), length60)

    10.10.107.168 > 10.10.107.231: ICMP echorequest, id 1024, seq 13840, length 40

        0x0000:  0003 7f11 2000 e839 3538 9e4a 0800 4500

        0x0010: 003c df5e 0000 8001 6fbf 0a0a 6ba8 0a0a

        0x0020: 6be7 0800 134c 0400 3610 6162 6364 6566

        0x0030: 6768 696a 6b6c 6d6e 6f70 7172 7374 7576

        0x0040: 7761 6263

00:06:14.196038ARP, Ethernet (len 6), IPv4 (len 4), Requestwho-has10.10.107.168 tell 10.10.107.231, length 28

        0x0000: ffff ffff ffff 0003 7f1120008100 0064

        0x0010: 0806 0001 0800 0604 0001 0003 7f11 2000

        0x0020: 0a0a 6be7 0000 0000 0000 0a0a 6ba8

00:06:14.196524ARP, Ethernet (len 6), IPv4 (len 4),Reply10.10.107.168 is-at e8:39:35:38:9e:4a (oui Unknown), length 46

        0x0000: 0003 7f11 2000 e839 35389e4a 0806 0001

        0x0010: 0800 0604 0002 e839 3538 9e4a 0a0a 6ba8

        0x0020: 0003 7f11 2000 0a0a 6be7 0000 0000 0000

        0x0030: 0000 0000 0000 0000 0000 0000

有上面,可以知道,在我們添加VLAN ID=100時,我們通過ping 10.10.107.168來ping PC就會有上面的資訊。村抓得包,我們可以知道,AP àPC 是已經加了VLAN TAG的。

注意上面的資料在試eth0上面抓到的。

而在eth0.100上面的資料如下:只有request。沒有replay。

~ # ./tcpdump-i eth0.100 -xxvv

deviceeth0.100 entered promiscuous mode

tcpdump:WARNING: can't create rx ring on packet socket 3: 99-Protocol not available

tcpdump:listening on eth0.100, link-type EN10MB (Ethernet), capture size 68 bytes

00:03:35.064079ARP, Ethernet (len 6), IPv4 (len 4),Request who-has10.10.107.168 tell 10.10.107.231, length 28

        0x0000: ffff ffff ffff 0003 7f11 2000 0806 0001

        0x0010: 0800 0604 0001 0003 7f11 2000 0a0a 6be7

        0x0020:  0000 0000 0000 0a0a 6ba8

00:03:36.064043ARP, Ethernet (len 6), IPv4 (len 4),Request who-has10.10.107.168 tell 10.10.107.231, length 28

        0x0000: ffff ffff ffff 0003 7f11 2000 0806 0001

        0x0010: 0800 0604 0001 0003 7f11 2000 0a0a 6be7

        0x0020: 0000 0000 0000 0a0a 6ba8

00:03:37.068137ARP, Ethernet (len 6), IPv4 (len 4),Request who-has10.10.107.168 tell 10.10.107.231, length 28

        0x0000: ffff ffff ffff 0003 7f11 2000 0806 0001

        0x0010: 0800 0604 0001 0003 7f11 2000 0a0a 6be7

        0x0020: 0000 0000 0000 0a0a 6ba8

2:更新部分

vlan協議資料框架格式:


vconfig命令的使用說明:


linux下vconfig命令實現說明:




vconfig命令設定engree操作:



和上面的圖類似


分別通過vconfig 設定不同的priority和vlan_qos,其中priority已經在vconfig的使用中說明了,是skb_buf的資料欄位。在我自己的ethernet驅動程式中此值是0;





聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.