I just started to learn about Networking and I am curious if I am right with my understanding that IP is used for networks to networks data transmission, it cannot be used for data transmission within a LAN. Instead MAC addresses are used for in-network (LAN) communication / data transmission. Am I correct?
The fact that you seem to have misunderstood is as follows:
- Within a LAN segment in a TCP/IP network, computers can communicate without using IP. They would need some mechanism to learn each other’s MAC addresses.
- Computers use the Address Resolution Protocol (ARP) to learn the MAC addresses of other machines within the same LAN segment. Wikipedia says, “ARP has been implemented with many combinations of network and data link layer technologies, such as IPv4, Chaosnet, DECnet and Xerox PARC Universal Packet (PUP) using IEEE 802 standards, FDDI, X.25, Frame Relay and Asynchronous Transfer Mode (ATM). IPv4 over IEEE 802.3 and IEEE 802.11 is the most common case.” (Emphasis added.)
- Computers that are not in the same LAN segment cannot communicate without using IP or some other layer 3 (network layer) protocol.
As other answers have stated, it is certainly possible (and, in fact, quite routine) for network communication within a LAN segment to use IP. Beyond that: it is possible for two processes on the same computer to communicate via IP.
Your understanding was
- In a TCP/IP network, IP is used only for traffic going through a router.
The truth (somewhat simplified) is
- In a TCP/IP network, IP is needed only for traffic going through a router.
So, you were close.
In OSI model layer 2 (data link layer) you can transmit data into host inside the same collision domain. So when you have layer 3 (network layer) connectivity you are allowed to cross that limit transmitting data inside same broadcast domain and send data to another broadcast domain via routing protocols or fixed routes.
No, this is pretty much completely wrong. Computers use IP to talk to each other, whether in the same network or in different networks. They compose IP datagrams and then it's the network's job to get that datagram to the destination machine. As the IP datagram travels over different transports, each transport may put its own "wrapper" around the IP datagram. But IP is still being used, it's just being used inside another transport.
Imagine an IP datagram that starts on my computer and is going to Google's web server. It has a source IP address, that of my computer, and a destination IP address, that of Google's web server. It passes over a variety of links, LANs, and routers on its travels. On some of those hops, it may be inside an Ethernet container that has a source and destination MAC address for that one hop. But the point of this entire setup is to transport IP datagrams and IP is being used by the entire process.
You can use IP-addresses in LAN communication too, a LAN is just a local network, which can consist of multiple networks. And with multiple networks and routing you will need IP-adresses.