Network Fundamentals: Delays, Switching, Protocols, and DNS

1G = 109, 1M = 106, 1K = 103, 1B = 1 Byte = 8 bits, 1b = 1 bit. Msec is millisec which is 0.001.

Delays

Types of delays: processing, queue, transmission, propagation.

dnodal = dproc + dqueue + dtrans + dprop

Dial-up networks have high transmission delays, while satellite connections have high propagation delays.

Processing Delay

Time it takes for a device to process a packet header to determine where to forward it (caused by CPU cycles).

Queue Delay

Time a packet waits in a system queue before processing, affected by the statistical behavior of the information source and service time (access delay, propagation delay, packet processing delay, and ARQ delay).

Transmission Delay

Time required to push all of a packet’s bits onto the wire. It’s a function of the packet’s length:

Dt = bits / transmission rate

Propagation Delay

Time it takes for the head of a signal to travel from sender to receiver:

Dp = distance / propagation speed

Recall: get payload per packet (payload/packets), then total packet size in bits (payload/packet * 8) = bits packet size, then packet size / transmission rate = transmission delay for one packet.

Packet Switching vs. Circuit Switching

Packet Switching

Data is broken into packets, each transmitted individually and potentially taking different paths. There’s no dedicated path; packets are sent as needed, and routers decide the best path based on network conditions. This method efficiently uses bandwidth but can experience congestion delays. It’s used in IP networks and is more efficient for bursty traffic, allowing multiple devices to share resources. However, packets may arrive out of order or be delayed, with a higher potential for packet loss due to congestion.

Circuit Switching

A dedicated communication path is established between two devices for the connection’s duration. This fixed path requires setup time but guarantees a constant transmission rate. Traditional telephone networks (PTSN) use circuit switching. It provides reliable and constant data transmission once established, making it suitable for phone calls. However, it inefficiently uses resources, as the circuit is reserved regardless of usage, and there’s a setup delay before communication starts.

Protocol Design

End-to-End Argument

Suggests functions like error handling and data integrity are best handled at the communication endpoints rather than intermediary systems (routers or gateways). For example, TCP ensures data arrives in order and intact, leaving IP to move packets without requiring reliability at every hop.

Stateless Protocol

Doesn’t store information from previous interactions; each client request is treated as a new, independent transaction (e.g., HTTP).

Stateful Protocol

Maintains information about the state of each interaction (e.g., user logged in, ongoing session status). State is kept across multiple requests from the same client (e.g., banking, gaming, FTP).

Connection-Oriented Protocol

Establishes a dedicated communication path before data exchange, maintaining it for the session’s duration (e.g., video streaming, large file transfers, TCP).

Connectionless Protocol

Doesn’t establish or maintain a dedicated path. Prioritizes speed over reliability, suitable where packet loss is acceptable (e.g., online gaming, live video broadcasts, UDP).

Application Protocols

DNS

A distributed hierarchical system, DNS translates domain names into IP addresses using databases of name servers. When a user types a URL, a DNS query is sent to a DNS resolver, which queries other DNS servers to find the corresponding IP address. This involves looking up root DNS servers, TLD servers, and authoritative servers.

DNS Dig

dig is a Linux command for querying DNS servers. It provides information like opcode (type of query), status, flags, question section, answer section (including TTL, class, record type, and IP address), authority section, query time, server, and message size.

Example:

; > DiG 9.10.6 > example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- status: NOERROR, id: 51234
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;example.com.            IN    A
;; ANSWER SECTION:
example.com.        300    IN    A    93.184.216.34
;; AUTHORITY SECTION:
example.com.        86400    IN    NS    ns1.example.com.
;; Query time: 30 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Tue Oct 10 12:34:56 UTC 2024
;; MSG SIZE  rcvd: 85

DNS Query Types

Recursive Query

The DNS resolver takes full responsibility for resolving the domain name. If it doesn’t have the answer cached, it queries other DNS servers until it finds the answer or an error.

Non-Recursive Query

The DNS resolver responds with the information it has available. Often used by DNS servers querying other DNS servers, not typically by end-users.

DNS Server Types

Root DNS Servers

Top-level servers in the hierarchy, responding to queries for records in the root zone and directing queries to TLD servers.

TLD Servers (Top-Level Domain)

Responsible for specific domains like .com, .net, .org, providing information about authoritative servers for domains under their TLD.

Authoritative Servers

Contain the DNS records for a specific domain, providing definitive answers to DNS queries for their domains.

DNS Caching

Storing DNS query results temporarily in the resolver to reduce lookup times for subsequent queries for the same domain. This reduces latency for frequently accessed domains and decreases the load on DNS servers and internet traffic. Each DNS record has a TTL, indicating how long it can be cached.

DNS Underlying Protocol

Primarily uses UDP due to its speed, low overhead, and acceptable reliability for DNS operations.

HTTP

HTTP/1.0: Non-Persistent Connections

Each request/response requires a new TCP connection, resulting in higher latency due to multiple connections and slower performance. RTT: 2 RTT + object transmission time per object.

HTTP/1.1: Persistent Connections

Reuses the same TCP connection for multiple requests/responses, reducing latency. RTT improvement: initial object takes 2 RTT + transmission time, subsequent objects take 1 RTT + transmission time.

HTTP/2.0: Binary Protocol

Uses binary framing, multiplexing (allowing multiple streams over a single TCP connection), header compression, and prioritization, eliminating head-of-line blocking issues.

TCP vs. UDP

TCP: reliable, connection-oriented, congestion control, flow control.

UDP: unreliable, unordered delivery, no connection setup (faster, less reliable), best-effort.

Multiplexing

The process of combining multiple signals into a single signal for transmission over a network.

Socket Code

import socket

# Create a socket
def create_socket():
    '''Create and return a TCP socket'''
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    return s

# Bind a socket to a specific port
def bind_socket(s, host, port):
    '''Bind the socket to a host and port'''
    s.bind((host, port))

# Listen for incoming connections
def listen_socket(s, backlog):
    '''Listen for incoming connections on the socket'''
    s.listen(backlog)

# Accept an incoming connection
def accept_connection(s):
    '''Accept a connection and return the client socket and address'''
    client_socket, address = s.accept()
    return client_socket, address

# Send data through a socket
def send_data(s, data):
    '''Send data to the connected socket'''
    s.sendall(data.encode('utf-8'))

# Receive data from a socket
def receive_data(s, buffer_size):
    '''Receive data from the connected socket'''
    return s.recv(buffer_size).decode('utf-8')

# Close a socket
def close_socket(s):
    '''Close the given socket'''
    s.close()

g8JMw3lUa2KpgAAAABJRU5ErkJggg==

pz41Exi6TwAAAABJRU5ErkJggg==

wN1Ch+sY5l3cwAAAABJRU5ErkJggg==