Is the router always broadcasting "I'm here" (say, every period of time) and the computer listens or the router listens and once the computer broadcasts "is there a router here?" It responds? It sounds like a silly question but I can't find an answer. Although I do know that when the computer already knows of the existence of the router it makes the first request for an IP address.
Looking at your question it looks like you're confusing DHCP and routing.
To be clear, they both accomplish different tasks and really have nothing to do with each other. DHCP is a way to dynamically assign IPs to clients. Routing allows you to get from one network to another.
To answer your question.. There are really two ways in which your computer will know there is a router on the network. Either because you have manually assigned an IP address/subnet mask with a default gateway (default gateway being the router), or because the computer has been set to request an IP via DHCP and within the DHCP offer it received from the server it contained a default gateway for the client to use.
The client will not attempt any communication with a router until it has an IP address and default gateway configured (again manually or via dhcp). The computer will then look at its own IP address and subnet mask to determine if the IP address it is trying to communicate with is on its local network. If it is then it will attempt to send the data straight to the device and if it is not then it will look at its configured default gateway (router) and send it there. The router will then send the traffic to the destination because it has a route, or to another router that might know where the destination network exists.
With IPv4, a computer doesn't really know about a router. A host will have a configured gateway, to which it will send any traffic destined for a different network. The gateway is probably a router, but not necessarily. The gateway is either manually configured, or assigned via DHCP. The host doesn't have a configured gateway until one is either manually or dynamically assigned. That means that it cannot communicate to a different network until one is assigned.
On the other hand, IPv6 has added ND (Neighbor Discovery), and part of ND includes RAs (Router Advertisements). Routers can be configured to advertise their existence, and the local network prefix. This allows IPv6 hosts to configure themselves without DHCP, although there is a version of DHCP for IPv6.
Modern Ethernet controllers have link state detection. They can detect when a link is established to their Ethernet port.
The situation is a bit different for IPv4 and IPv6. First the IPv4 scenario.
When the Ethernet cable is plugged in the OS detects this through link state detection. If the interface is configured for DHCP then the client will send out a DHCP request. In a typical home/small buisness network the router will run a DHCP server which will assign the client an IP address and also tell the client what subnet mask, default gateway and DNS servers to use. In a larger network the router and the DHCP server may be on different devices.
If no DHCP server is found the client may keep trying and/or it may assign a local IP using "automatic private IP addressing".
IPv6 is a little more complicated. Unlike IPv4 nodes IPv6 nodes always have a link local address which they assign themselves. For Internet access they will need a global scope address and related settings. There are three main posibilities for IPv6 autoconfiguration.
- RAs only. The router sends out advertisements telling clients what prefixes are on the link and what networks the router offers routes to (including a default gateway if applicable). The advertisements are sent to all IPv6 nodes on the link (this is technically classed as a multicast but practically its the closest thing IPv6 has to a broadcast) and inform the clients of the prefix they should be using and the addresses of routers. Clients can send out a request to prompt a RA to be sent sooner than the router would have sent it. Clients construct their own IPv6 addresses based on the prefix. Older systems used a single address based on their MAC address, more modern systems with privacy extensions will use multiple short-lived addresses. Unfortunately RAs do not provide DNS server configuration, so on their own they are inadequate for autoconfiguration of IPv6 only clients.
- RAs with stateless DHCPv6. Here addressing is handled by RAs as above but DNS server details (and possiblly other less important configuration) is handed out by a DHCP server in response to a client request.
- Stateful DHCPv6, this works much like DHCP for IPv4.
The best appropriate answer to your question is DHCP(Dynamic Host Configuration Protocol). When a computer or any network device connect to the network, it sends DHCP Discover Message with broadcast IP adress(255.255.255.255) to obtain its own IP adress. A DHCP server receiving a DHCP Discover Message responds to the client with an DHCP Offer Message. If we look closer to this message, we will look router option field in it. Here it is, hosts or any network device who want to obtain IP adress actually learn the IP adress of default gateway from this field.
When your PC is turned on, it uses the DHCP protocol to request an IP-address and network settings. Every time a packet is then sent from the computer it will send it to the default gateway of the router. The router is not consistently pinging out 'hello im here' more like the host will direct traffic when it needs to. - Hope this clarifies it.
In the "conversation words".
You turn on your Computer and the Computer detects that there is a cable connected to your NIC.
Computer thinks "NICE! I'm connected to a network - is their a DHCP server online, so I know where I am??"
Computer sends out DHCP request.
Router/DHCP Server gets this request and says to the Computer:
"Hey! You are and this is your Netmask, your default gateway and other Informations - Welcome to the network!"
This only works if your NIC is configured for DHCP.
The router does not broadcast that it is there as a default gateway. A DHCP server does respond to a shout out (broadcast) from the endpoint though. Part of the DHCP response is the IP address of the default gateway (the router). Most routers have built in DHCP servers which are disabled by default. Many server/I.T. admins rather use Windows Server DHCP.