Skip to content

Instantly share code, notes, and snippets.

@mkbabb
Last active September 7, 2023 16:00
Show Gist options
  • Select an option

  • Save mkbabb/800e3bb889bd941556e04a8ad0bd359d to your computer and use it in GitHub Desktop.

Select an option

Save mkbabb/800e3bb889bd941556e04a8ad0bd359d to your computer and use it in GitHub Desktop.
Chapter 1.md

1.1 Uses of Computer Networks

  • Computer networks allow remote access to information, person-to-person communication, electronic commerce, entertainment, and more.
  • The client-server model and peer-to-peer communication are common ways to access information over a network.

1.2 Types of Computer Networks

  • There are many types of networks, including broadband access networks, mobile/wireless access networks, content provider networks, transit networks, enterprise networks, and inter-networks. Each serves a different purpose and scale.
  • Local area networks (LANs) operate over a small geographic area like a building. Wireless LANs (WiFi) are very common now.

1.3 Network Technology, from Local to Global

  • Networks span a huge range of scales, from personal area networks up to the global Internet. Different technologies are used at each scale.
  • Key technologies include Ethernet for wired LANs, WiFi for wireless LANs, DOCSIS for cable broadband access, cellular technologies for mobile access, and fiber optics for long-haul transport.

1.4 Examples of Networks

  • The Internet evolved from ARPANET and NSFNET and now interconnects many networks globally. It uses TCP/IP and packet switching.
  • Mobile networks have evolved over generations and now use technologies like LTE. They combine circuit and packet switching.
  • WiFi (802.11) networks provide short-range wireless access using technologies like CSMA and spread spectrum transmission to deal with interference.

1.5 Network Protocols

  • Common protocol design goals are reliability, resource allocation, evolvability, and security.
  • Protocols are often organized in layers to break up complexity. Each layer provides a service to the layer above.
  • Services can be connection-oriented (virtual circuit) or connectionless (datagram).

Misc. Notes

Layering

Protocols are organized in layers, with each layer building on the one below. This allows specialization.

OSI Model

The Open Systems Interconnection (OSI) model is a conceptual framework employed to understand network interactions in distinct layers. Seven layers make up this model, each serving specific functionalities.

  1. Physical Layer
    • Function: Concerned with the physical connection between devices. It stipulates the hardware elements involved, such as cables, switches, and network interface cards.
    • Examples: Ethernet cables, USB cables, and optical fibers.
  2. Data Link Layer
    • Function: Responsible for creating a reliable link between two directly connected nodes. It encompasses the framing, addressing, and error detection.
    • Examples: Ethernet (for its MAC addressing), Wi-Fi (WLAN), and PPP (used in dial-up connections).
  3. Network Layer
    • Function: Directs data packets from the source to the destination device, potentially across multiple networks. It deals with logical addressing and routing.
    • Examples: IP (IPv4 and IPv6), ICMP (used in tools like ping), and routers.
  4. Transport Layer
    • Function: Ensures data transfer is reliable, sequential, and free from errors between two devices. It manages flow control, error correction, and segmentation.
    • Examples: TCP (ensures reliable data transfer), UDP (offers connectionless communication), and ports.
  5. Session Layer
    • Function: Manages and controls the synchronization, coordination, and termination of communication sessions.
    • Examples: NetBIOS (used in older Windows systems for session management), PPTP (for creating VPN tunnels), and RPC protocols.
  6. Presentation Layer
    • Function: Transforms the data format from one presentation to another. It's responsible for encryption, compression, and translation.
    • Examples: SSL/TLS (for encryption in web browsing), JPEG (image format), and MPEG (video format).
  7. Application Layer
    • Function: This is the interface between the OSI model and end-users. It provides network services directly to end-user applications.
    • Examples: HTTP/HTTPS (web browsing), FTP (file transfer), and SMTP (email).

Example Stacks:

  1. Web Browsing:
    • Physical: Ethernet cable
    • Data Link: Ethernet
    • Network: IP (IPv4 or IPv6)
    • Transport: TCP
    • Session: (Often this layer is thin or transparent in many modern applications)
    • Presentation: SSL/TLS
    • Application: HTTP/HTTPS
  2. File Transfer via FTP:
    • Physical: Wi-Fi
    • Data Link: WLAN
    • Network: IP
    • Transport: TCP
    • Session: (Transparent in this case)
    • Presentation: (None, unless encrypted)
    • Application: FTP

ARP (Address Resolution Protocol)

ARP is a protocol used within the Internet Protocol (IP) suite, specifically in the context of IPv4. Its primary function is to map 32-bit IP addresses to MAC (Media Access Control) addresses, allowing for correct packet delivery within a local network segment; used to map Layer-2 MAC addresses to Layer-3 IP addresses.

Purpose:
In Ethernet networks, data packets are transmitted to devices using MAC addresses. When a device knows the IP address of a destination but not its MAC address, ARP assists in determining the MAC address associated with that IP.

ARP Process:

  1. ARP Request:
    When a device (e.g., a computer) wishes to communicate with another device on the local network, it sends an ARP request to ascertain the MAC address of the destination device. This request is broadcast to all devices on the local network.
  2. ARP Reply:
    The device with the IP address specified in the ARP request responds with its MAC address. This is sent directly to the requesting device.

Why Does ARP Use a Broadcast Address?

ARP uses a broadcast address for its requests because the requesting device does not know the MAC address of the destination device. Broadcasting ensures that all devices on the local network segment receive the ARP request. Only the device with the matching IP address responds to the ARP request.

ARP Cache:

To reduce the number of ARP requests, devices maintain an ARP cache or table. This cache contains recent IP-to-MAC address mappings. Before sending an ARP request, a device checks its ARP cache. If the mapping is present, it uses the cached MAC address. If not, it proceeds with the ARP request.

Potential Issues with ARP:

  1. ARP Spoofing or ARP Poisoning:
    This is a type of attack where a malicious device sends fake ARP messages to the Ethernet LAN. The aim is to link the attacker's MAC address with the IP address of another device, like a default gateway. This causes traffic meant for that IP address to be sent to the attacker instead.
  2. ARP Cache Pollution:
    This occurs when too many ARP responses are received, causing unnecessary entries in the ARP cache. This can degrade network performance or be used as part of a malicious attack.
  • MAC addresses - Unique hardware addresses used at layer 2.
  • Packet switching - Independent routing of packets instead of circuits. Enables dynamic rerouting.
  • CSMA - Carrier sense multiple access protocol used in WiFi to share the wireless channel.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment