\documentclass[a4paper, landscape]{article}
\input{src/default.tex}

% Global setttings
\def\subject{Subject}
\def\semester{Semester}
\def\author{Author}
\def\cols{4}


\cheatsheet{
    \section{Lec 2}
\textbf{Computer network uses: }
1. Business applications
Resource Sharing (Printers, files, databases), 
Information Sharing (Cloud, intranets), 
Communication (Emails, VoIP, messaging apps),
Client-server model is commonly used.
2. Home applications: Usually uses peer-to-peer model. 
3. Social Issues: 
Net Neutrality (No content-based traffic discrimination),
Censorship \& Anonymity (Use of cookies, tracking, blocking),
Privacy \& Info Theft (Botnets, phishing, spyware).
\textbf{Types of Transmission Technology}
1. Broadcast Links: communication channel shared by all machines in network (Ethernet, WiFi),
2. Point-to-Point links: connect individual pairs of machines (unicast)
\textbf{Internetworks:} It's a network of smaller networks.
\textbf{Gateways} are different devices that transfer information from one layer to another.
A \textbf{router} is a gateway for information at the network layer.
\textbf{Network Software \& Layering}
1. Layered Architecture: Each layer solves a specific problem and provides services to the layer above. Layers use protocols for peer-to-peer communication and services for vertical communication.
2. Connection Types: Connection-Oriented (TCP): Setup required, reliable. Connectionless (UDP): No setup, fast but unreliable.
3. Service Primitives: System calls (in OS) that provide access to network services (CONNECT, SEND)
4. Service vs Protocol: Service - Provided to upper layers (vertical),
Protocol - Peer-layer rules (horizontal) \textbf{OSI Model}
7. \textit{Application:} supports network applications, provides end-user applications access to network resources (http, ftp, smtp). 6. \textit{Presentation:} Data translation, encryption, compression (jpeg, ascii). 5. \textit{Session}: Maintains sessions between users (rcp). 4. \textit{Transport}: provides process to process data transfer, reliable data delivery, segmentation of packets, end-to-end network error control (tcp, udp). 3. \textit{Network}: Routing of packets and addressing (ip, icmp). 2. \textit{Data Link}: Error detection, MAC addressing (enthernet). 1. \textit{Physical}: Transmits raw bits over a physical medium (fiber, wifi)

% \subsection{Subsection}
% This is a subsection

% \subsubsection{Subsubsection}
% This is a subsubsection

% % Two-column layout within the section
% \begin{minipage}{0.49\linewidth}
%     Left
% \end{minipage}
% \hfill
% \begin{minipage}{0.49\linewidth}
%    Right
% \end{minipage}

% \section{Table Example}
% \begin{tabularx}{\linewidth}{|X|X|X|}
%     \hline
%     \textbf{Header 1} & \textbf{Header 2} & \textbf{Header 3} \\
%     \hline
%     Row 1, Col 1 & Row 1, Col 2 & Row 1, Col 3 \\
%     \hline
%     Row 2, Col 1 & Row 2, Col 2 & Row 2, Col 3 \\
%     \hline
%     Row 3, Col 1 & Row 3, Col 2 & Row 3, Col 3 \\
%     \hline
% \end{tabularx}

% \section{Boxed Equation}
% % Boxed equation with a simple math expression
% \mathbox{
%     $E = mc^2$
% }

% \section{Input}
% % Including an external file
% \input{sections/00_Example}

% \section{Image}
% % Including an image with full width
% \includegraphics[width=\linewidth]{img/example.png} 


    \section{Lec 3}
\textbf{Network Architecture}
Provides services to applications; fixed and defined by Internet protocols.
\textbf{Application Architecture}
Designed by app developers; defines interaction across end systems.
\textbf{Application Layer Architectures}:
1. \textbf{Client-Server Architecture}
Client initiates communication.
Server is always on, waits to be contacted.
Server typically has a permanent IP address.
Clients may have dynamic IPs and do not directly communicate with other clients.
Egs: HTTP (web), FTP, Email, Telnet.
2. \textbf{Peer-to-Peer (P2P) Architecture}
No reliance on centralized servers.
End systems (peers) communicate directly.
Peers act as both client and server.
Self-scalable: New peers bring new capacity and new demand.
\textbf{Processes}
A process is a program running on an end host.
Two processes on the same host communicate via inter-process communication (\textbf{IPC}).
Two processes on different hosts communicate via network messages.
\textbf{Sockets (API)}
The interface between the application and transport layer.
Each process sends and receives messages through its socket.
The OS uses sockets to manage network communication.







    \section{Lec 4}
\textbf{TCP Service} Reliable transport service.
Flow Control: Prevents overwhelming the receiver.
Congestion Control: Reduces load during congestion.
Connection-Oriented: Handshake required before sending data.
Does NOT provide timing, throughput guarantees, or encryption.
\textbf{UDP Service}
Unreliable, connectionless service.
No flow control, congestion control, or security.
Lightweight with low overhead → ideal for real-time apps. \textbf{Why use UDP?} Less delay and faster for apps that can tolerate some loss (e.g., VoIP).
\textbf{Securing TCP – SSL (Secure Sockets Layer)}
Neither TCP nor UDP offers encryption.
To add security to the TCP service, SSL (Secure Socket Layer) is applied at the application layer. Applications will use SSL libraries, and that library will "communicate" with the TCP instead. Provides process-to-process security services, like encryption, data integrity, and end-point authentication.
SSL is an application-layer enhancement over TCP.
Provides:
Encryption (confidentiality),
Data Integrity,
End-point Authentication.
Apps use SSL libraries, which interact with TCP. Often referred to as TCP with SSL or TLS (newer version).
\textbf{Application-Layer Protocols}
An application-layer protocol defines how an application’s processes,
running on different end systems, pass messages to each other:
▪ \textit{Message Types}: request, response.
▪ \textit{Message syntax}: What fields in messages \& how fields are delineated.
▪ \textit{Message semantics}: Meaning of information in fields.
▪ \textit{Rules} for when and how processes send \& respond to messages.
Some protocols are \textbf{open}: defined in RFCs.
This allows for interoperability (HTTP, SMTP).
Some protocols are \textbf{proprietary}: not in the public (Skype).
\textbf{HTTP}
A web page consists of objects (files).
Each object is addressable by a URL (Uniform Resource Locator).
Based on the client/server model.
Uses TCP protocol on port 80 by default.
Stateless.
\textbf{Non-Persistent HTTP}: At most one object sent per TCP connection.
\textbf{Persistent HTTP}: Multiple objects can be sent over a single TCP connection.
\textbf{HTTP Messages:}
\textbf{Request Message Format}:
Text-based (ASCII),
Components:
Request Line: Method, URL, version,
Header Lines: Info like host, user-agent,
Optional Body (e.g., form data).
\textbf{Response Message Format}:
Text-based (ASCII),
Components:
Status Line: HTTP version, status code, reason,
Header Lines: Info about server, content type, etc.,
Body: The requested resource (HTML file),
\textbf{Status Codes}
Informational Responses (100-199),
Successful Responses (200-299) eg. 200 OK,
Redirection Messages (300-399) eg. 301 Moved Permanently,
Client Error Responses (400-499) eg. 400 Bad Request, 404 Not Found, 418 I’m a teapot, 
Server Error Responses (500-599)
eg. 505 HTTP Version not supported.



    
    \section{Lec 5}
\textbf{Email System Components:} 
\textbf{User Agent (UA):} Email applications like Outlook or Apple Mail; lets users read, reply, forward, compose, and save messages.  
\textbf{Mail Server:} Maintains mailbox for incoming messages and a message queue for outgoing messages.  
\textbf{SMTP (Simple Mail Transfer Protocol):} Client-server protocol used to send email from sender's mail server to recipient’s mail server via TCP (port 25). SMTP is a \textbf{push protocol} (initiated by sender); uses 7-bit ASCII; messages must end with \texttt{CRLF.CRLF}.  \textbf{SMTP Phases:} 
1. \textbf{Handshaking} (greeting and initial setup)  
2. \textbf{Message Transfer}  
3. \textbf{Closure}  \textbf{Mail Message Format (RFC 822):}  
\textbf{Header:} \texttt{To}, \texttt{From}, \texttt{Subject} — distinct from SMTP commands.  
\textbf{Body:} ASCII text message.  
Message format: Header \texttt{(CRLF)}, blank line, Body  \textbf{Mail Access Protocols:}  
SMTP only handles sending. Retrieving mail requires:  
- \textbf{POP3 (Post Office Protocol v3, RFC 1939):}  
\textbf{Port 110, Stateless. Three phases:}  
\textbf{Authorization:} user <username>, pass <password>  
\textbf{Transaction:} list (message IDs), retr (retrieve), dele (delete), quit  
\textbf{Update:} server deletes marked messages after \texttt{quit}  
\textbf{POP3 Modes:}  
\textbf{Download-and-delete:} Messages removed from server after download (cannot re-read elsewhere).  
\textbf{Download-and-keep:} Copies remain on server; messages accessible across devices.  
\textbf{Limitation:} Cannot create remote folders or manage message storage — \textbf{use IMAP instead}  - \textbf{IMAP (Internet Message Access Protocol, RFC 1730):}  Allows manipulation of messages on the server; user interacts directly with server to view, search, delete messages. Supports folders and stateful sessions.  - \textbf{HTTP (e.g., Gmail, Hotmail):} Web-based mail access; user interacts with mail servers using browser-based interface.  
\textbf{Cookies:}  
Used to hold state in HTTP, which is stateless by default.  
Consists of:  1 A Set-Cookie header in the HTTP response  
2 A Cookie header in the HTTP request  
3 Cookie stored in user’s browser  
4 Website backend database to maintain session info  
Used for:  
- Authorization  
- Shopping carts  
- Recommendations  
- User session management  
\textbf{Web Cache / Proxy Server:}  
Acts as intermediary between client and origin server.  
Browser connects to proxy, which fetches content if not cached.  
If cached, it serves directly. Reduces load and latency.  
Proxy behaves as both client (toward server) and server (toward browser).  
Typically implemented by ISPs.


    \section{Lec 6}
\textbf{DNS Overview:} DNS maps hostnames to IP addresses and vice versa. It is a distributed hierarchical database and an application-layer protocol. DNS uses UDP on port 53.
\textbf{DNS Services:} 
- Hostname to IP address translation (and reverse)  
- Host aliasing (e.g., one host with multiple names)  
- Mail server aliasing using MX records  
- Load distribution by mapping a name to multiple IPs  
\textbf{DNS Hierarchy:}  
- \textbf{Root Servers:} Point to TLD servers  
- \textbf{TLD Servers:} Store records for domains under a top-level domain  
- \textbf{Authoritative Servers:} Provide IPs for specific domains  
- \textbf{Local DNS Server:} Acts as cache + resolver for end-hosts; forwards unresolved queries \textbf{DNS Components:}  
- \textbf{DNS Servers:} Store and respond to queries  
- \textbf{Name Resolvers:} Generate and send queries from applications  
- \textbf{Zones:} Each server manages a zone (domain/subdomain) \textbf{Name Resolution (Iterative Query):}  
1. Client queries local DNS  
2. Local may query root  
3. Root returns TLD server  
4. TLD returns authoritative server  
5. Authoritative returns IP  
6. Response is passed back to client \textbf{Caching:}  
- All servers cache resolved names (with TTL)  
- Cache may be outdated until TTL expires  
- Reduces root/TLD traffic \textbf{DNS Records:} Format: (Name, Value, Type, TTL)  
- \textbf{A:} Maps hostname to IP  
- \textbf{NS:} Points to authoritative name server  
- \textbf{CNAME:} Alias for a canonical name  
- \textbf{MX:} Maps domain to mail server  
\textbf{DNS Messages:}  
- Same format for queries and replies  
- 16-bit identification number links query to reply  
- Flags indicate query/reply, recursion desired/available, authoritative answer  
\textbf{Adding Records to DNS:}  
- Register domain through DNS registrar  
- Provide authoritative server names and IPs  
- Registrar inserts NS and A records into TLD servers  
- Owner sets up A and MX records in authoritative servers
\textbf{DNS Vulnerabilities:}  
- \textbf{DDoS Attacks:} Flood root/TLD/local servers  
- \textbf{Redirect Attacks:} Man-in-the-middle and DNS poisoning  
- \textbf{Amplification:} Use spoofed queries to flood a target





    \section{Lec 7,8,9,10,11}
\textbf{Transport Layer}
Provides logical communication between application processes on different hosts.
From the application's POV, the hosts running the processes are directly connected.
Typically implemented in end systems (not in network routers).
Converts data from application layer messages into segments, passing these segments to the network layer, where it is put into a datagram.
Routers only look at the data in the network layer fields of a datagram.
Protocols include TCP and UDP.
\textbf{Where is the Transport Layer Implemented?}
It’s implemented only in the end systems, not routers.
1. Sending side: Converts application layer messages into segments. Adds transport headers to each segment. Passes these segments to the network layer (which adds IP headers).
2. Receiving side: Network layer extracts the segment from the datagram. Segment is passed up to the transport layer. Transport layer delivers data to the appropriate application.
\textbf{Two transport protocols:}
1. UDP (User Datagram Protocol): Connectionless, unreliable. Minimal functionality. Fast, lightweight – good for real-time apps.
2. TCP (Transmission Control Protocol): Connection-oriented and reliable. Ensures data is delivered completely and in order. Used for email, web, file transfers, etc.
\textbf{Demultiplexing}
When a host receives data, the transport layer does not give the application data directly. It instead places the data into an intermediary socket.
A host can have multiple receiving sockets.
Sockets have unique identifiers.
Transport layer segment has header data about the destination socket. 
Important: TCP sockets are identified by a source IP address, source port, destination IP address, and destination port. UDP sockets only need destination IP and port.
\textbf{Multiplexing}
The process of gathering data from the sockets of the source host and encapsulating it into segments, passing these segments to the network layer. At the sender side.

Collects data from multiple processes and packages them for network delivery.
Ports range from 0 to 65535, but 0 to 1023 are restricted (for HTTP, FTP, etc.)
\textit{Fundamentals of Reliable Data Transfer Protocol}:
1. Error detection and correction: packet received but incorrect.
2. Loss detection and recovery: packet is lost.
3. Challenges: Maximizing efficiency.
\textbf{UDP Checksum} checks if data was altered at all. (TCP has this too)
\textbf{TCP Features}:
1. Sequence Number: Tracks data position. Position of first byte in segment.
2. Acknowledgment Number: Confirms receipt. Next expected byte.
3. Checksum: Detects errors.
4. Flow Control: Uses window size to manage send rate.
5. Congestion Control: Avoids overloading the network.
A \textbf{TCP segment} consists of the data field (chunk of application data) and header fields.
- The data field is limited by the MSS (Maximum Segment Size).
- Interactive applications tend to transmit data chunks that are much smaller than the MSS.
\textbf{TCP Segment Structure} 
- 32 bit sequence number (reliable data transfer)
- 32 bit acknowledgment number (reliable data transfer)
- 16 bit receive window (flow control)
- 4 bit header length field (length of TCP header)
- Optional and variable-length options
- 6 bit flag field





    \section{Lec 12}
\textbf{Socket}: Acts as a doorway between the application layer and the transport layer (TCP or UDP).
\textbf{Socket programming} is the method by which networked applications (like web browsers and servers) communicate with each other. 
\textbf{Socket Programming with UDP}: No connection needed, client program just attaches IP destination and port number to packets. 
\textbf{Socket Programming with TCP}: Connection needed, server has to have a socket for welcoming client contacts, and creates new sockets after "greeting" clients.
\textbf{Client-Server Architecture in Socket Programming}
Most network applications follow the client-server model:
- The \textbf{client} initiates the request.
- The \textbf{server} waits and responds to requests.
- These programs run on different systems, communicating via sockets.
\textbf{Routing Protocols}: Establish paths between routers.
Networks are modeled as a graph where routers are vertices, links are edges, and the weights are an associated cost (distance, loss, latency). Goal it to find a path from one router to another with least cost.
\textbf{Sockets Interface}
A collection of system-level functions used with Unix I/O to build network apps.
Created in the early 1980s as part of the Berkeley Unix distribution.
Available on modern platforms (Linux, Windows, macOS, Android, iOS).
\textbf{Socket in Kernel}: It's an endpoint for communication. \textbf{Socket in Application}: It's a file descriptor(can read/write to it).
% Including an image with full width
% \includegraphics[width=\linewidth]{img/socketProg.png} 

    \section{Lec 13}
\textbf{Routing}: Network-wide process that determines end-to-end paths that packets take from source to destination,  takes seconds. Calculated using routing algorithms.
Happens on a longer timescale(seconds).
Maintains forwarding tables.
\textbf{Forwarding}: When a packet arrives at a router's input link, the router must move the packet to the appropriate link. Implemented in hardware, takes nanoseconds. Router-local action. Happens on nanosecond timescale.
Typically implemented in hardware.
\textbf{Routing Algorithm}: an algorithm that calculates optimal path from one router to another.
\textbf{Forwarding Table}
A router uses a forwarding table to decide where to send packets.
The router examines packet headers and uses them to index into the forwarding table.
The result tells the router which output interface to forward the packet to.
\textbf{How Are Forwarding Tables Built?}
Routing algorithms compute the contents of the forwarding tables.
Algorithms run inside each router.
Routers exchange routing messages with each other using a routing protocol to build and update these tables.
\textbf{Network Service Model}: defines the characteristics of  end-to-end transport of data between one "edge" of the network and the other, i.e., between sending and receiving end systems. Some properties of a network service model can (but don't have to) include:
	- Guaranteed Delivery (Packet will eventually reach the destination),
	- Guaranteed Delivery with Bounded Delay (Packet will arrive within a defined delay limit ),
	- In-order Packet Delivery (Packets arrive in the order sent),
	- Guaranteed Minimum Bandwidth (Emulates a dedicated link),
	- Security (Encryption at the network layer for confidentiality).



    \section{Lec 14}
\textbf{Components of a Router}
Routers consist of 4 main components, which work together to move packets across networks: 
1. \textbf{Input Ports}: Perform link-layer processing to receive packets.
Interface between the incoming link and the switching fabric.
Use the forwarding table to determine where to send incoming packets.
Note: This hardware 'port' is not the same as a software (socket) port.
2. \textbf{Switching Fabric}:
The internal interconnection network that moves packets from input to output.
It is at the heart of the router – handles packet switching.
3. \textbf{Output Ports}:
Store and forward packets coming from the switching fabric.
Prepare packets for transmission by handling link-layer and physical-layer functions.
4. \textbf{Routing Processor}:
Executes routing algorithms and maintains the routing table.
Computes and updates the forwarding table.
Handles control-plane functions (configuration, communication with other routers).
\textit{Input ports, output ports, and switching fabric are implemented in hardware for speed, while routing processor functions often run in software.}
\textbf{Forwarding Process (Input Port Processing)}
A packet arrives → Input port examines the header → Looks up the forwarding table → Sends packet to correct output port.
Forwarding table lookup is destination-based.
\textbf{How the Forwarding Table is Created:}
Built and updated by the routing processor.
Routers communicate with each other using routing protocols to exchange information.
The routing processor computes the forwarding table, then copies it to line cards on each port.
\textbf{Line Cards}
Circuit boards with transmission and reception circuitry.
Present in all ports of small to mid-size routers.







    \section{Lec 15,17}
    \textbf{Network Layer Design Issues}
\textit{Store-and-Forward Packet Switching}: Each router waits to receive the whole packet before forwarding.
\textit{Services to Transport Layer}:
1. Connectionless Service: Datagram (IP). 2.
Connection-Oriented Service: Virtual Circuit (MPLS)
\textbf{Network Layer}: Responsible for delivering packets between source and destination over multiple links (end-to-end transmission).
\textbf{Internetworking}: Joining multiple different networks into a single larger network.
Differences in packet size, reliability, addressing, etc. are hidden via a common network layer protocol – IP.
IP acts as a universal layer that all routers can understand and forward.
\textbf{IP Layer}: A universal packet format that all routers recognize and can be passed to almost any network.
\textbf{IP Basics}:
1. IP provides internetworking between different technologies (Ethernet, WiFi, Frame Relay).
2. Routers use IP to interconnect heterogeneous networks.
3. \textbf{Forwarding}: IP used to route datagrams to the destination network.
4. Within each network, native link-layer handles actual delivery.
\textbf{Access Control}: Allowing/rejecting traffic from a particular network in a router. Routers can permit or deny traffic based on source/destination address or other policies.
\textbf{Tunneling}: Connects two similar networks through a middle one that is different from the two. Encapsulate packets from one network inside packets of another when traversing a different network.
\textbf{IP Address}: An identifier (IPv4: 32-bit, IPv6: 128-bit) for a host, or router interface. Assigned by Internet Corporation for Assigned Names and Numbers (ICANN) to avoid conflicts. Hierarchical.
\textbf{Interface}: A connection between a host or router and a physical link. Routers typically have multiple interfaces with unique IP addresses. Hosts typically have one or two interfaces (Ethernet, WiFi).
IP addresses consist of variable-length network ID in the top bits and host ID in the bottom bits.
\textbf{Prefixes}: Written by giving the lowest IP address in the block and size of the block (number of bits in network portion).
Routers forward packets based on prefix only.
\textbf{Hierarchical Addressing}: All hosts in the same network have the same network ID.
\textbf{Network ID}: An IP address where the host ID is all zeroes. 200.1.1.0 is a network ID for ex.
\textbf{IP Network Layer Functions}
1. \textbf{ICMP(Internet Control Message Protocol):}
It's a companion to IP that returns error info.
Required, and used in many ways, e.g., for traceroute. If something unexpected occurs during packet processing at a router, the
event is reported to the sender by the ICMP.
2. \textbf{ARP (Address Resolution Protocol):} Finds Ethernet (MAC) address of local IP address. Glue that is needed to send any IP packets. 
Host queries an address and the owner replies. \textit{Ques: How to determine interface’s MAC address, knowing its IP address?}
Ans: Use ARP: each IP node (host, router) on LAN has ARP table:
$<IP address; MAC address; TTL>$
TTL (Time To Live): time after which address mapping will be forgotten
(typically 20 min)
ARP rotocol to resolve the hardware address. The request ARP broadcasts the request message.
The target ARP responds with the target hardware address.
3. \textbf{DHCP (Dynamic Host Configuration Protocol):} Assigns a local IP address to a host dynamically instead of hard-coding it. Gets host started by automatically configuring it. Host sends request to server, which grants a lease. DHCP can return more than just allocated IP address on subnet:
- address of first-hop router for client (default gateway).
- name and IP address of DNS sever.
- network mask (indicating network versus host portion of address).
\textit{DHCP overview: (4-step process)}
1. host broadcasts “DHCP discover” msg [optional]
2. DHCP server responds with “DHCP offer” msg [optional]
3. host requests IP address: “DHCP request” msg
4. DHCP server sends address: “DHCP ack” msg



\textbf{IP Version 4 (IPv4) Protocol}
IP header is carried on all packets and has fields for the key parts of the
protocol:
\textbf{Version}: IP protocol version number, IPv4 or IPv6.
\textbf{IHL}: IP header length in 32-bit words
\textbf{Total length}: total datagram length (bytes) (max=$65536$)
\textbf{Differentiated service}: 0: normal data, 5:voice, ...
\textbf{TTL}: max number remaining hops (decremented at each router)
\textbf{Protocol}: upper layer protocol to deliver payload to (TCP, UDP, ..)
\textbf{Fragment offset}: start of this fragment as multiple of 8 Bytes
\textbf{Header checksum}: Internet checksum, computed at every hop
\textbf{DF}: don’t fragment
\textbf{MF}: more fragments
\textbf{Options}: e.g. timestamp,
record route taken, specify
list of routers to visit.
\textbf{Identification}: sequence no.
\textbf{ECN}: Explicit Congestion
Notification
\textbf{IP Basics- Fragmentation}
Fragmentation parameters
\textbf{Identification}: carries the packet sequence number
\textbf{DF bit}: do not fragment
\textbf{MF bit}: more fragments follow this one
\textbf{Fragment offset}: start of this fragment as multiple of 8 Bytes

\textit{IPv4 Address space}: 32 bit IP addresses.
\textit{IPv6 Address Space}: 128 bit IP addresses. $3fff:0000:0000:0000:0123:4567:89AB:CDEF$. Can also be written as $3fff::123:4567:89AB:CDEF$.
Can convert IPv4 addresses to IPv6 notation as such: $192.31.20.49 \xrightarrow{} ::192.31.20.49$
\textbf{Routing Algorithms}
Routing is the process of discovering good network paths from sending
hosts to receiving host, through network of routers
Fill the routing table: “good”: least “cost”, “fastest”, “least congested”.
Model the network as a graph of nodes and links.
Decide what to optimize (e.g., fairness vs efficiency).
Update routes for changes in topology (e.g., failures).
\textbf{Forwarding} is the sending of packets along a path by using the already
built routing table

\textbf{Three types of IPv6 addresses}:
	1. \textbf{Unicast Addresses}: Identify a single interface.
	2. \textbf{Anycast Addresses}: Interify set of interfaces. Packet sent to an anycast address delivered to the closest member of the set.
	3. \textbf{Multicast Addresses}: Identify a group of interfaces. Packet sent to a multicast address is delivered to all of the interfaces in the group.
Not all routers can be upgraded simultaneously, so we tunnel IPv6 datagrams as a payload in the IPv4 datagrams for IPv4 routers.



    \section{Lec 16}


\textbf{Frame:} Encapsulates a network-layer datagram into a link-layer frame with header fields and data field. 
\textbf{MAC Protocol:} Defines rules for transmitting frames on a link; in point-to-point, sender sends when link is idle. 
\textbf{Services:} Provides framing, error detection (via bits), sometimes correction, and reliable delivery. 
\textbf{Error Detection:} Sender sets check bits; receiver verifies them; typically hardware-based and accurate. 
\textbf{Error Correction:} Detects location of bit errors and fixes them at receiver end. 
\textbf{NIC:} Network Interface Card = link-layer controller chip handling framing, access, errors; Intel 710 (Ethernet), Atheros AR5006 (Wi-Fi). 
\textbf{NIC Types:} Older NICs were PCI/PCMCIA cards; now mostly LAN-on-motherboard built-in chips. 
\textbf{Source:} NIC gets datagram from host memory, encapsulates it in frame, sends via link-access protocol. 
\textbf{Destination:} NIC receives frame, checks errors, extracts datagram, sends to network layer. 
\textbf{Hardware+Software:} Most link-layer functions in hardware; software triggers NIC, handles addressing & interrupts. 
\textbf{MAC Address:} Also called LAN or physical address; 6-byte hex, flat structure, globally unique, fixed per interface. 
\textbf{IEEE Role:} IEEE manages address space; vendors buy $2^{24}$ blocks; first 24 bits = vendor, last 24 = device-specific. 
\textbf{Fixed Identity:} MAC doesn't change by location (like SSN); IP changes by network (like postal address). 
\textbf{IP vs MAC:} IP = hierarchical, dynamic; MAC = flat, static; both needed for delivery & host identity. 
\textbf{ARP:} Address Resolution Protocol maps IP to MAC address to allow LAN frame delivery; key for host/router comm.



    \section{Lec 18}
    \textbf{32-bit IP}: network-layer address for interface, used for network layer forwarding.
    \textbf{MAC}: LAN/Physical/Ethernet address. Used locally to get "frame" from one interface to another physically connected interface (equivalent to subnets in IP-add). 48-bit MAC address burned in NIC ROM, sometimes software settable. Ex:1A-2F-BB-76-09-AD. Each interface on LAN has both of the above, MAC is unique, IP locally unique.MAC administered by IEEE,manufacturer buys portion of MAC add space to ensure uniqueness.MAC flat address, portable, can move interface from LAN to LAN. IP add not portable, depends on IP subnet to which node attached.
    \textbf{“dominant” wired LAN technology}: first used, cheap, simple, kept upto speed: 10mbps-400gbps, single chip multiple speeds(Broadcom BCM5761).
    \textbf{Bus:}(coax cable)Popular mid 90s,all nodes same collision domain(can collide each other).\textbf{Switched:}today,active link layer 2 switch in center, each "spoke" runs a seperate ethernet protocol(nodes do not collide).
    \textbf{sending interface encaps IPdatagram/network layer prot packet in Ethernet frame.}preamble:used synchronise receiver,sender clock rates 7bytes 10101010 followed by 1 byte 10101011,
    destadd,srcadd-6byte src and desti MAC add if adapter receives frame with matching dest add or with broadcast add(eg ARP packet) passes data in frame to netwrk layer prot otherwise discards,
    type-indicates higher layer prot(mostly Ip but others poss(Novell IPX, AppleTalk) used to demultiplex at receiver,
    data(payload),
    crc(cyclic redundancy check)-error detected=drop frame.
    \textbf{Connectionless:}no handshaking b/w NICs \textbf{Unreliable:}receving NIC doesnt send ACK or NAKs to sending NIC. dropped frame data recovered only if sender uses higher layer prots (TCP),otherwise lost.
    \textbf{Ethernets MAC prot:unslotted CSMA/CD with binary backoff}
    \textbf{Switch:}linklayer device-active role-store, forward Ethernet frames.examines incoming frames' MAC address, selectively forward frame to one/more outgoing links when frame tobe forwarded on segment, uses CSMA/CD to access segment.\textbf{Transparent: host unaware of switches}.\textbf{Plugnplay,self learning: switches dont need to be configd}.switches buffer packets,hosts have dedicated,direct connection to switch.\textbf{Eth prot used on each incoming link, no collision, full duplex, each link its own collision domain}switching: can transmit simultaneously,without collisions.Each switch has switch table (entry is MAC of host, interface to reach host, time stamp), looks like routing table.\textbf{Self-learning:switch learns which host can be reached through which interfaces}. when frame received,switch learns location of sender(incoming LAN seg). records sender/location pair in table.\textbf{frame dest unknown: flood. Known:selectively send on one} self learning switches can be connected together


    \section{Lec 19}
    \textbf{Physical layer:}Foundation,properties of wires,fiber and wireless limit,determines thoroughput,latency and error rate of network communication link.\textbf{Key Problem:}send (digital) bits using (analog) signals this is called modulation. Information: can be transmitted by varying some physical props(voltage,current,freq,phase).\textbf{Comm rates limits: Fourier Analysis,Bandwidth-limited signal, max data rate of a channel}.
    \textbf{Bandwidth:}ElecEng-analog bandwidth-Hz, CompSci-digital bandwidth-max data rate of a channel-bps
    \textbf{Fourier-Analysis:}time-varying signal can be equivalently represented as a series of frequency components (harmonics) or infinite number of sines and cosines.if signal period is t then f=1/t
    \textbf{Bandwidth limited signals:}less bandwidth means we lose some harmonics,degrades received signal
    \textbf{Transmission Media:}Media have diff properties,hence performance in terms of bandwidth,delay,cost,ease of installation,maintainence.\textbf{Guided media: Copper Wire(Twisted pairs, Coaxial cable, Power Lines), Fiber Optics(Single mode,multimode), Unguided-media(Terrestial wireless,satellite,lasers through the air)}
    \textbf{Wires-twisted pair:}Two insulated copper wires(LANs, telephone lines), twists reduce radiated signal(interference), signal carried as difference in voltage b/w the 2 wires. \textbf{Bandwidth depends on wire thickness and distance travelled}.Twisted-pair cabling categories: \textbf{Category 5(Cat 5):}4 twisted pairs grouped together(100 mbps ethernet uses 2 out of 4 pairs, one for each direction, 1GBPS uses all 4 pairs in both directions simultaneously) \textbf{Category 6(compatible cat 5):}UTP(unshielded twisted pair) 10Gbps, has more stringent specifications for crosstalk and system noise, up to 100m.\textbf{Category 7:}STP (Shielded twisted pair).
    \textbf{Link Terminology:}Full-duplex link:Used for transmission in both directions at same time. use different twisted pair for each direction.Half-duplex link: Both directions, not at the same time, ex: senders take turns on a wireless channel.Simplex Link: One fixed direction at all times, not common.
    \textbf{Coaxial Cable(co-ax):}2 concentric copper conductors.Common,more expensive than twisted pair.Better shielding,more bandwidth for longer distance and higher rates than twisted pair.Commonly used for video (cableTV) because needs larger bandwidth.Bidirectional,broadband(multiple channels on cable). 2 types: 50-ohm (for digital transmission), 75-ohm (analog transmission, now its for both dig,analog).
    \textbf{Power Lines:}Household electrical wiring, convenient use, horrible for sending data. Electricity at 50-60Hz, data at much higher freq.
    \textbf{Fiber Optic:}Glass fiber carrying light pulse, each pulse a bit. pulse-1 nolight-0. used for high speed point-to-point transmission (10's-100's GBps). Low error rate, thus repeaters spaced far apart(light immune to electromagnetic noise).Common for high data rates, long distance (backbone): long distance ISP links, fiber-to-the-home (FttH),light carried in very long thing strand of glass. \textbf{Three key parts:light source, transmission, medium, detector(generates electrical pulse when light falls on it.)}
    \textbf{Single-Mode:}Narrow core(10 micrometers)-light cant bounce,used with lasers for long distances(100km).
    \textbf{Multi-mode:}Core Diameter(50 micrometers)-light can bounce,each ray above critical incident said to have different mode, used with LED for cheaper, shorter distance links.
    \textbf{Computer connection various Configurations(topologies)-} Bus topology:All nodes connected to a single communication line that carries message in both directions, simple-low cost. Single cable called trunk(backbone,segment), only 1 computer can send message at a time, passive topology: computer only listens, does not regenerate data.
    \textbf{Star Topology:}Config centers around 1 node to which all other connected and thru which messages sent. each computer has cable connected to a single point, more cabling-higher cost, all transmissions thru hub(switch) if down then entire network down. depending on intelligence of hub, may send messages at the same time.
    \textbf{Ring Topology:} Config connects all nodes in closed loop on which messages travel in 1 direction.Every computer serves as repeater to boost signal, send data by token passing (only computer that gets the token can send data.One computer fails, whole network fails, difficult to add computers, more expensive.
    \textbf{Network Interface Card (NIC):}Network adapter, connects node to media, unique Machine Access Code(MAC address- 6 bytes long).
    \textbf{Network linking devices:}Connect nodes in the network, cable runs from node to device, crossover cable connects 2 computers together.
    \textbf{Hub:}Center of star network,all nodes receive transmitted packets, slow insecure.
    \textbf{Switches:}Replacement for hubs, only intended node receives transmission, fast secure.
    \textbf{Router:}Connects 2 or more LANs together, packets sent to remote LAN will cross, network segmented by IP add, Connect internal networks to the internet, need to be configd before installation.
    \textbf{Gateway:}Connect 2 dissimilar networks, connects coax to twisted pair, most gateways contained in other devices.
    \textbf{Electromagnetic Spectrum:}Signal carried in electromagnetic spectrum,The number of oscillations per second of a wave is called its frequency (f) and is measured in Hz,The time between two consecutive maxima (or minima) is called the period, T in seconds (T=1/f).
The distance between two consecutive maxima (or minima) is called the wavelength, $\lambda$ in meters.Electromagnetic waves travel at the speed of light(c) The fundamental relation between f, $\lambda$, and c (in a vacuum) is: $\lambda$
= c/f.


    \section{Lec 20}
    Unlicensed Industrial,Scientific and medical bands (ISM bands), free for use at low power,devices manage intereference, widely used for networking, wifi bluetooth, zigbee etc.
    \textbf{Wireless Access Network:}shared wireless access network connects end system to router via base station aka access point(AP).
    Wireless LANs: within building (100ft), 802.11g/n/ac (WiFi): 54/300/1000 Mbps transmission rate. Wide-are wireless access:Provided by telecom (cellular) operator, 10’s km,between 1 and 100 Mbps and more 3G,4G,LTE.
    \textbf{Wireless vs Wires/Fibres:}Wireless- (+)Easy Inexpensive,naturally supports mobility and broadcast(-)Transmissions interfere and must be managed,Signal strengths hence data rates vary greatly.Wires:(+)Easy to engineer a fixed data rate over point to point links(-)Expensive to deploy especially over distances,doesnt readily support mobility or broadcast.
    \textbf{Digital Modulation:}Process of converting data bits into signals.\textbf{Baseband Transmission:} Signal occupies freqs from 0 to a max, common for wires.\textbf{Passband Transmission:}Schemes that regulate amplitude,phase or freq of a carrier signal to convey bits. Signal occupies band of freqs around the frequency of the carrier signal.Common for wireless and optical channels.
    \textbf{Baseband Transmission types:}\textbf{NRZ (Non-Return-to-Zero):}Use a +ve voltage for 1 and -ve for 0. More levels of voltages, then the symbol carry more bits (symbol rate=baud rate).\textbf{Manchester encoding:}Mixes clock signal with data signal by XORing them together.Clock XOR'd with 0 level,makes a low-to-high transition-logical 0, when XOR'd with 1 level its inverted, makes high-to-low transition-logical 1.\textbf{NRZI (Non-Return-to-Zero-Inverted):}Same as NRZ but 1=transition 0=no transition.
    \textbf{Baseband Transmission coding scheme:}4B/5B Coding Scheme, introduced to limit the number of consecutive 0's or 1's. Every 4 bits is mapped into a 5bit pattern with a fixed translation table.
    \textbf{Passband Transmission:}Use a range of frequencies taht does not start at 0. for wireless channels not practical to send very low frequency signals because size of antenna($\lambda$/4) will be very large; $\lambda$=c/f.Frequencies are governed by a regulating body.Digital modulation is done with passband transmission by modulating carrier signal that sits in the passband,ASK(Amplitude Shift Keying), two different amplitudes are used to represent 0 and 1.FSK (Frequency Shift Keying), two or more different frequencies are used. PSK (Phase Shift Keying), the carrier wave is systematically shifted θ degrees at each symbol period, if 2 phases BPSK(Binary Phase Shift Keying)
    \textbf{Time Division Multiplexing (TDM):}users take turns (round-robin manner), each one periodically getting entire bandwidth for a little burst of time.
    \textbf{Public Switched Telephone Network:}Local Loop:=Fiber-To-The-Home (FTTH)-FTTH broadband relies on deployment of fiber optic cables for high data rates.one wavelength can be shared among many houses.Fiber passive(no amplifiers,etc), utpo 100mbps.
    \textbf{Internet over cable:}Reuse cable telivision plant. Data sent on shared cable tree from head-end not on dedicated line per subscriber (like DSL)
    \textbf{Frequency Division Multiplexing (FDM):} different channels transmitted in different frequency bands
    \textbf{Enterprise Access networks (Ethernet)}: Used in companies,unis, etc.10 Mbps, 100Mbps, 1Gbps, 10Gbps transmission rates.today, end systems typically connect into Ethernet switch
    
    \section{Lec 21}


\textbf{Confidentiality:} Only the sender and intended recipient should be able to understand the content of the transmitted message.  
\textbf{Message Integrity:} Ensures the message was not altered in transit, either maliciously or by accident.  
\textbf{End-Point Authentication:} Sender and receiver should be able to verify the identity of the other party to confirm they are who they claim to be; unlike face-to-face communication, network authentication requires cryptographic mechanisms.  
\textbf{Operational Security:} All public-facing organizational networks are susceptible to attacks like worms, DoS, and internal network mapping; a \textbf{firewall} controls packet access between private and public networks, and an \textbf{intrusion detection system (IDS)} performs deep packet inspection and alerts admins to suspicious activity.  
\textbf{Example Scenario:} Alice wants to securely send data to Bob. To maintain confidentiality, message integrity, and authentication, they exchange both control and data messages (like TCP). These may be encrypted.  
\textbf{Potential Attacks:} An intruder can eavesdrop (sniff/record control or data packets), or perform message modification, insertion, deletion, impersonation, session hijacking, or launch DoS attacks to overload systems and deny service.
\textbf{Cryptography:} Techniques that allow a sender to disguise data so intruders cannot gain meaningful information; the receiver can decrypt and retrieve original data.  
\textbf{Plaintext / Cleartext:} The original unencrypted message (e.g., “Bob, Hello Alice”).  
\textbf{Encryption:} Process of converting plaintext to ciphertext using an encryption algorithm.  
\textbf{Ciphertext:} The encrypted form of a message that appears unintelligible to intruders.
\textbf{Standardization:} Most Internet encryption algorithms are public, standardized, and known to all (e.g., RFC 1321, 3447, 2420; NIST 2001). Hence, secret \textbf{keys} are required to secure the encryption/decryption process.  
\textbf{Key (K):} A string of characters or numbers used in encryption/decryption.  
\textbf{K(m):} Ciphertext produced when plaintext message \texttt{m} is encrypted using key \texttt{K}.  
\textbf{Decryption:} The reverse process where the receiver (e.g., Bob) uses a key to decrypt ciphertext and retrieve the original plaintext.
\textbf{Symmetric Key Systems:} Also called private key systems. Alice and Bob use the same secret key for encryption and decryption. Key must be securely shared in advance.  
\textbf{Public Key Systems:} Also called asymmetric key systems. A key pair is used — one key (public) is shared with everyone, while the other (private) is kept secret. The public key encrypts, and the private key decrypts (or vice versa depending on context).


    


    
    \section{Lec 22}
    \textbf{Message Integrity (message authentication):} Digital Signature and end-point authentication.
    \textbf{A hash function} takes an input, m, and computes a fixed-size string H(m) known as a hash.
    A cryptographic hash function is required to be computationally infeasible to find any two different messages x and y such that H(x)=H(y) (thus, cannot substitute one message for another message that is protected by the hash).This shared secret, is a string of bits, is called the authentication key. Using this shared secret, message integrity can be performed.Message authentication code (MAC)=hash formed from string made by appending auth key(s) with message(m), MAC=H(m+s),this MAC again appended to message(not hashed message) creating extended message, receiver recalculates the mac with m and s then checks, if equal then correct.Signature attests to the fact that you (as opposed to someone else) have acknowledged and/or agreed with the document’s contents.digital signature is a cryptographic technique for indicating the owner or creator of a document, or to signify one’s agreement with a document’s content.the signature must be \textbf{verifiable} and the signature \textbf{cannot be forged}. \textbf{End-point authentication} is the process of one entity proving its identity to another entity over a computer network.performing authentication over the network, the communicating parties cannot rely on biometric information, such as a visual or voiceprint.authentication must be done solely based on messages and data exchanged as part of an authentication protocol.authentication protocol would run before the two communicating parties run some other protocol (ex, a reliable data transfer protocol, a routing information exchange protocol, or an e-mail protocol
    security services providable in any of the top four layers of the Internet protocol stack.security provided for a transport-layer protocol, all applications that use that protocol utilize the security services of the transport protocol.security provided at the network layer on a host-to- host basis, all transport-layer segments (and hence all application-layer data) utilize the security services of the network layer.security provided on a link basis, then the data in all frames traveling over the link receive the security services of the link.Why at more than one layer?Although security at the network layer can offer “blanket coverage” by encrypting all the data in the datagrams (that is, all the transport-layer segments) and by authenticating all the source IP addresses, it can’t provide user-level security. It is generally easier to deploy new Internet services, including security services, at the higher layers of the protocol stack. While waiting for security to be broadly deployed at the network layer
    
    
    
    
    \section{Lec 23}

\textbf{Network Security:} Branch of computer science focused on protecting network components to prevent unauthorized access, data theft, misuse of network resources, data modification, and service disruption. 
\textbf{Resource:} Any valuable object or system component requiring protection. 
\textbf{Vulnerability:} A weakness in a system that may be exploited by a threat. 
\textbf{Threat:} A potential danger to a resource or to the functioning of a network. 
\textbf{Attack:} An action carried out to harm or compromise a resource. 
\textbf{Risk:} Possibility of loss, modification, destruction, or negative consequences to a resource, arising from a threat exploiting a vulnerability. 
\textbf{Countermeasure:} A protective measure that mitigates threats or reduces risk.
\textbf{Types of Hackers:} 
\textbf{Hackers:} Individuals driven to explore systems, understand how they work, and test their knowledge and tools. 
\textbf{White Hat Hackers:} Perform audits to ensure network security of organizations. 
\textbf{Black Hat Hackers:} Engage in unauthorized activities for illegal purposes like data theft and account compromise. 
\textbf{Gray Hat Hackers:} Blend of white hat and black hat motivations. 
\textbf{Blue Hat Hackers:} Test software for bugs before public release. 
\textbf{Script Kiddies:} Use tools written by others without understanding underlying principles. 
\textbf{Hacktivists:} Driven by ideological or political motives. 
\textbf{Phreakers:} Specialize in exploiting telecommunication systems, e.g., to place free calls. 
\textbf{Carders:} Target smart card systems and exploit card-based security.
\textbf{Types of Malware:} 
\textbf{Spyware:} Spy software that installs without user permission, used to collect personal info, track browsing activity, and redirect HTTP requests to advertising sites. Not self-replicating. 
\textbf{Adware:} Displays ads, often in pop-up windows, without the user’s permission. 
\textbf{Scareware:} Convinces users their system is infected and prompts them to buy fake solutions. 
\textbf{Trojan Horse:} Program that appears useful but contains hidden malicious behavior, often enabling unauthorized system access. 
\textbf{Ransomware:} Encrypts system contents and demands payment (often in crypto) for access restoration. 
\textbf{Virus:} Attaches to legitimate programs to perform harmful tasks. Requires user execution; may remain idle to avoid detection. 
\textbf{Worms:} Self-propagating malware that spreads across networks by exploiting vulnerabilities, usually slows down system or network.
\textbf{Types of Network Security:} 
\textbf{Physical Security:} Protects physical environment (e.g., server rooms, network devices) against damage, fire, accidents, and unauthorized access. Includes UPS, surveillance, etc. 
\textbf{Logical Security:} Implements software-based access controls such as password policies, authentication/authorization models, firewall configs, VPNs, and intrusion prevention systems (IPS). 
\textbf{Administrative Security:} Uses manuals and processes to manage internal risks; defines responsibilities, prevents fraud, ensures material tracking, rational use of property, and operational efficiency.
\textbf{Types of Network Attacks:} 
\textbf{Reconnaissance Attacks (Passive):} Aim to collect data about the target network and identify vulnerabilities. 
\textbf{Ping Sweep:} Sends ICMP echo requests to multiple IPs to identify live hosts. 
\textbf{Port Scanning:} Analyzes open TCP/UDP ports to identify active services. 
\textbf{Packet Sniffing:} Captures Ethernet frames traveling over the network to gather MAC/IP/port info and even usernames/passwords. Tools: Wireshark, TCPDump.
\textbf{Access Attacks:} Target sensitive data in transit or storage. 
\textbf{Phishing:} Uses fake emails/URLs to extract credentials or financial data (e.g., pretending to be a bank). 
\textbf{Pharming:} Redirects web traffic to fake sites. 
\textbf{Man-in-the-Middle (MITM):} Attacker intercepts communication between two parties to eavesdrop or alter data. 
\textbf{Spoofing:} Fakes identity of source via MAC/IP/port/DNS to trick receivers or firewalls. 
\textbf{Hijacking:} Attacker takes over a session by spoofing one side of the connection.
\textbf{Availability Attacks:} 
\textbf{DoS(Denial-of-Service):} Renders a service unavailable via two methods: 
\textbf{1.Saturation:} Floods target with fake requests to block legitimate ones. 
\textbf{2.Exploiting Vulnerability:} Crashes or disables remote system using known software flaws. 
\textbf{DDoS(Distributed DoS):} Conducted from many computers simultaneously, often from geographically distributed bots. 
\textbf{SYN Flood:} Sends many TCP SYN requests without completing the handshake. 
\textbf{ICMP Flood:} Sends fake ICMP packets to overwhelm target.
\textbf{Security Measures:} 
\textbf{Separation of Resources:} Segregate sensitive data into isolated zones; enforce strict monitoring for database access. 
\textbf{Deep Protection:} Layered deployment of security tools across different points of the network. 
\textbf{Least Privilege Rule:} Users should only have minimum access needed for their roles. 
\textbf{Adequate Protection:} All security mechanisms should be reliable, complete, and updated. 
\textbf{Restrict Information Access:} Provide data only required for specific tasks. 
\textbf{Separation of Duties + Job Rotation:} Reduces risk by preventing one person from having too much control and encourages policy enforcement.
\textbf{Vulnerability Audit Measures:} 
\textbf{Preventive Measures:} Prevent vulnerabilities using firewalls, physical locks, and administrative security policies. 
\textbf{Detective Measures:} Monitor and detect intrusions using system logs, IPS, anti-spoofing tools, and surveillance. 
\textbf{Corrective Measures:} Identify and fix root causes after a security breach, update systems and software. 
\textbf{Recovery Measures:} Restore systems to working state after an incident. 
\textbf{Deterrence Measures:} Put in place mechanisms (policies, awareness, penalties) to discourage attacks.
\includegraphics[width=\linewidth]{img/socketProg.png} 


}