I understand that when data is sent to another network, it has to use logical addresses, or IP addresses, to get there
Like the moderator said, IP and mac addresses are used on ethernet, so you are confused and don't understand how this works. If a PC-A on ethernet sends IPv4 traffic to an PC-B on another network, the packet still needs to arrive at the first-hop router. The destination IP address will be PC-B, but the destination mac-address is the first-hop router's mac.
PC-A is configured with the next-hop router IP address and PC-A ARPs to find the mac address of the first-hop router.
In this case, the first-hop router (also called the "default gateway") uses its routing table to find the proper interface to deliver the packet towards PC-B.
what if the destination for the data is on the local network? Do they use IP or MAC with ARP, and is that Layer 3 or 2? Like, is the Network layer used at all if the destination is on the local network?
If PC-A wants to send IPv4 traffic to PC-C on a local network, both the destination mac-address and the destination IP address are for PC-C.
PC-A realizes that PC-C is on the same network, so it ARPs to find the mac address of PC-C.
In this case, the lan-switch uses its mac-address table to find the proper interface to deliver the packet. However, PC-C still checks the destination IP address to ensure it belongs on PC-C.
Sometimes, I wish they'd stop teaching the OSI model. It seems to confuse more than it helps.
When we say that layers communicate with each other, we mean the data created by a particular layer (say, transport) on host A is processed by the same layer on host B. This is a logical connection.
The actual data (in this case, the segment containing the SYN flag) is encapsulated in the Network PDU (IP packet), then encapsulated in the data-link PDU (Ethernet), then finally transmitted on the Ethernet cable (Physical layer). Host B reverses this process, unencapsulating the PDU at each layer until it reaches the transport layer. The transport layer processes the SYN flag and creates a new PDU containing the SYN, ACK flags. Then it sends it to A using the same encapsulation process.
The only way data is actually sent from one host to another is via the physical wire. Layer to layer communication is just a mental construct.
Best Answer
Source and destination addresses are found in the IP packet, belonging to the network layer. A transport layer datagram or segment that uses port numbers (=host subaddresses) is wrapped into an IP packet and transported by it.
The network layer uses the IP packet information to transport the packet across the network (routing). Arriving at the destination host, the host's IP stack uses the transport layer information (port number) to pass the information to the application.
IP addresses (and port numbers of course) are referred to as logical addresses because they are assigned to a host by the network (or its administrator) and are used to structure a network. This is in contrast to physical addresses like Ethernet MAC addresses that are assigned by the manufacturer.