其他分享
首页 > 其他分享> > WiFi DHCP 流程

WiFi DHCP 流程

作者:互联网

WiFi DHCP 流程
一、什么是DHCP?
  DHCP,动态主机配置协议,前身是BOOTP协议,是一个局域网的网络协议,使用UDP协议工作,常用的2个端口:67(DHCP server),68(DHCP client)。DHCP通常被用于局域网环境,主要作用是集中的管理、分配IP地址,使client动态的获得IP地址、Gateway地址、DNS服务器地址等信息,并能够提升地址的使用率。简单来说,DHCP就是一个不需要账号密码登录的、自动给内网机器分配IP地址等信息的协议。

二、DHCP协议中的报文
DHCP报文共有一下几种:

DHCP DISCOVER :客户端开始DHCP过程发送的包,是DHCP协议的开始
DHCP OFFER :服务器接收到DHCP DISCOVER之后做出的响应,它包括了给予客户端的IP(yiaddr)、客户端的MAC地址、租约过期时间、服务器的识别符以及其他信息
DHCP REQUEST :客户端对于服务器发出的DHCP OFFER所做出的响应。在续约租期的时候同样会使用。
DHCP ACK :服务器在接收到客户端发来的DHCP REQUEST之后发出的成功确认的报文。在建立连接的时候,客户端在接收到这个报文之后才会确认分配给它的IP和其他信息可以被允许使用。
DHCP NAK :DHCP ACK的相反的报文,表示服务器拒绝了客户端的请求。
DHCP RELEASE :一般出现在客户端关机、下线等状况。这个报文将会使DHCP服务器释放发出此报文的客户端的IP地址
DHCP INFORM :客户端发出的向服务器请求一些信息的报文
DHCP DECLINE :当客户端发现服务器分配的IP地址无法使用(如IP地址冲突时),将发出此报文,通知服务器禁止
使用该IP地址。

三、DHCP工作流程
在这里插入图片描述
四、关键log流程打印

01-19 10:23:25.021  1496  3914 D WifiClientModeImpl: SUPPLICANT_STATE_CHANGE_EVENT state=SCANNING -> state= SCANNING
01-19 10:23:26.788 29737 29737 I wpa_supplicant: wlan0: Trying to associate with SSID 'HuaweiMate'
01-19 10:23:26.790  1496  3914 D WifiClientModeImpl: SUPPLICANT_STATE_CHANGE_EVENT state=ASSOCIATING -> state= CONNECTING
01-19 10:23:27.002 29737 29737 D wpa_supplicant: nl80211: Associated with dc:72:9b:42:6b:ab
01-19 10:23:27.002 29737 29737 D wpa_supplicant: nl80211: Associated with dc:72:9b:42:6b:ab
01-19 10:23:27.003 29737 29737 I wpa_supplicant: wlan0: Associated with dc:72:9b:42:6b:ab
01-19 10:23:27.004 29737 29737 I wpa_supplicant: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
01-19 10:23:27.004  1496  3914 D WifiClientModeImpl: SUPPLICANT_STATE_CHANGE_EVENT state=ASSOCIATED -> state= CONNECTING
01-19 10:23:27.005  1496  3914 D WifiClientModeImpl: SUPPLICANT_STATE_CHANGE_EVENT state=FOUR_WAY_HANDSHAKE -> state= AUTHENTICATING
01-19 10:23:27.027 29737 29737 I wpa_supplicant: wlan0: CTRL-EVENT-CONNECTED - Connection to dc:72:9b:42:6b:ab completed [id=0 id_str=%7B%22configKey%22%3A%22%5C%22HuaweiMate%5C%22WPA_PSK%22%2C%22creatorUid%22%3A%221000%22%7D]
01-19 10:23:27.029  1496  3914 D WifiClientModeImpl: SUPPLICANT_STATE_CHANGE_EVENT state=GROUP_HANDSHAKE -> state= AUTHENTICATING
01-19 10:23:27.126  1496 29966 D DhcpClient: Receive thread started
01-19 10:23:27.140  1496 29744 D DhcpClient: Broadcasting DHCPDISCOVER
01-19 10:23:27.152  1496 29966 D DhcpClient: Received packet: da:24:d7:7a:6c:e5 OFFER, ip /192.168.43.175, mask /255.255.255.0, DNS servers: /192.168.43.1 , gateways [/192.168.43.1] lease time 3600, domain null
01-19 10:23:27.153  1496 29744 D DhcpClient: Got pending lease: android.net.networkstack.DhcpResults@4705803 DHCP server /192.168.43.1 Vendor info ANDROID_METERED lease 3600 seconds Servername
01-19 10:23:27.154  1496 29744 D DhcpClient: Broadcasting DHCPREQUEST ciaddr=0.0.0.0 request=192.168.43.175 serverid=192.168.43.1
01-19 10:23:27.172  1496 29966 D DhcpClient: Received packet: da:24:d7:7a:6c:e5 ACK: your new IP /192.168.43.175, netmask /255.255.255.0, gateways [/192.168.43.1] DNS servers: /192.168.43.1 , lease time 3600
01-19 10:23:27.173  1496 29744 D DhcpClient: Confirmed lease: android.net.networkstack.DhcpResults@2c7fdb9 DHCP server /192.168.43.1 Vendor info ANDROID_METERED lease 3600 seconds Servername
01-19 10:23:27.198  1496 29744 D DhcpClient: Scheduling renewal in 1799s
01-19 10:23:27.198  1496 29744 D DhcpClient: Scheduling rebind in 3149s
01-19 10:23:27.198  1496 29744 D DhcpClient: Scheduling expiry in 3599sbash
在这里插入代码片

标签:10,01,23,19,流程,WiFi,1496,DHCP
来源: https://blog.csdn.net/AaronDroid/article/details/122704335