Author Topic: Finding device with DHCP IP address  (Read 9757 times)

Offline Richard

  • Newbie
  • *
  • Posts: 44
    • View Profile
Finding device with DHCP IP address
« on: June 27, 2009, 04:07:15 AM »
Hi, all.

Imagine that you send a uTasker device -- e.g., an intelligent coffee maker that has a web server on port 4388 -- to your friend to install in his house.  Your friend knows almost nothing about networks, but someone has already set up an Ethernet network for him, so all he has to do is plug in the coffee pot.  He would like to see the coffee pot's web page on his PC (via the LAN), and you'd like to see the web page on your PC (via the Internet). 

What I don't understand:
1) how will your friend know what IP address was assigned to the coffee pot by his DHCP server?
2) how will you convince his router to accept traffic from you for port 4388 and forward it to the coffee pot?  I.e., how do you open port 4388 through the router's NAT?
3) Number 2 comes into play only if you already know your friend's public IP address, which is most likely one that is assigned dynamically by his ISP and subject to change.  There are solutions for this, see e.g., <http://www.dyndns.com/>.  Some routers have a built-in update client -- the module that sends "here-I-am" to the dynamic DNS service at appropriate intervals -- but not all do.  Is there uTasker code for an update client?

Given the push to attach everything in the world to the Internet, this problem must have been addressed somewhere, but I haven't seen where.  I'd appreciate any hints.

Thanks,
    Richard

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3069
    • View Profile
    • uTasker
Re: Finding device with DHCP IP address
« Reply #1 on: June 27, 2009, 01:06:33 PM »
Hi Richard

The first time the coffee machine gets an IP address from the DHCP server no one will know what address it is apart from the DHCP server and the coffee machine (unless the Ethernet is sniffed). It is possible to display the obtained address in a menu, if it has a display (it will generally remain the same value forever in a small home network). However in this situation it is easiest to use NetBIOS. Then the coffee machine can be contacted by its name rather than its IP address - this works well with DHCP together since DHCP also supplies the correct subnet-mask, which is important for NetBIOS, as it uses sub-net broadcasts (these must match accurately to be accepted).  See http://www.utasker.com/forum/index.php?topic=107.0 for NetBIOS details.

There are (at least) 2 possibilities of allowing the coffee machine to be contactable via the network's public IP address:
- set the coffee machine's IP address in a DMZ (demilitarized zone) [router configuration]. This allows the machine to be fully exposed to the Internet traffic addressed to the public IP.
- add its TCP port / IP address as a virtual server [router configuration]. This allows it to be contacted on the standard port number 80 (externally) but internally exist on 4388. Or any other combination.

The DynDNS is a topic that has been mentioned a number of times. If the router has an update client internally then this is probably no problem since it is no longer an issue to the coffee machine. In case the coffee machine needs to be able to do this itself it will need to implement the update client, which is essentially probably quite simple(?). I never actually tried but did hear that several people planned it as part of their project - unfortunately I never heard back about their experiences. Presumably a DynDNS account is also required and possibly the coffee machine needs to be configured correctly to operate with it (possibly hard coded).

Anyone already done it??

Regards

Mark


Offline Richard

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: Finding device with DHCP IP address
« Reply #2 on: June 29, 2009, 05:11:27 AM »
Thanks, Mark, for your amazingly prompt response.

I may have to check out the NetBIOS option if I can't figure out another way of finding the DHCP-assigned local address.  My suspicion is that in solving the rest of this riddle, I'll also find another solution to discovering the local IP address.

My friend's lack of network prowess precludes his performing any router configuration, so both the DMZ and the virtual server options are problematical, as is the assumption that the coffee pot will end up with the same IP address forever.  Imagine the non-deterministic scramble of assigning local addresses to nodes after a major power failure, especially if some laptops and other net-aware appliances on the LAN have been added or removed since the coffee pot was installed.

I can easily set up a free DynDNS account for my friend, but a coffee-pot-based update client may not be so simple to write.  The issue is that DynDNS http://www.dyndns.com/support/clients/ explicitly states, "An update client should only send updates when a change is detected, but some clients send updates at regular intervals (e.g. hourly) whether or not an update is necessary."  How would the coffee machine know if the external IP address changed, i.e., when an update were needed?  The router would know, but if there is any standard way to have a router tell its local clients what its external address is or to have it send some kind of a message when this address changes, I don't know what it is.  And without knowing the external address, the coffee machine would presumably try something like sending out updates based on a timer, which DynDNS explicitly mentions as "abusive updates" and for which they will block the coffee pot from using their service.

I'm going to work on this some more, perhaps after doing some other things that are pressing.  But from your response, I infer that there is no obvious solution.

Oops, maybe there is!  I just heard about "Universal Plug and Play" that looks promising.  From its wikipedia article, it appears that it's quite new: "UPnP was published as a 73-part International Standard, ISO/IEC 29341, in December, 2008."  [Or maybe not, since the "UPnP Vendor's Implementation Guide" is dated 5 Jan 2001.]    And, with 73 parts, there's probably a lot to wrap one's head around.  Furthermore, as I read the article, it seems that the protocol is not really ready for prime time.  There seem to be major security flaws that would have reasonable people disable it.  However, this does mean that a lot of people are working on the problem, and again that it has no obvious solution.

Has anyone looked into implementing UPnP on a uTasker device?

Cheers,
    Richard

Offline alager

  • Jr. Member
  • **
  • Posts: 92
    • View Profile
Re: Finding device with DHCP IP address
« Reply #3 on: September 01, 2009, 12:32:33 AM »
There is another option....and that is to have the coffee pot initiate the communication.  Of course this requires some additional interfacing: server to accept the coffee pot communication and an interface to the web browser.

Aaron

Offline Richard

  • Newbie
  • *
  • Posts: 44
    • View Profile
Re: Finding device with DHCP IP address
« Reply #4 on: September 01, 2009, 06:13:41 AM »
Thanks for the replies.  I've put this on the back burner for now, but I'll look at the "Session Traversal Utilities for NAT" (STUN) protocol when I get back to it.  See RFC 5389, http://tools.ietf.org/html/rfc5389, and http://en.wikipedia.org/wiki/STUN for more information.

Cheers,
    Richard
« Last Edit: September 01, 2009, 06:31:03 AM by Richard »

Offline paulk

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Finding device with DHCP IP address
« Reply #5 on: November 20, 2009, 04:17:06 AM »
Richard,

I'm also interested in this.  You may need to look into UPnP, as I believe it will allow you to talk to the router and haveit to open certain ports for you.  From the outside world, if you know the address of the router (via a dynamic DNS setup), and a unique port, you won't need to know the IP address of the internal client.

I've also wondered how device discovery works, for example the "Detector" utility from Lantronix.  It is designed specifically for this purpose: ie: the Lantronix modules use DHCP (or sometimes not even), but can still be detected (and in fact configured) via this utility.  I guess somehow it talks via the MAC address, and bypasses TCP until the device has an actual address.

Let us know if you get anywhere with this, and I will do likewise, as for devices without a display, having a "detect" utility would be important (although NetBIOS may be a nice compromise).

Offline thamanjd

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Finding device with DHCP IP address
« Reply #6 on: November 26, 2009, 07:43:17 AM »
This is an interesting topic. My two cents even tho youve put it on the backburner.
I asked myself the same question when we made our first product using utasker.

What i ended up doing was two things:

One: there is a single seven segment display and four buttons for reading and modifying the
IP ADDRESS, SUBNETMASK & GATEWAY IP

Two: The devices periodically (every 1 to 3 minutes) advertise themselves using a UDP broadcast packet on a particular port. This could also use multicast packets if you dont like broadcast packets. A utility computer can also prompt for these advetisements with a "Request" packet on the same port.

This however does require a PC software utility and can only be used on the network where the devices/utility PC are reachable by UDP broadcast.

The devices also are given a third propietary address with a DIP switch. As long as the device is reachable, you can change the IP addresses using a UDP broadcast because the broadcast can tell a device of DIP switch address xxx to become IP address xxx.xxx.xxx.xxx.

This works as long as the DIP switch addresses are all different.
But even if there were one or two utasker devices with the same dip switch, it shows up on the software utility that sees the devices being advertised over UDP broadcast since they are also advertising their MAC Address.

I take it if your friend has a network that they have a computer?
Is it possible to find a simple UDP listener program ( i think i found one on sourceforge), give it to them, get them to enter the appropriate port number to listen two and the advertisements appear in the incoming window in plain text? IP=?

I've also played around with Lantronix. I think you're right, i think you could talk to them even if they weren't on your network. But i think you needed to know their mac address first? does that sound right? I haven't played around at the ethernet level but i suspect you can do some simple broadcasts/multicasts at that level to do discovery/advertisements.

What about getting it across the net?
Add an edit box in the web pages to put an IP or IP's to direct periodic advertisements to and set it up beforehand.
The friends router/modem should let this through but you'll have to make sure it gets through any firewall at your end.
Again you wouldnt necessarily have to make a software utility program for yourself if your happy just checking it with a freeware udp/tcp listener

JD








Offline paulk

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Finding device with DHCP IP address
« Reply #7 on: November 30, 2009, 10:27:50 PM »
No, the Lantronix software finds *any* Lantronix module.  I think it may look for any device that has its own vendor specific MAC address start.  You don't need to know anything about the module, it just has to be (physically) on the same subnet.

Incidentally, I recently found that Luminary Micro has an identical utility for finding the IP address of its boards on the network.  Its called "finder" and its included in the StellarisWare package (with source code).  I have to take a closer look, but it looks like it uses some sort of custom "protocol" to sniff out modules that are on the network.  Again, there may be a presumption that the MAC address is specific to the vendor.

Offline thamanjd

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Finding device with DHCP IP address
« Reply #8 on: December 02, 2009, 01:38:23 PM »
Ive got the Lantronix tool. I might have the Luminary tool. If i think of it one day at work i'll run wireshark at the same time and see what happens.

MAC addresses are offered by IEEE in two ways. OUI and IAB.

With an OUI -Organisationally Unique Identifier you pay for the first three octets of a MAC. The organisation is then free to dole out their addresses using the last three octets.
Of course when the organisation runs out of OUIs they might buy another OUI or maybe if they think the MAC address is old enough - recycle it. I wonder what the expected use is?

With an IAB, if you don't think you'll use so many MAC addresses, you can buy a block. The first three octets (OUI) technically belong to the IEEE. The next 12 bits are also assigned. This leaves you with 12 bits. So you're really just buying 4096 sequential MAC addresses.

In both cases the organisation name associated with a MAC address is in a database on the IEEE site that is searchable.
However you can pay a bit more so that your company name is kept private.

So identifying their own MAC addresses should be straight forward if they are using an OUI or OUIs. I dont know if identifying the MAC address as their own is important or not though.


I'll see if i can find the one lantronix device ive got hanging around at work tomorrow and try it out.
JD

Offline JuKu

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Finding device with DHCP IP address
« Reply #9 on: December 03, 2009, 08:45:31 AM »
I have no idea about how Lantronix software works, but a co-worker suggested the following: If your user case allows to run a tool on a PC, it would be simple to either send a some kind of broadcast message to the local network asking all BrandX devices to identify themselves to the sender. Alternatively, you could brobe some obscure port and if you get correctly formatted answer, you found the device. There is only 254 addresses to brobe, that doesn't take very long.

Now, if I just want to type something like "local.coffeemachine" on a browser, things get hairy.

Offline paulk

  • Newbie
  • *
  • Posts: 45
    • View Profile
Re: Finding device with DHCP IP address
« Reply #10 on: December 10, 2009, 11:15:36 PM »
As a small update, I have done some more research into this topic.  It looks like the Luminary Micro implementation requires that the "target" is running a "locator" process.  This is actually included in the /StellarisWare/utils directory as source.  Then the "finder" application appears to send a broadcast query and looks for a response from this process.

This method works well, but seems to be overkill if you can use NETBIOS.  In that case, its as simple as setting it up in uTasker and typing "ping (whatever)", where that is the name you specified.  The ping command will resolve the netbios name to an IP address and display the results.

The trick with the Luminary approach is that the device MUST be on the same subnet.  If it doesn't successfully obtain an address (or uses AUTOIP to grab a "default" address), this method won't work.

The Lantronix utility is somehow able to find a device even if it hasn't obtained an IP.....

Offline mike.newsome

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Finding device with DHCP IP address
« Reply #11 on: February 09, 2010, 01:09:40 PM »
I don't know about the Lantronix method, but while trying to solve the same problem (with the difference that I may have several devices on my network segment, I came across

http://kelley.ca/wordpress/2008/10/24/digi-connect-me-discovery/ and
http://qbeukes.blogspot.com/2009/11/advanced-digi-discovery-protocol.html

which describes the protocol used by Digi for their modules. It essentially is a broadcast message to port 2362 containing identifier bytes 'D' 'I' 'G' 'I' as the first four. The rest of the packet can set up ip addresses etc.

Worth a thought

Mike