How does a router detect a connected device ? (ENC28J60 module)

5,717

All routers have at least two network interfaces. For the sake of this answer, assume a typical home setup where the router has only two interfaces - the WAN ethernet, and the LAN + wireless ethernet (typically bridged together so it's effectively a single interface).

What happens is the router issues a DHCP request on its WAN interface, and then the ISP's DHCP server responds with public IP information. The router then uses that to configure the IP of the WAN interface.

The router itself typically runs its own DHCP server which hands out IPs to those connected via the LAN. It does not give an IP to the WAN interface at all.

The alternative is APIPA, where the device picks a random IP in the APIPA range, issues an ARP to see if anyone else is using it, and then starts using it if no one replies. This is bad if you want to use any subnet other than the APIPA subnet.

IPv6 autoconfiguration works similarly.

I don't have a lot of experience on Ardunio but it sounds like you need a DHCP client functionality somewhere in there.

Share:
5,717

Related videos on Youtube

Bouncing_Back
Author by

Bouncing_Back

Love Making Not Consuming

Updated on September 18, 2022

Comments

  • Bouncing_Back
    Bouncing_Back almost 2 years

    Background:

    I am actually an Arduino beginner and learning to connect one to the internet via Ethernet.

    I'm not using the more commonly used (much easier) Ethernet shield (based on the Wiznet W5100/W5200 chips) but one that uses the ENC28J60 chip - the difference is the TCP 'handling(?)' has to be done by software, whereas the W5100/W5200 chips have it built-in by the hardware).

    I'm using libraries which handle the grunt work with code. I do not understand fully, but have already suceeded in setting up the Arduino as a web server as well as a web client.

    The Issue:

    My problem is consistency. More often than not, the Arduino+Ethernet module is NOT detected by the router and hence will not function because it does not get an IP address. It is not a LAN cable issue; when I connect that to the computer, it shows up in the Client Table of the router, but when I connect it to the device (i.e. Arduino via Ethernet module) it does not show up.

    My question is: how does a router detect a computer/connected device? A search on Google gave me results for "how does a computer detect the router?"; I want it the other way around.

    I would like to have a general understanding of how a router does the detection, because I can't determine whether the failure to connect is at the device side, or the router side.

    I'm quite ignorant to technicalities with networking, but am familiar with concepts of PING-ing and DHCP vs. fixed IP addresses - all of which are precluded by having an actual connection - which is where my stumbling block is. I would appreciate any layman explanation or at least some troubleshooting tips to find out where the problem really is.

    • lorenzog
      lorenzog over 10 years
      Could you post a link to which libraries are you using? Have you googled for the name of your chip + arduino + router? IIRC Arduino shares its Ethernet shield with USB; do you have some devices that are using lots of USB bandwidth, perhaps?
    • Bouncing_Back
      Bouncing_Back over 10 years
      the shield uses the SPI bus, while the USB shares the UART. i'm still quite new to Arduino as well, so don't "take that to the bank" :) i don't think the library is the issue, i've managed to get it to work one time but don't know why it doesn't now - i think it's hardware related which is why i'm trying to understand what is going on in the cables themselves.
  • Daniel B
    Daniel B over 10 years
    Indeed. The important point is: DHCP is a "pull" service. It does not detect the client. Quite the contrary, in fact. The (purely informational!) list in most routers is also populated utilizing ARP sniffing.
  • Bouncing_Back
    Bouncing_Back over 10 years
    thanks for your response, i found it useful but can't vote it such. it helped give me a layman's understanding of what is going on between those wires, and to the outside too ! will have to look up what ARP is in more detail :)
  • Bouncing_Back
    Bouncing_Back over 10 years
    the Arduino doesn't show up - which prompted the question to troubleshoot why it's failing, is it the router's "fault" or the Arduino(and module) - it did show up one time when the connection worked - but am trying to figure out what changed since. thanks for "pull" service and "ARP sniffing" - this should help me to further study the situation.
  • Bouncing_Back
    Bouncing_Back over 10 years
    thanks for link - that's exactly sort of link i was hoping to get - although not for Linux but getting better picture fm everyone's response of what happens b/n router & client, perhaps nt really what i should b looking for. yr statement of "no detection going on" REALLY HELPS my understanding - i think can conclude problem is on Arduino side, not router. just noticed my question was edited, i did think perhaps it was issue of insufficient voltage coming from the module - LED at jack does light up & there are blinks showing activity, but perhaps not high enough voltage for the router to "hear"
  • Bouncing_Back
    Bouncing_Back over 10 years
    sorry for above "txt language" - my comment went overboard and i hacked away trying to get under the character limit - i should've just broken it into two comments - anyway, thanks - i think your answer is the closest to what i need, but everybody's answer helped what was probably a rather wide-ranging query.