本帖最后由 guoqingli1123 于 2016-10-12 11:39 编辑
最近在调试MINI-STM32的DHCP。一开始调试的挺顺利,用家里的路由器很快就调试成功了。但后来在公司换了个路由器调试怎么都获取不了IP地址。电脑可以正常获取IP地址。很郁闷。网上也没有找到答案。不能DHCP的路由器是D-LINK,非常老的路由器,我又找了个路由器磊科的,比较新,试了一下很快获取了IP地址。很纳闷。为啥电脑用D-LINK,磊科的都可以,而STM32-MINI板不行。于是进行了抓包
如下所示
以上为DLINK的。可以看到DLINK提供的offer包,BOOTP标志为0x0000, 单播
此时STM32-MINI板没有发出Request包,获取DHCP失败
而电脑并没有按照单播的要求进行回复,而是直接回复了广播包,一下就获取到了IP地址
然后对磊科的路由器进行抓包如下
发现磊科路由器提供的offer包,bootp标志为0x8000, 组播
此时STM32-MINI板能够正确获取到IP地址。
我试了几个路由发现只要发出的是0x0000的都获取不到IP地址。0x8000的都能正确获取。猜测lwip不支持0x0000模式????
怎么修改还没有解决方案。原子哥。。。求助。。。。
好像真没收到offer包呢。。。。哥,帮忙分析分析呗。都是广播包,为啥有的能收到,有的收不到?????
dhcp_start(): starting DHCP configuration
dhcp_discover()
pbuf_alloc(length= 308)
pbuf_alloc(length= 308) == 2000134c
transaction id xid(abcd0001)
dhcp_discover: making request
dhcp_discover: realloc()ing
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)
pbuf_header: old 20001394 new 2000138c ( 8)
udp_send: added header in given pbuf 2000134c
udp_send: sending datagram of length 316
udp_send: UDP packet length 316
inet_chksum_pseudo(): checksumming pbuf 2000134c (has next 00000000)
inet_chksum_pseudo(): pbuf chain lwip_chksum()= 6d91
udp_send: UDP checksum 0x0000000000000000000000000000000000000000926e
udp_send: ip_output_if (,,,,IP_PROTO_UDP,)
pbuf_header: old 2000138c new 20001378 ( 20)
ip_output_if: en 0
IP header:
+-------------------------------+
| 4 | 5 | 0x000000000000000000000000 | 336 | (v, hl, tos, len)
+-------------------------------+
| 0 | 0 0 0| 0 | (id, flags, offset)
+-------------------------------+
| 255 | 17 | 0x0000000000000000000000000000000000000000ba9d | (ttl, proto, chksum)
+-------------------------------+
| 0 | 0 | 0 | 0 | (src)
+-------------------------------+
| 255 | 255 | 255 | 255 | (dest)
+-------------------------------+
netif->output()pbuf_header: old 20001378 new 2000136a ( 14)
etharp_send_ip: sending packet 2000134c
dhcp_discover:pbuf_alloc(length= 60)
pbuf_alloc: allocated pbuf 20007ca8
pbuf_alloc(length= 60) == 20007ca8
ethernet_input: dest:ff:ff:ff:ff:ff:ff, src:08:10:75:d1:d9:9a, type: 806
etharp_update_arp_entry: 192. 168. 1. 1 - 000000000000000000000008:000000000000000000000010:000000000000000000000075:0000000000000000000000d1:0000000000000000000000d9:00000000000000000000009a
etharp_find_entry: found empty entry 0
etharp_find_entry: no empty entry found and not allowed to recycle
etharp_arp_input: incoming ARP request
etharp_arp_input: we are unconfigured, ARP request ignored.
pbuf_free(20007ca8)
pbuf_free: deallocating 20007ca8
deleting()ing
pbuf_free(2000134c)
pbuf_free: deallocating 2000134c
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 2000 msecs
netif: setting default interface en
etharp_request: sending ARP request.
pbuf_alloc(length= 42)
pbuf_alloc(length= 42) == 2000134c
etharp_raw: sending raw ARP packet.
pbuf_free(2000134c)
pbuf_free: deallocating 2000134c
tcp_slowtmr: no active pcbs
dhcp_start(netif=20008a38) en 0
dhcp_start(): restarting DHCP configuration
udp_bind(ipaddr = 0. 0. 0. 0, port = 68)
udp_bind: bound to 0. 0. 0. 0, port 68
udp_connect: connected to 0. 0. 0. 0,port 68
dhcp_start(): starting DHCP configuration
dhcp_discover()
pbuf_alloc(length= 308)
pbuf_alloc(length= 308) == 2000134c
transaction id xid(abcd0002)
dhcp_discover: making request
dhcp_discover: realloc()ing
dhcp_discover: sendto(DISCOVER, IP_ADDR_BROADCAST, DHCP_SERVER_PORT)
pbuf_header: old 20001394 new 2000138c ( 8)
udp_send: added header in given pbuf 2000134c
udp_send: sending datagram of length 316
udp_send: UDP packet length 316
inet_chksum_pseudo(): checksumming pbuf 2000134c (has next 00000000)
inet_chksum_pseudo(): pbuf chain lwip_chksum()= 6e91
udp_send: UDP checksum 0x0000000000000000000000000000000000000000916e
udp_send: ip_output_if (,,,,IP_PROTO_UDP,)
pbuf_header: old 2000138c new 20001378 ( 20)
ip_output_if: en 0
IP header:
+-------------------------------+
| 4 | 5 | 0x000000000000000000000000 | 336 | (v, hl, tos, len)
+-------------------------------+
| 1 | 0 0 0| 0 | (id, flags, offset)
+-------------------------------+
| 255 | 17 | 0x0000000000000000000000000000000000000000ba9c | (ttl, proto, chksum)
+-------------------------------+
| 0 | 0 | 0 | 0 | (src)
+-------------------------------+
| 255 | 255 | 255 | 255 | (dest)
+-------------------------------+
netif->output()pbuf_header: old 20001378 new 2000136a ( 14)
etharp_send_ip: sending packet 2000134c
dhcp_discover: deleting()ing
pbuf_free(2000134c)
pbuf_free: deallocating 2000134c
dhcp_discover: SELECTING
dhcp_discover(): set request timeout 2000 msecs
正在查找DHCP服务器,请稍等...........
tcp_slowtmr: no active pcbs
tcp_slowtmr: no active pcbs
tcp_slowtmr: no active pcbs
pbuf_alloc(length= 316)
pbuf_alloc: allocated pbuf 20007ca8
pbuf_alloc(length= 316) == 20007ca8
ethernet_input: dest:02:00:00:dc:ff:38, src:08:10:75:d1:d9:9a, type: 800
pbuf_header: old 20007cb8 new 20007cc6 ( -14)
ip_input: iphdr->dest 0x 201a8c0 netif->ip_addr 0x 0 (0x 0, 0x 0, 0x 201a8c0)
ip_input: UDP packet to DHCP client port 68
ip_input: DHCP packet accepted.
ip_input:
IP header:
+-------------------------------+
| 4 | 5 | 0x000000000000000000000000 | 302 | (v, hl, tos, len)
+-------------------------------+
| 0 | 0 0 0| 0 | (id, flags, offset)
+-------------------------------+
| 64 | 17 | 0x0000000000000000000000000000000000000000f66b | (ttl, proto, chksum)
+-------------------------------+
| 192 | 168 | 1 | 1 | (src)
+-------------------------------+
| 192 | 168 | 1 | 2 | (dest)
+-------------------------------+
ip_input: p->len 302 p->tot_len 302
pbuf_header: old 20007cc6 new 20007cda ( -20)
udp_input: received datagram of length 282
UDP header:
+-------------------------------+
| 67 | 68 | (src port, dest port)
+-------------------------------+
| 282 | 0x00000000000000000000000000000000000000007f61 | (len, chksum)
+-------------------------------+
udp ( 192. 168. 1. 2, 68) <-- ( 192. 168. 1. 1, 67)
udp_input: calculating checksum
inet_chksum_pseudo(): checksumming pbuf 20007ca8 (has next 00000000)
inet_chksum_pseudo(): pbuf chain lwip_chksum()= ffff
pbuf_header: old 20007cda new 20007ce2 ( -8)
dhcp_recv(pbuf = 20007ca8) from DHCP server 192. 168. 1. 1 port 67
pbuf->len = 274
pbuf->tot_len = 274
transaction id mismatch reply_msg->xid(abcd0001)!=dhcp->xid(abcd0002)
pbuf_free(20007ca8)
pbuf_free: deallocating 20007ca8
pbuf_alloc(length= 316)
pbuf_alloc: allocated pbuf 20007ca8
pbuf_alloc(length= 316) == 20007ca8
ethernet_input: dest:02:00:00:dc:ff:38, src:08:10:75:d1:d9:9a, type: 800
pbuf_header: old 20007cb8 new 20007cc6 ( -14)
ip_input: iphdr->dest 0x 201a8c0 netif->ip_addr 0x 0 (0x 0, 0x 0, 0x 201a8c0)
ip_input: UDP packet to DHCP client port 68
ip_input: DHCP packet accepted.
ip_input:
IP header:
+-------------------------------+
| 4 | 5 | 0x000000000000000000000000 | 302 | (v, hl, tos, len)
+-------------------------------+
| 0 | 0 0 0| 0 | (id, flags, offset)
+-------------------------------+
| 64 | 17 | 0x0000000000000000000000000000000000000000f66b | (ttl, proto, chksum)
+-------------------------------+
| 192 | 168 | 1 | 1 | (src)
+-------------------------------+
| 192 | 168 | 1 | 2 | (dest)
+-------------------------------+
ip_input: p->len 302 p->tot_len 302
pbuf_header: old 20007cc6 new 20007cda ( -20)
udp_input: received datagram of length 282
UDP header:
+-------------------------------+
| 67 | 68 | (src port, dest port)
+-------------------------------+
| 282 | 0x00000000000000000000000000000000000000007f61 | (len, chksum)
+-------------------------------+
udp ( 192. 168. 1. 2, 68) <-- ( 192. 168. 1. 1, 67)
udp_input: calculating checksum
inet_chksum_pseudo(): checksumming pbuf 20007ca8 (has next 00000000)
inet_chksum_pseudo(): pbuf chain lwip_chksum()= ffff
pbuf_header: old 20007cda new 20007ce2 ( -8)
dhcp_recv(pbuf = 20007ca8) from DHCP server 192. 168. 1. 1 port 67
pbuf->len = 274
pbuf->tot_len = 274
transaction id mismatch reply_msg->xid(abcd0001)!=dhcp->xid(abcd0002)
pbuf_free(20007ca8)
pbuf_free: deallocating 20007ca8
pbuf_alloc(length= 316)
pbuf_alloc: allocated pbuf 20007ca8
pbuf_alloc(length= 316) == 20007ca8
ethernet_input: dest:02:00:00:dc:ff:38, src:08:10:75:d1:d9:9a, type: 800
pbuf_header: old 20007cb8 new 20007cc6 ( -14)
ip_input: iphdr->dest 0x 201a8c0 netif->ip_addr 0x 0 (0x 0, 0x 0, 0x 201a8c0)
ip_input: UDP packet to DHCP client port 68
ip_input: DHCP packet accepted.
ip_input:
IP header:
+-------------------------------+
| 4 | 5 | 0x000000000000000000000000 | 302 | (v, hl, tos, len)
+-------------------------------+
| 0 | 0 0 0| 0 | (id, flags, offset)
+-------------------------------+
| 64 | 17 | 0x0000000000000000000000000000000000000000f66b | (ttl, proto, chksum)
+-------------------------------+
| 192 | 168 | 1 | 1 | (src)
+-------------------------------+
| 192 | 168 | 1 | 2 | (dest)
+-------------------------------+
ip_input: p->len 302 p->tot_len 302
pbuf_header: old 20007cc6 new 20007cda ( -20)
udp_input: received datagram of length 282
UDP header:
+-------------------------------+
| 67 | 68 | (src port, dest port)
+-------------------------------+
| 282 | 0x00000000000000000000000000000000000000007f61 | (len, chksum)
+-------------------------------+
udp ( 192. 168. 1. 2, 68) <-- ( 192. 168. 1. 1, 67)
udp_input: calculating checksum
inet_chksum_pseudo(): checksumming pbuf 20007ca8 (has next 00000000)
inet_chksum_pseudo(): pbuf chain lwip_chksum()= ffff
pbuf_header: old 20007cda new 20007ce2 ( -8)
dhcp_recv(pbuf = 20007ca8) from DHCP server 192. 168. 1. 1 port 67
pbuf->len = 274
pbuf->tot_len = 274
一周热门 更多>