This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of React Cookbook: Recipes for Mastering the React Framework and have David Griffiths & Dawn Griffiths on-line!
See this thread for details.
Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

reset DHCP

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to reset/refresh/reboot DHCP using Java code ? The software is being developed under AndroidStudio.
 
Saloon Keeper
Posts: 24188
166
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think what you are looking for is a change of lease, since I don't think that Android is going to be doing an administrative function on someone else's DHCP server.

I doubt it's possible, since the DHCP lease is held by the entire (Android) OS, not by one specific application. I think the closest you could get would be to disconnect the device from the network and reconnect it and that's probably something you'll only be able to do from the Android Settings app.

Since the same lease applies to ALL connections on a given network interface, it would be potentially disruptive to other Android apps if you pulled the network out from under them.
 
Igor Janick
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am not looking for a possibility of tampering within DHCP settings.
It seems it is being reset when one switch off then swith on the device.
How to do it without it ?
 
Tim Holloway
Saloon Keeper
Posts: 24188
166
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do not understand.

When you power off an Android device, go into Airplane Mode, or otherwise disconnect it from a network, then I would expect that it would try to send a "free my lease" command back to the DHCP server. For various reasons - including lost network - that may or may not succeed, however.

Regardless, when you re-connect to a network, the device should be sending out a new DHCP client request to obtain a IP address. DHCP provides the mapping between hardware MAC addresses and IP addresses, and in my experience, a DHCP server will typically respond with the same IP address that was last used for that MAC address. That's not guaranteed, however, especially for networks that see a lot of devices frequently connecting and disconnecting.

Note also that a computer (including an Android device) may have more than one active Network Interface at a time. For example, a cell phone might connect on both the cellular network and on a local WiFi network. Each of those networks would have an independent DHCP server and subnet. In the case of cellular network services it could get very interesting as you move from tower to tower. I don't know how far you'd have to move to end up on a different subnet. Although if they use the 10.x.x.x subnet you could cover a lot of a country since 24 milllion simultaneously connected users would be significant. Then again, you could simply use IPV6 and I'm not even sure that IPV6 even has those constraints.

So as a general rule, you're best off just letting the OS do its thing.
 
Igor Janick
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.
"... the device should be sending out a new DHCP client request to obtain a IP address. DHCP provides the mapping between hardware MAC addresses and IP addresses ..."
is the goal I would like to achieve.
Besides it is not a phone but payment terminal working under Adroid.
 
Tim Holloway
Saloon Keeper
Posts: 24188
166
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The device type really doesn't matter.

In your device Setting app there will typically be a list of network-connectable devices, sometimes including Buetooth and/or InfraRed. Each device comes with customizable options including auto-reconnect, and for Internet-capable devices, the ability to use DHCP or a static IP address, where DHCP is the default option. The MAC address may be randomizable for security reasons, in which case getting the same IP address on each subsequent re-connection may be a problem.

When a network interface is connected to a network, whether by manual connection request or auto-reconnect, if it has not been set to use a static IP address it will broadcast a UDP DHCP request packet. The DHCP server for that subnet will hear it and commence the process of assigning an IP address to the device network interface. It's all automatic, and there's nothing you need to do to make it happen.

It's also the exact same process that desktop computers use, whether they use wired Ethernet cables, WiFi, or both.
 
Igor Janick
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Customers's explanation:

The matter is to switch off The Internet.
Temporarily free the IP address.
Then switch on again.
They assume that the DHCP server will automaticallu do the rest.


We have to solve the above using Java code.
 
Tim Holloway
Saloon Keeper
Posts: 24188
166
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, as I said, an Android device can have multiple network connections, so to truly "switch off the Internet", you'd have to disconnect all of them. But since you only have to release "the" IP address, and not all the IP addresses the device holds, I'll take that as meaning that you're only interested in one of them.

I'm curious as to what the customer expects all this rigamarole to accomplish in practical terms, but it's not essential. And yes, disconnecting and reconnecting will result in a DHCP request on reconnect, although unless MAC ID scrambling is enabled, odds are that the exact same IP address will be given as was just released.

You may find this API useful: https://developer.android.com/reference/android/net/wifi/WifiManager
 
Igor Janick
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Trying to solve I use hint from: https://stackoverflow.com/questions/26380227/android-l-data-turn-off-error

with mentioned permission in AndroidManifest.xml

However I still receive:



Any hint would be appreciated.
 
Tim Holloway
Saloon Keeper
Posts: 24188
166
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's not sufficient information for me to tell anything.

However, from youc link I did note that the ability to control the network seems to be reserved for System Apps. And my understanding is that System Apps are permanently burned into the device ROM. Meaning that if you aren't the device manufacturer you can't install your own System App.

As I've said before, turning off the network from one app can be incredibly rude to all the other apps running on the device, so I'm not surprised that there would be limitations.
 
Igor Janick
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Problem seems to be solved by enabling then disabling Airplane Mode. A feature provided by the device producer.
 
Tim Holloway
Saloon Keeper
Posts: 24188
166
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Igor Janick wrote:Problem seems to be solved by enabling then disabling Airplane Mode. A feature provided by the device producer.


Yes, that will do it. Anything that switched off the network interface. You could simply turn WiFi on and off also.
 
Igor Janick
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I know the airplane mode disables also GPRS (and other cellular connections) together with Bluetooth.
 
Tim Holloway
Saloon Keeper
Posts: 24188
166
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it's called "Airplane mode" because there was concern that having an unapproved radio system operating onboard an airplane could possibly cause interference to sensitive flight navigation and control instruments.

Airplane mode is intended to shut down ALL radio emissions from the device. That includes - but is not restricted to - the cellphone radio, the WiFi Network Interface, Bluetooth, Near-field Communications (NFC), and anything else that might generate radio-frequency interference. That includes receive-only devices like FM radios, and possible GPS since superheterodyne oscillators can generate minute radio transmissions of their own.

As far as RFI goes, digital electronics of any sort can emit all sorts of radio-frequency garbage, but modern-day airplane mode is likely to allow low-grade noisemakers as long as they meet FCC/FAA standards for low-power radio emissions.

The initial concern about RFI noise in airplanes actually came from laptops, but these days, mostly it's about cellphones. In actuality I don't know of any incidents where computer electronics ever interfered with any air flight, but it at least gave airlone the excuse to sell in-flight phone services.
 
crispy bacon. crispy tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic