Beej’s Guide to Networking Concepts
Technical Books
In Progress
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