Introduction to Networking 101 (TCP/IP/UDP/LAN/WAN/Hub Switch Router/3-way Handshake)
How do we get networks at home? What connects networks that allow us to exchange data and get the information we need from WAN to LAN? What is the process for the three-way handshake in TCP?
Networking is as simple as sending a letter. Reference
Let’s say we want to send a letter to Randy, but he lives two towns over. You know that the letter is going to go through each of the town post offices on their way to Randy’s house.
- Letter: Packet
- Your house: The client
- Randy’s House: The server
- Post Office A: Your default gateway
- Post Office B: The router closest to the server
- Computers communicate by sending packets
- Protocols are sets of rules that determine how data is transmitted between different devices in the same network.
ICMP (Internet Control Message Protocol)
- Ping command creates an ICMP Echo Request and sends it to the selected destination. If the destination gets that request, it will reply with a response.
UDP (User Datagram Protocol)
- Doesn’t guarantee single-packet delivery
- Time-sensitive with minimal overhead
- Commonly used for video calls.
TCP (Transmission Control Protocol)
- Ensures packets can get to their destination.
- Requires additional overhead comes with the knowledge of delivery.
- Commonly used with IP (TCP/IP).
- TCP 3-Way Handshake. This allows us to communicate between two machines over the specified port. If the TCP handshake fails, then our application can do nothing over the network.
LAN / WAN / Router
LAN — Router — WAN — Router — LAN
LAN (local area network — home network)
- IP (logical address)
- Subnet (define your local area network range, check if it is within the network or not)
- Gateway (IP address of the router)
WAN (wide area network)
- Firewall — if we do not see our traffic on the sending side then it must have been dropped in the network stack — the firewall dropped the packet before the network trace
- DMZ (demilitarized zone) — a subnetwork that contains and exposes a device to an untrusted network such as the internet. when the device sits in the DMZ, the device can talk to the device outside the firewall
- PORT Forwarding — directs a communication request from one address and port number combination to another while the packets are traversing a network gateway, such as a router or firewall (you need to specify which port address that communication needs to happen)
- NAT (network address translation) — a method of remapping an IP address while they are in transit across a traffic routing device.
- Router — the gateway allows LAN to talk to the outside network
- Router — the networking device that forwards data packets between different computer networks for security reasons
Hub / Switch / Router
Hubs, Switches, and Routers are used to connect networks.
Hub — connect all of your network devices together on an internal network. A device that has multiple ports that accept Ethernet connections from network devices. Does not filter data. Data comes to one port then data is copied to all other ports. (security concerns and unnecessary concerns)
- only detects that a device is physically connected to it
Switch — intelligent, learn the physical address of the device. Stored called MAC address, and then the switch will look at its table of MAC address and matching ports and deliver to the correct port. (preferred over the hub, reduce unnecessary traffic)
- can detect specific devices that are connected to it
- and keep a record of the MAC addresses of those devices
Hub and Switch are used to exchange data within a local area network. (in-home network or business) not used to exchange data outside their own network, like the internet.
In order to exchange data outside their own network, a device needs to be able to read IP addresses.
Subnets- logical groupings of IP addresses
Router — routes or forwards data from one network to another based on their IP address. When a data packet is received from the router, the router inspects the data’s IP address and determines if the packet was meant for its own network or if it is meant for another network. (gateway of a network)
Three-Way Handshake in TCP
The client wants to establish a connection with a server
- IP Adress
- Set up TCP Handshake
- The client creates a source port, sends an SYN request to the server
- The server acknowledges back (bi-directional) with an SYN request + acknowledgment
- The client acknowledges the SYN request and we are good to go.
Step 1 (SYN)
The client sends a segment with SYN(Synchronize Sequence Number) which informs the server that the client is likely to start communication and with what sequence number it starts segments.
Step 2 (SYN + ACK)
The server responds to the client request with SYN-ACK signal bits set. Acknowledgment is going to be whatever your sequence was, plus 1. For example, if I send you 1000 bytes, you’ll send me acknowledgment 1001.
Step 3 (ACK)
The client acknowledges the response of the server, and both establish a reliable connection with which they will start the actual data transfer.