Beej’s Guide to Networking Concepts
Technical Books
My notes on Beej’s Guide to Networking Concepts by Beej
Notes
Chapter 2. Networking Overview
No notes
Chapter 3. Introducing The Sockets API
General steps to connect to another computer:
- Ask the OS for a socket
- Perform a DNS lookup
- Connect the socket to the IP address (from the DNS lookup) no a specific port.
- Send data and receive data
- Close the connection
Sever listening process steps:
- Ask the OS for a socket
- Bind the socket to a port
- Listen for incoming connections
- Accept incoming connections. The original socket the server made in step 1 is still listening for new connections. When the connection arrives, the OS makes a new socket specifically for that one connection. This way the server can handle multiple clients at once.
- Send data and receive data
- Go back and accept another connection
Chapter 4. The Layered Network Model
- Interesting that clients get assigned a port number as well (usually at random) but it makes sense as the server needs a port to send back to.
- TCP sockets are called stream sockets
- UDP sockets are called datagram sockets
- Remember NAT is the ability to have a translation between private IP addresses and public IP addresses. IPv4 address are limited so you can have one device with public IP address as the “gateway” and all other devices with a private IP address route through this gateway and then gateway will do the NAT translation keeping track of everything
- Header is some data that is prepended by some other data by a particular protocol
- TCP would include error detection and correction info, source and destination port number
- IP would include some source and destination IP addresses.
- Ethernet would include the source and destination MAC addresses.
- MAC Address take the form of
aa:bb:cc:dd:ee:ff, are 6 bytes long and must be unique on the LAN. When a network adapter is manufactured, it is given a unique MAC address that it keeps for life. - ARP cache (address resolution protocol) is the lookup done in ethernet layer to find where the destination MAC address is.
- Ethernet packets are called ethernet frames
Chapter 5. HTTP Client and Server
\r\nused to denote the end of a header\r\n\r\nused to denote the end of all the headers
Chapter 6. The Internet Protocol (IP)
- IP addresses are split up into two parts: networks and hosts.
- The individual networks are called subnets.
- ICMP: Internet Control Message Protocol, a mechanism for communicating IP nodes to talk about IP control metadata with one another.
- IPSec: Internet Protocol Security, encryption and authentication functionality. Commonly used with VPNs.
pinguses ICMP “echo request” and “echo response” messages.tracerouteuses ICMP “time exceeded” messages to find out how packets are being routed.- When you connect device to your LAN it will broadcast out a messages asking for an IP, a Dynamic Host Configuration Protocol server will be listening for these requests and respond.
Chapter 7. IPv4
- The lowest host is reserved and the highest host is used or broadcast
- Subnet mask is simply a number than you can do a bitwise and with to get the subnet number (all zeros for the subnet)
127.0.0.1the computer you are on now often mapped tolocalhost0.0.0.0is reserved255.255.255.255broadcast for all hosts on a subnet, routers don’t forward packets intended for this address. You can also broadcast with will hosts bits set to 1 on any subnet.
Chapter 8. IPv6
No notes.
Review
Read this as a primer before I tackle Beej’s Guide to Network Programming and you can never go wrong with any of Beej’s guides. His C programming one is excellent and this one was also great.