If I already have a physical address (MAC), what is the usefulness of a logical address (IP)?
Why do networks need both types of address to work?
If I already have a physical address (MAC), what is the usefulness of a logical address (IP)?
Why do networks need both types of address to work?
This question does not seem to be about programming, but here are some curiosities that might help you to understand better:
MAC Address
It is a unique identification that each network card has, whether it is wired or wireless. The MAC acts on the Link layer of the OSI model and is used by (traditional) second layer switches to deliver the packets to their destinations.
IP Address
Identifies a host (computer, router, printer, etc.) and acts on the network layer of the OSI model. The IP address is used by routers to forward packets to their destinations.
Why do we need both?
Because the IP address is also responsible for identifying which network the hosts belong to and that portion of the network is defined by the IP subnet mask. The MAC does not know anything about networks.
Important Detail
As a packet travels over the network, the source and destination IP addresses are always the same, but the source and destination MAC addresses are constantly modified and indicate the last device the packet passed and which will be the next that it will pass.
In summary, IP is used to guide information from one network to another and the MAC to guide information from one device to another directly connected (same network).