Detection of port "live" state or activity happens well below any protocols that run on the Ethernet interface. At the Ethernet physical layer an electrical device can detect whether a connection is made long before any data packets are sent. It can then notify the OS of cable connection and the OS can then start sending packets.
At the electronic medium level the Ethernet PHY is regularly attempting to send a series of pulses over the wires. This process is known as Autonegotiation.
These link integrity test (LIT) pulses are sent by Ethernet devices when they are not sending or receiving any frames. They are unipolar positive-only electrical pulses of a nominal duration of 100 ns, with a maximum pulse width of 200 ns,[13] generated at a 16 ms time interval with a timing variation tolerance of 8 ms. A device detects the failure of a link if neither a frame nor two of the LIT pulses is received for 50-150 ms. For this scheme to work, devices must send LIT pulses regardless of receiving any. In the autonegotiation specification these pulses are called normal link pulses (NLP).
So on a regular basis both sides of an Ethernet connection, regardless of whether the cable is connected, is sending a pulse out. If one side or the other receives a pulse then it becomes aware of a "good" connection and then proceeds to negotiate link speed, duplex and other physical link characteristics with the other side via another series of electrical pulses.
Once both sides have negotiated a valid physical connection then the Ethernet chip will be able to signal to it's drivers within the operating system that a connection has been established.
After the connection is up and known good then the operating system can start transmitting Ethernet packets, doing DHCP, ARP and establishing connections to other computers and devices.