In the LAN depicted in the picture below, am I correct in saying that devices do not have IP addresses? There is no router and also only Ethernet frames (with source and destination mac address would be transmitted) and not IP packets. Is that a correct assumption?
Ethernet communication is local only (segment) - across all switches (or repeaters) within a single VLAN (when other VLANs exist).
IP packets are transported as payload (layer 3) inside Ethernet frames (layer 2) or any other suitable link layer.
Due to the local-only restriction the IP communication in this network is confined to the local subnet. Multiple subnets can co-exist in a single L2 segment but they can't communicate with each other. Communication across subnets requires routers.
can Ethernet frames only be transmitted in a LAN
Yes. Ethernet frames can only be transmitted in a LAN (as in "LAN = a segment connected by switches") - note that today, technologically a "LAN" as a layer 2 segment has no geographically defined limit any more; fiber links can reach dozens or even hundreds of km. Also note that the segment can also be bridged through a tunnel (L2TP, VXLAN, ...), letting you transmit Ethernet frames globally.
No, you can't deduce that from just the picture.
You could have hosts without IP addresses, but you could also have IP addresses. You don't need a router to assign IP addresses. You could:
- have a host running a DHCP (or even BOOTP) server providing IP addresses to the other hosts
- have hosts with manually configured IP addresses
- have hosts using auto-configuration IP addresses (IP addresses in the 169.254/16 network)
As for traffic, provided we are indeed talking about Ethernet switches and interfaces, you can have Ethernet frames running through the network, and these Ethernet frames could contain anything, including IP packets. Without a router connected to the outside world, they would not be able to reach other networks (or the Internet at large), but the hosts could speak IP between them provided they somehow got IP addresses as described above.
Yes and no. At the data-link layer (Ethernet in this case), there is no concept of an "IP address": the only address that exists is the MAC address. Frames that are sent can be marked as containing IP packets (EtherType 0x0800/0x86DD), but it's up to higher-level layers to decide what to do with the data.
So if you're looking at this solely at the point of view of the Ethernet interface, you would be correct. However, looking at this from the point of the device using the interface, you would be incorrect: it would see the network from the TCP/IP or UDP/IP layer and would usually be completely indifferent to what exists beneath that.
A wrinkle that can occur is if you start using VPN tunnels. If you set up a VPN in bridge mode (let's say between switches 2 and 3), you now have a layer 2 frame encapsuled inside a higher-level packet!
There are solutions (eg Ethernet over MPLS) that actually allow transferring ethernet frames over a WAN - these are in production use in some applications but still somewhat exotic. Used in scenarios where you want multiple physically separate machines - in different buildings or even towns or countries, so that eg a local disaster will not wipe the whole setup out - able to quickly take on a given, identical IP address as needed without having to change routing or wait for DNS propagation.
There are non-IP packets to be found even on a modern LAN: ARP, a helper protocol IP uses to associate IP addresses to MAC addresses. Various discovery protocols for network-connected devices (which you want to be able to discover without knowing beforehand eg what address they were given by a DHCP server). Sometimes, legacy NetBEUI broadcasts if older Windows machines are involved. Spanning tree and LLDP, which is the shop-talk between intelligent network switches (they are actually gossiping about the expensive macbooks acting entitled!).
What you say is more or less correct: None of your switches have IP adresses. But your hosts do have a IP and the ethernet frames that pass the switches contain the IP's of host1 and host34. Your switches just don't care about those IP's.
A bit more info about the basic devices:
(These are all theoretical devices, many real-life devices take on some properties of device A and some of device B)
All types of data will always move over hubs even if it's not a ethernet packet. A hub will just read all bits it sees and sent them back out again on every port. It doesn't have a MAC or IP because it doesn't care about the fact that the bits are ethernet packets.
A switch will:
- Discard everything that's not a ethernet packet.
- Make decisions on what do with the packet based on everything in the packet except the ethernet frame (the payload). In most cases this decision is only based upon the destination MAC address.
A switch has a MAC so that it can communicate with other switches and more advanced devices. A switch is a smart hub.
A router will:
- Discard everything that's not a IP packet.
- Make decisions on what do with the packet based on the header of the IP packet but it doesn't care about the data in the IP packet. In most cases this decision is only based upon the destination address
A router has a IP for each port so that it can communicate with other routers and more advanced devices. Since these IP packets are in Ethernet packets it will also have MAC addresses.
A router is smart switch.
- Network card of a computer
This is like a switch with 2 ports where 1 (virtual) port is connected with a cable and 1 port is connected with the operating system of the computer.
It has a MAC but contrary to what you may think no IP.
A firewall cares about everything.
A firewall is a smart router and has a MAC and IP's
- Operating system of a computer
This is like a firewall:
- That doesn't look at the data in a TCP/UDP/ICMP packet but does look at the header of those packets
- Where a virtual port is connected to each network card. It sends/receives IP packets to/from the network cards and these cards create Ethernet packets with the IP packets as frame or strip them from everything except the frame.
- It also has virtual ports that are connected to applications. There are 1 (ICMP) + 2^16 (TCP) + 2^16 (UDP) ports.
It has multiple IP's (1 for each network card) but no MAC
- A cable
This is like a hub with exactly 2 ports
It does not have a IP or MAC.
This is a simplified version of the theory, I ignore a lot of things (e.g. There is both IPv4 and IPv6). It's simplified but should be correct enough.
Just for fun: YES.
Can Ethernet frames only be transmitted in a LAN?
Yes, Ethernet frames in a strict sense are only transmitted in a LAN. In a WAN, you will have other formats.
In the LAN depicted in the picture below, am I correct in saying that devices do not have IP addresses?
Yes. The yellow line as many switches, which, as related to the packages between the two hosts, do not have IP addresses.
Modern switches can obviously have IP address of their own for their own configuration (i.e., if they offer a management web GUI). But simple household switches, even if they are rather intelligent (i.e. if they do not broadcast any and all ethernet packages on all ports, like they did in the stone age of networking), need to have no IP address at all.
Remark regarding comments: this is equivalent to saying that all the switches between those hosts are part of one subnet (i.e., one IP netmask). This is, admittedly, to some extent an assumption, as these days there can be very complicated switches, and some people may even call routers switches. But still; per default I would assume that a chart labeled with switches contains switches. They may (in fact, they most certainly will) look at the IP address to make the decision on which port to send a package. But they do not introduce new IP addresses as part of the path the packet takes.