Android系统DHCP问题【转】
本文转载自:http://blog.csdn.net/tankai19880619/article/details/42972551
一、现象
12小时压测wifi连接后,发现网络连接中断;相关log:
我们关心状态变化部分ConnectivityService: ConnectivityChange for WIFI
- 01-19-17:42;0501-01 08:00:38.552 954 1117 D ConnectivityService: --NetworkStateTracker.EVENT_STATE_CHANGED handle--
- 01-19-17:42;0501-01 08:00:38.552 954 1117 D ConnectivityService: ConnectivityChange for WIFI: CONNECTED/CONNECTED
- 01-19-17:42;0501-01 08:00:38.552 954 1117 D ConnectivityService: Setting TCP values: [524288,1048576,2097152,262144,524288,1048576] which comes from [net.tcp.buffersize.wifi]
- /////////////////////////////////////////////////////////////////////////////////////////////////////12hago
- 01-20-05:14;2201-01 19:33:18.943 1267 1386 V shizx : @@@clienttype:@@@TCL-CN-MT55CD-F3700A-LG
- 01-20-05:14;22ERROR!!! MlmeEnqueueForRecv: un-recongnized mgmt->subtype=15
- 01-20-05:14;2301-01 19:33:19.572 954 1808 E Dhinit:
- 01-20-05:14;23 waitpid returned pid 1835, status = 00000009
- 01-20-05:14;23cpStateMacinit: process 'dhcpcd_wlan0', pid 1835 exited
- 01-20-05:14;23hine: DHCP failed on wlan0: Timed out waiting for DHCP Renew to finish
- 01-20-05:14;2301-01 19:33:19.574 954 1808 D DHCP : ifc_init, return = 0
- 01-20-05:14;2301-01 19:33:19.574 954 1808 D DHCP : ifc_set_addr(wlan0, xx) = 0
- 01-20-05:14;2301-01 19:33:19.574 954 1808 D DHCP : ifc_close
- 01-20-05:14;2301-01 19:33:19.779 954 1115 D WifiHW : send cmd is DRIVER POWERMODE 0
- 01-20-05:14;2301-01 19:33:19.779 954 1115 D WifiHW : send cmd is DRIVER BTCOEXMODE 2
- 01-20-05:14;2301-01 19:33:19.781 954 1115 E WifiStateMachine: IP configuration failed
- 01-20-05:14;2301-01 19:33:19.781 954 1115 D WifiHW : send cmd is DISCONNECT
- 01-20-05:14;2301-01 19:33:19.782 1558 1558 D wpa_supplicant: wpa_driver_wext_deauthenticate
- 01-20-05:14;2301-01 19:33:19.789 1558 1558 D wpa_supplicant: wpa_driver_wext_set_key: alg=0 key_idx=0 set_tx=0 seq_len=0 key_len=0
- 01-20-05:14;2301-01 19:33:19.790 1558 1558 D wpa_supplicant: wpa_driver_wext_set_key: alg=0 key_idx=1 set_tx=0 seq_len=0 key_len=0
- 01-20-05:14;2301-01 19:33:19.790 954 1110 D NetdConnector: RCV <- {600 Iface linkstate wlan0 up}
- 01-20-05:14;2301-01 19:33:19.793 1558 1558 D wpa_supplicant: wpa_driver_wext_set_key: alg=0 key_idx=2 set_tx=0 seq_len=0 key_len=0
- 01-20-05:14;2301-01 19:33:19.793 1558 1558 D wpa_supplicant: wpa_driver_wext_set_key: alg=0 key_idx=3 set_tx=0 seq_len=0 key_len=0
- 01-20-05:14;2301-01 19:33:19.794 1558 1558 D wpa_supplicant: wpa_driver_wext_set_key: alg=0 key_idx=0 set_tx=0 seq_len=0 key_len=0
- 01-20-05:14;2301-01 19:33:19.795 1558 1558 D wpa_supplicant: wpa_driver_wext_set_operstate: operstate 1->0 (DORMANT)
- 01-20-05:14;2301-01 19:33:19.795 1558 1558 D wpa_supplicant: netlinkinit:
- 01-20-05:14;23 waitpid returned pid 1126, status = 00000009
- 01-20-05:14;23init: process 'dhcpcd_eth0', pid 1126 exited
- 01-20-05:14;23: Operstate: linkmode=-1, operstate=5
二、分析
关键部分:
- DhcpStateMachine: DHCP failed on wlan0: Timed out waiting for DHCP Renew to finish
- init: waitpid returned pid 1835, status = 00000009
- init: process 'dhcpcd_wlan0', pid 1835 exited
1.frameworks/base/core/java/android/net/DhcpStateMachine.java
- private boolean runDhcp(DhcpAction dhcpAction) {
- if (dhcpAction == DhcpAction.START) {
- if (DBG) Log.d(TAG, "DHCP request on " + mInterfaceName);
- success = NetworkUtils.runDhcp(mInterfaceName, dhcpInfoInternal);
- mDhcpInfo = dhcpInfoInternal;
- } else if (dhcpAction == DhcpAction.RENEW) {
- if (DBG) Log.d(TAG, "DHCP renewal on " + mInterfaceName);
- success = NetworkUtils.runDhcpRenew(mInterfaceName, dhcpInfoInternal); //f分析该函数
- dhcpInfoInternal.updateFromDhcpRequest(mDhcpInfo);
- }
- if (success) {
- ......
- } else {
- //这里就是打印:DhcpStateMachine: DHCP failed on wlan0: Timed out waiting for DHCP Renew to finish
- Log.e(TAG, "DHCP failed on " + mInterfaceName + ": " +
- NetworkUtils.getDhcpError());
- NetworkUtils.stopDhcp(mInterfaceName);
- mController.obtainMessage(CMD_POST_DHCP_ACTION, DHCP_FAILURE, 0)
- .sendToTarget();
- }
- return success;
- }
2.frameworks/base/core/java/android/net/NetworkUtils.java
- public native static boolean runDhcpRenew(String interfaceName, DhcpInfoInternal ipInfo);
3.frameworks/base/core/jni/android_net_NetUtils.cpp
- static jboolean android_net_utils_runDhcpRenew(JNIEnv* env, jobject clazz, jstring ifname, jobject info)
- {
- return android_net_utils_runDhcpCommon(env, clazz, ifname, info, true);
- }
- static jboolean android_net_utils_runDhcpCommon(JNIEnv* env, jobject clazz, jstring ifname,
- jobject info, bool renew)
- {
- if (renew) {
- result = ::dhcp_do_request_renew(nameStr, ipaddr, gateway, &prefixLength,
- dns1, dns2, server, &lease, vendorInfo);
- }
- }
4.system/core/libnetutils/dhcp_utils.c
- int dhcp_do_request_renew(const char *interface,
- char *ipaddr,
- char *gateway,
- uint32_t *prefixLength,
- char *dns[],
- char *server,
- uint32_t *lease,
- char *vendorInfo,
- char *domain,
- char *mtu)
- {
- if (wait_for_property(result_prop_name, NULL, 30) < 0) {
- snprintf(errmsg, sizeof(errmsg), "%s", "Timed out waiting for DHCP Renew to finish"); //这是最关键的错误部分
- return -1;
- }
- }
- static int wait_for_property(const char *name, const char *desired_value, int maxwait)
- {
- char value[PROPERTY_VALUE_MAX] = {'\0'};
- int maxnaps = (maxwait * 1000) / NAP_TIME;
- if (maxnaps < 1) {
- maxnaps = 1;
- }
- //add by tank
- // add for MStar Android Patch Begin
- maxnaps = maxnaps + 1;
- usleep(50*1000);
- // add for MStar Android Patch End
- //end tank
- while (maxnaps-- > 0) {
- usleep(NAP_TIME * 1000);
- if (property_get(name, value, NULL)) {
- if (desired_value == NULL ||
- strcmp(value, desired_value) == 0) {
- return 0;
- }
- }
- //add by tank@
- // add for MStar Android Patch Begin
- usleep(NAP_TIME * 1000);
- // add for MStar Android Patch End
- //end tank
- }
- return -1; /* failure */
- }
三、解决
合入上处4中add by tank后问题解决。
其他问题,mac地址冲突导致重启后无法获取IP。
- D/NetdConnector( 958): RCV <- {213 5c:36:b8:4d:ab:7a 0.0.0.0 0 [up broadcast multicast]}
- D/NetdConnector( 958): RSP <- {213 5c:36:b8:4d:ab:7a 0.0.0.0 0 [up broadcast multicast]}
- D/NetworkManagementService( 958): rsp <213 5c:36:b8:4d:ab:7a 0.0.0.0 0 [up broadcast multicast]>
- D/NetworkManagementService( 958): flags <[up broadcast multicast]>
- D/NetworkManagementService( 958): Registering observer
- I/EthernetStateTracker( 958): reset device eth0
- D/NetUtils( 958): android_net_utils_resetConnections in env=0x7d6950 clazz=0xad200001 iface=eth0 mask=0x3
- D/DHCP ( 958): ifc_init, return = 0
- D/DHCP ( 958): ifc_close
- D/DHCP ( 958): ifc_init, return = 0
- D/DHCP ( 958): ifc_up(eth0) = 0
- D/DHCP ( 958): ifc_close
- D/DHCP ( 958): ifc_init, return = 0
- D/DHCP ( 958): ifc_close
- D/DHCP ( 958): ifc_init, return = 0
- D/DHCP ( 958): ifc_close
- D/dhcp ( 1124): enter dhcpcd service
- D/dhcp ( 1124): enter dhcpcd service add options
- D/dhcp ( 1124): enter dhcpcd service leave option
- D/dhcp ( 1124): enter dhcpcd service chdir
- D/dhcp ( 1124): enter dhcpcd service dump
- D/dhcp ( 1124): enter dhcpcd service master
- E/dhcp ( 1124): version 5.2.10 starting
- D/DHCP ( 1124): ifc_init, return = 0
- D/DHCP ( 1124): ifc_close
- F/dhcp ( 1124): eth0: using hwaddr 5c:36:b8:4d:ab:7a
- F/dhcp ( 1124): eth0: executing `/system/etc/dhcpcd/dhcpcd-run-hooks', reason PREINIT
- I/dhcp ( 1124): host does not support a monotonic clock - timing can skew
- F/dhcp ( 1124): eth0: reading lease `/data/misc/dhcp/dhcpcd-eth0.lease'
- E/dhcp ( 1124): eth0: broadcasting for a lease
- F/dhcp ( 1124): eth0: sending DISCOVER (xid 0xd92bbde3), next in 3.54 seconds
Android系统DHCP问题【转】的更多相关文章
- 深入浅出 - Android系统移植与平台开发(五)- 编译Android源码(转)
2.3编译Android源码 Android源码体积非常庞大,由Dalvik虚拟机.Linux内核.编译系统.框架代码.Android定制C库.测试套件.系统应用程序等部分组成,在编译Android源 ...
- Android系统在超级终端下必会的命令大全(adb shell命令大全)
. 显示系统中全部Android平台: android list targets . 显示系统中全部AVD(模拟器): android list avd . 创建AVD(模拟器): android c ...
- [总结]Android系统体系结构
Android 从图中可以看出Android主要的组成部分,其中底层是Linux的内核,包括的主要就是文件.内存.系统资源等的管理,Google在这部分的工作主要就是电源管理和一部分驱动,并且整合上层 ...
- 【Android 系统开发】 编译 Android文件系统 u-boot 内核 并烧写到 OK-6410A 开发板上
博客地址 : http://blog.csdn.net/shulianghan/article/details/40299813 本篇文章中用到的工具源码下载 : -- ok-6410A 附带的 A ...
- (转)android系统架构及源码目录结构
转自:http://blog.csdn.net/finewind/article/details/46324507 1. Android系统架构: android系统架构采用了分层架构的思想,如下图所 ...
- Android 系统属性-SystemProperties详解***
创建与修改android属性用Systemproperties.set(name, value),获取android属性用Systemproperties.get(name),需要注意的是androi ...
- 最新Android系统版本与API等级对应关系表
最新Android系统版本与API等级对应关系表 从Android官网拷过来的,方便查阅... 官网地址:https://developer.android.com/guide/topics/mani ...
- Android系统全貌 (转)
转自Gityuan的Android开篇,对自我学习作进一步整理. Android系统以Linux内核作为基底,上层采用Native层和Java层.系统分为内核空间和用户空间,并通过系统调用(Sysca ...
- android系统release签名
转自:http://blog.csdn.net/yangkai6121/article/details/38682321 为什么需要给Android系统签个名才能进行CTS认证呢?原来我们通过make ...
随机推荐
- python 中各种数据类型的排序问题
list #按照list的第二键值排序 disP2P = [[1,2,3],[2,3,4],[4,5,6]] disP2P = sorted(disP2P,key = lambda x:x[2]) s ...
- PAT 甲级 1087 All Roads Lead to Rome(SPFA+DP)
题目链接 All Roads Lead to Rome 题目大意:求符合题意(三关键字)的最短路.并且算出路程最短的路径有几条. 思路:求最短路并不难,SPFA即可,关键是求总路程最短的路径条数. 我 ...
- HTTP状态码之200和304
HTTP状态码之200和304 HTTP状态码(HTTP Status Code)是一种表示网页服务器响应状态的三位数字编码.通过这些数字,可以简化状态的表达.状态码有几十种,其中首位数字为1-5 ...
- Java开发者使用C++写程序踩的坑
笔者是一个很矛盾的人.平时用Java.但是一开始学习的时候学的是汇编语言,而且对C语言也很熟悉.为什么不学C++呢?是因为我可以完全用Java的编码规范去写C++.因此我不需要了解更多的诸如C++的命 ...
- python--文本处理1
1.字符和字符值之间的转换 内建函数:ord(),chr() >>> print ord("a") 97 >>> print chr(97) a ...
- 邁向IT專家成功之路的三十則鐵律 鐵律十六:IT人交友之道-單純
元曲知名的作家 白樸,曾在沉醉東風﹒漁夫一文創作中,寫道:「雖無刎頸交,卻有忘機友」.IT人交朋友應首重在單純而非廣泛,因為實際上越複雜的朋友圈,只會為你的工作以及生活帶來許多不必要的麻煩.至於男女朋 ...
- STL源代码剖析 容器 stl_deque.h
本文为senlie原创.转载请保留此地址:http://blog.csdn.net/zhengsenlie deque ---------------------------------------- ...
- 现代数字信号处理——AR模型
1. AR模型概念观 AR模型是一种线性预测,即已知N个数据,可由模型推出第N点前面或后面的数据(设推出P点),所以其本质类似于插值,其目的都是为了增加有效数据,只是AR模型是由N点递推, ...
- MySQL常用SQL整理
MySQL常用SQL整理 一.DDL #创建数据库 CREATE DATABASE IF NOT EXISTS product DEFAULT CHARSET utf8 COLLATE utf8_ge ...
- 算法——字符串匹配之BM算法
前言 Boyer-Moore算法是一种基于后缀匹配的模式串匹配算法(简称BM算法),后缀匹配就是模式串从右到左開始比較,但模式串的移动依旧是从左到右的.在实践中.BM算法效率高于前面介绍的<KM ...