android dhcp 服务器,Android推送SDK(10)-DHCP租约到期自动续租问题导致TCP连接异常-程序员宅基地

技术标签: android dhcp 服务器  

DHCP

简单的来说,DHCP是一个局域网协议,使用UDP协议进行工作,它的作用就是动态的分配IP地址,Gateway地址,DNS服务器地址等信息,一旦租约到期,那么路由器就会把当前的这个ip分配给其他设备使用,所以,对于设备而言要定期请求DHCP Server来更新ip地址信息,保证ip地址有效可用

DHCP租约到期,设备不会自动进行续租而仍然使用旧的ip地址

DHCP租约到期,设备向DHCP Server发起请求,但是没有收到Ack

遇到如上情况会导致ip无法更新,所以设备仍然会使用旧的ip,对于tcp连接来说,使用旧的过期ip就意味着连接不到远程服务器,从我们的日志信息中可以得知,当TCP使用过期的ip去连接远程服务器的时候会报如下异常:java.net.NoRouteToHostException: No route to host,意思是说没有可达Host的路由,确实是这样的,设备连接无线网是连接到路由器上的,而路由器上分配给设备的ip已经过期不可用,那么设备到路由器的链路是通的,但是路由器到远程主机的链路肯定是不通的,所以会报如上错误

正常情况下,我们的Android设备在处于熄屏的状态下,DHCP的租约是1个小时,所以会每隔半小时就请求DHCP Server来更新ip地址:

Line 30221: 09-11 12:58:51.016 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 30227: 09-11 12:58:51.246 1835 3791 D DhcpClient: Received packet: 00:0a:f5:43:d8:7c ACK: your new IP /172.28.88.48, netmask /255.255.248.0, gateways [/172.28.88.254] DNS servers: /114.114.114.114 /172.28.1.28 /8.8.8.8 /172.28.1.26 , lease time 3600

Line 30228: 09-11 12:58:51.247 1835 3789 D DhcpClient: Renewed lease: IP address 172.28.88.48/21 Gateway 172.28.88.254 DNS servers: [ 114.114.114.114 172.28.1.28 8.8.8.8 172.28.1.26 ] Domains dw.gdbbk.com DHCP server /1.1.1.1 Vendor info ������ lease 3600 seconds

Line 30228: 09-11 12:58:51.247 1835 3789 D DhcpClient: Renewed lease: IP address 172.28.88.48/21 Gateway 172.28.88.254 DNS servers: [ 114.114.114.114 172.28.1.28 8.8.8.8 172.28.1.26 ] Domains dw.gdbbk.com DHCP server /1.1.1.1 Vendor info ������ lease 3600 seconds

Line 30243: 09-11 12:58:51.252 1835 3789 D DhcpClient: Scheduling renewal in 1799s

Line 30244: 09-11 12:58:51.253 1835 3789 D DhcpClient: Scheduling rebind in 3149s

Line 30245: 09-11 12:58:51.253 1835 3789 D DhcpClient: Scheduling expiry in 3599s

Line 30718: 09-11 13:28:51.280 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 30718: 09-11 13:28:51.280 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 30722: 09-11 13:28:51.306 1835 3791 D DhcpClient: Received packet: 00:0a:f5:43:d8:7c ACK: your new IP /172.28.88.48, netmask /255.255.248.0, gateways [/172.28.88.254] DNS servers: /114.114.114.114 /172.28.1.28 /8.8.8.8 /172.28.1.26 , lease time 3600

Line 30723: 09-11 13:28:51.307 1835 3789 D DhcpClient: Renewed lease: IP address 172.28.88.48/21 Gateway 172.28.88.254 DNS servers: [ 114.114.114.114 172.28.1.28 8.8.8.8 172.28.1.26 ] Domains dw.gdbbk.com DHCP server /1.1.1.1 Vendor info ������ lease 3600 seconds

Line 30723: 09-11 13:28:51.307 1835 3789 D DhcpClient: Renewed lease: IP address 172.28.88.48/21 Gateway 172.28.88.254 DNS servers: [ 114.114.114.114 172.28.1.28 8.8.8.8 172.28.1.26 ] Domains dw.gdbbk.com DHCP server /1.1.1.1 Vendor info ������ lease 3600 seconds

Line 30747: 09-11 13:28:51.316 1835 3789 D DhcpClient: Scheduling renewal in 1799s

Line 30748: 09-11 13:28:51.316 1835 3789 D DhcpClient: Scheduling rebind in 3149s

Line 30749: 09-11 13:28:51.316 1835 3789 D DhcpClient: Scheduling expiry in 3599s

Line 31114: 09-11 13:58:53.153 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 31114: 09-11 13:58:53.153 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 31120: 09-11 13:58:53.220 1835 3791 D DhcpClient: Received packet: 00:0a:f5:43:d8:7c ACK: your new IP /172.28.88.48, netmask /255.255.248.0, gateways [/172.28.88.254] DNS servers: /114.114.114.114 /172.28.1.28 /8.8.8.8 /172.28.1.26 , lease time 3600

Line 31121: 09-11 13:58:53.221 1835 3789 D DhcpClient: Renewed lease: IP address 172.28.88.48/21 Gateway 172.28.88.254 DNS servers: [ 114.114.114.114 172.28.1.28 8.8.8.8 172.28.1.26 ] Domains dw.gdbbk.com DHCP server /1.1.1.1 Vendor info ������ lease 3600 seconds

Line 31121: 09-11 13:58:53.221 1835 3789 D DhcpClient: Renewed lease: IP address 172.28.88.48/21 Gateway 172.28.88.254 DNS servers: [ 114.114.114.114 172.28.1.28 8.8.8.8 172.28.1.26 ] Domains dw.gdbbk.com DHCP server /1.1.1.1 Vendor info ������ lease 3600 seconds

Line 31133: 09-11 13:58:53.226 1835 3789 D DhcpClient: Scheduling renewal in 1799s

Line 31134: 09-11 13:58:53.226 1835 3789 D DhcpClient: Scheduling rebind in 3149s

Line 31135: 09-11 13:58:53.226 1835 3789 D DhcpClient: Scheduling expiry in 3599s

以上是发起请求后有正常收到Ack的情况,但是接下来设备发起了请求并没有收到Ack,所以导致设备一直不断的去发起DHCP请求,而且此时设备并没有网络切换广播,并且设备本地判断网络是正常可用的,原因是设备到路由器的网络是通的,只是路由器到远程服务器的链路是不通的:

33540: 09-11 14:28:54.007 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 33540: 09-11 14:28:54.007 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 33557: 09-11 14:28:59.012 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 33557: 09-11 14:28:59.012 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 33585: 09-11 14:29:04.021 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 33585: 09-11 14:29:04.021 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 33701: 09-11 14:29:12.088 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 33701: 09-11 14:29:12.088 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 33724: 09-11 14:29:28.065 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 33724: 09-11 14:29:28.065 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 33779: 09-11 14:30:03.317 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 33779: 09-11 14:30:03.317 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 33815: 09-11 14:31:13.838 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 33815: 09-11 14:31:13.838 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 51658: 09-11 14:33:33.786 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 51658: 09-11 14:33:33.786 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 53369: 09-11 14:35:32.229 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 53369: 09-11 14:35:32.229 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 53714: 09-11 14:37:46.146 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 53714: 09-11 14:37:46.146 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 55611: 09-11 14:40:02.569 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 55611: 09-11 14:40:02.569 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 57692: 09-11 14:42:01.271 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

Line 57692: 09-11 14:42:01.271 1835 3789 D DhcpClient: Unicasting DHCPREQUEST ciaddr=172.28.88.48 request=0.0.0.0 serverid=null to /1.1.1.1:67

在这段时间内,TCP连接是一直报java.net.NoRouteToHostException: No route to host异常,如果TCP当前正处于连接中,那么DHCP的更新可能会导致TCP断线,等到后面设备发起的DHCP请求收到Ack之后,TCP连接立刻恢复正常,并且此时收到了网络切换广播,针对以上问题,如何恢复呢?搜索网上资料是说应用程序每次重新建立一条新的TCP的时候会触发设备请求DHCP Server,但是从我们的log查看发现并没有,请求DHCP Server没有Ack后设备会间隔重试,当设备被触发亮屏后,网络马上恢复正常,DHCP请求也收到Ack,同时也收到网络切换广播

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_31202821/article/details/117295546

智能推荐

中望cad自定义快捷键命令_很多CAD大神都善用专属快捷键,掌握AutoCAD自定义快捷键受益匪浅...-程序员宅基地

文章浏览阅读1.2k次。阅读完,如果觉得有用,那么点击"关注"和点赞是对作者的一种尊重和鼓励。版权所有,抄袭必究。作者的新书《AutoCAD 2020中文版入门-进阶-精通(第6版)》已经正式出版,敬请关注,谢谢。内容提要:在实际工作中,掌握了AutoCAD快捷键可以提高绘图效率。那么有没有想过除了AutoCAD系统自身的默认快捷键之外,还可以为自己常用的工具命令设置专属个人的快捷键呢?本文专门介绍AutoCAD自定义快..._中望cad2021机械版快捷键

kohana简介-程序员宅基地

文章浏览阅读108次。2019独角兽企业重金招聘Python工程师标准>>> ..._kohana是什么洗发水

QT中UDPSocket丢包问题_qt udp 丢包考核-程序员宅基地

文章浏览阅读8.9k次,点赞4次,收藏43次。Qt中的QUdpSocket发生严重丢包现象,在Linux下使用while死循环接收来解决,但存在CPU占用率太高的问题。_qt udp 丢包考核

Python中出现UnboundLocalError: local variable ‘xxx‘ referenced before assignment情况的解决方法_unboundlocalerror: local variable 'sentencepiece_m-程序员宅基地

文章浏览阅读2w次,点赞14次,收藏11次。UnboundLocalError: local variable 'xxx' referenced before assignment在函数外部已经定义了变量n,在函数内部对该变量进行运算,运行时会遇到了这样的错误:主要是因为没有让解释器清楚变量是全局变量还是局部变量。有时候在其他模块声明该变量,在本模块使用时也会出现。那么问题就来了,出现这个问题我们就要考虑程序是按照全局变量,就是经过函数运算到函数外面还生效,还是按照局部变量在函数外生效。第一种,当全局变量来看,就是使用global..._unboundlocalerror: local variable 'sentencepiece_model_pb2' referenced befor

chatgpt VS 文心一言使用对比实测_chatgpt和文心一言-程序员宅基地

文章浏览阅读5.4k次。chatgpt VS 文心一言使用对比实测_chatgpt和文心一言

thermal的gov_bang_bang governer_thermal bangbang-程序员宅基地

文章浏览阅读838次。thermal gover 有五种,我们这里以gov_bang_bang.c 为例gov_bang_bang是控制风扇的。之后两种状态,即风扇开和关,并没有提供调整风扇转速的方法.static struct thermal_governor thermal_gov_bang_bang = { .name = "bang_bang", .throttle = bang_bang_contr_thermal bangbang

随便推点

Java面试的问题_java中的两个重载函数,如果只有几行代码不同,改如何设计-程序员宅基地

文章浏览阅读467次。1、一个".java"源文件中是否可以包括多个类(不是内部类)?有什么限制?可以有多个类,但只能有一个public的类,并且public的类名必须与文件名相一致。2、Java有没有goto?java中的保留字,现在没有在java中使用。 3、说说&和&&的区别。&和&&都可以用作逻辑与的运算符,表示逻辑与(and),当运算符两边的表达式的结果都为true时,整个运算结果才为true,否则,只要有一方为false,则结果为fa_java中的两个重载函数,如果只有几行代码不同,改如何设计

JavaScript之javascript概述_简述什么是javascript以及javascript的作用-程序员宅基地

文章浏览阅读1.9k次。一、初识JavaScript1、JavaScript是什么javascript是一种运行在客户端的脚本语言(Script是脚本的意思)。脚本语言:不需要编译,运行过程中由js解释器(js引擎)逐行来进行解释并执行。现在也可以基于Node.js技术进行服务器端编程。2、JavaScript的作用表单动态校验(密码强度检测)(JS产生最初的目的)网页特效服务器端开发(Node.js)桌面程序(Electron)App(Cordova)控制硬件-物联网(Ruff)游戏开发(cocos2d-_简述什么是javascript以及javascript的作用

js dom node.children与node.childNodes区别_node.children和node.childnodes的区别-程序员宅基地

文章浏览阅读1k次。不同点:node.children不会取到节点下面的TextNode但是node.childNodes会取到 共同点:两者都是集合类数组,可以通过索引的方式取到值也可以用for循环遍历..._node.children和node.childnodes的区别

HTML、CSS知识点总结,浅显易懂。_sm学习 html-程序员宅基地

文章浏览阅读7.2k次,点赞25次,收藏116次。一,html+css基础1-1Html和CSS的关系学习web前端开发基础技术需要掌握:HTML、CSS、JavaScript语言。下面我们就来了解下这三门技术都是用来实现什么的:1. HTML是网页内容的载体。内容就是网页制作者放在页面上想要让用户浏览的信息,可以包含文字、图片、视频等。2. CSS样式是表现。就像网页的外衣。比如,标题字体、颜色变化,或为标题加入背景图片、边_sm学习 html

vue中$bus的用法及$emit、$on、$off的使用_this.$bus.$on-程序员宅基地

文章浏览阅读9.5k次,点赞7次,收藏32次。vue中 $bus 一般与 $emit、 $on、 $off 连用,一般用在任意组件间的通信,即 $bus 用来传递非父子关系的数据。如两个组件之间传递数据:子组件1子组件21、$emit2、$on注意:$emit 和 $on 的事件必须在一个公共的实例上,才能够触发。3、实例事件实例事件就是在构造器外部调用构造器内部的数据。4、实例在Student组件中提供数据给另一个School组件在School组件中使用事件总线,接收数据。School组件想接收数据,则在School组件中给 $bus绑_this.$bus.$on

2022第二届网刃杯writeup_2022年网刃杯wp-程序员宅基地

文章浏览阅读931次,点赞3次,收藏4次。文章目录MISC玩坏的winxpICSeasyiec喜欢移动的黑客carefulguyxyp07re定时启动ez_algorithmRe_functionfreestylewebSign_inuploadez_java这次re做了4个,ICS做了3个,wp直接贴战队的了。MISC玩坏的winxp1、虚拟机加载硬盘2、Magnet AXIOM收集信息发现了网页浏览历史中的特殊网址。3、meiren.png中两次binwalk可以得到一个需要密码才能解压的zip,并且提示寻找戴围脖的软件。4、尝试_2022年网刃杯wp

推荐文章

热门文章

相关标签