MAN: Larger than LAN, connecting cities and towns.
WAN: Larger than MAN, connecting countries and continents.
LAN: Local Area Network, a locally connected network, such as a school, home, and an organization. Devices are interconnected via switches to make subnets, and subnets are interconnected via routers to make a network. Such networks connected together make the Internet.
For internet to work, each device should be able to communicate with any other device. And each device needs an IP address for communication. We predominantly use IPv4 addressing, which is a relatively smaller space. Thus we use NATing
NAT: Network Address Translation, allows a single IP address to represent an entire network in the internet. The router is assigned an IP address, which is used for communicating with the internet.
How Alice sends messages to Bob, who is behind a NAT.
There is no way for Alice to start a communication directly with Bob in this case, thus we assume that Bob had started the communication and Alice is just responding back.
- Alice gets the IP & additional details (port etc.) for Bob's machine from Bob's request.
- Alice responds to the NAT IP
- The packets reach the router, these are the possibilities w.r.t NATing:
- Static NAT
- A single private IP is mapped directly to the public NAT IP, Bob's machine is directly mapped to the NAT IP
- Dynamic NAT
- Private IP is mapped to public NAT IPs from a pool of public IP addresses, Bob's machine is mapped to one of the IPs
- Chances of data loss in case there are more devices being present in the LAN than the IP addresses available in the pool
- PAT, Port based address translation
- Multiple private IP addresses mapped to a single NAT public IP
- Each private IP is mapped to a combination of NAT IP and a port, Bob's machine is mapped to NAT IP on a certain port
- Static NAT
- The router on the basis of configuration locates Bob's machine and forwards the packets.
VLAN: Virtual Local Area Network, a concept of further partition a LAN, implemented for the sake of segmenting a network. Managed by the switch which may group devices connected on certain ports (e.g. port 150-200).
A switch could also implement much smarter segmentation by group devices on the basis of their properties.