TECHNOLOGY 

Published on

KembaraXtra-Computer Science - The Internet Protocol Suite

Overview

The internet protocol suite standardizes communication on the internet.

Key protocols: Transmission Control Protocol (TCP) and Internet Protocol (IP), collectively known as TCP/IP.

Network protocols operate in a layered model called a network stack.

Layered Model (TCP/IP Model)

Four-layer model (TCP/IP model):

  • Link
  • Internet
  • Transport
  • Application

Protocols at each layer interact with adjacent layers only (encapsulation).

Each layer has specific responsibilities handled by protocols within that layer.

OSI Model

Another network model with seven layers.

Less relevant as the internet is based on the TCP/IP model.

Table of Layers and Protocols

Layer Description Example Protocols
Application Provides application-specific functionality (e.g., email, web pages). Structures data for process-to-process communication. HTTP, SSH
Transport Provides a communication channel for applications to send and receive data between hosts. TCP, UDP
Internet Enables communication across networks. Responsible for host addressing and routing data across the internet. IP
Link Enables communication on a local network. Closely associated with networking hardware (e.g., Wi-Fi). Ethernet, Wi-Fi

Data Transmission Flow

Outgoing Transmission: Travels down the network layers (Application → Transport → Internet → Link).

Incoming Transmission: Travels up the network layers (Link → Internet → Transport → Application).

Network hosts (clients, servers) use all four layers.

Networking hardware (switches, routers) often use only lower layers.

Detailed Layer Breakdown

1. Link Layer

Connects devices on the same local network.

Uses Media Access Control (MAC) addresses to uniquely identify devices.

Data is divided into frames (header, payload, footer).

Frame Header: Contains source and destination MAC addresses, data type descriptor.

Payload: Contains the data being transmitted.

Frame Footer: Used for error detection.

Examples:

  • Wi-Fi (IEEE 802.11): Wireless communication.
  • Ethernet (IEEE 802.3): Wired communication using RJ45 connectors.

Networking devices:

  • Hub: Retransmits frames to all ports.
  • Switch: Examines MAC addresses and sends frames to the correct port.

2. Internet Layer

Allows data to travel beyond the local network (routing).

Uses Internet Protocol (IP) for addressing and routing.

Every host has an IP address.

Data is sent in packets (enclosed in a link layer frame).

IP Packet Header: Contains source and destination IP addresses, IP version, header length.

Data Section: Payload.

IP Versions:

  • IPv4: 32-bit addresses (dominant). Displayed in dotted decimal notation (e.g., 192.168.1.23).
  • IPv6: 128-bit addresses.

Subnets:

  • Devices on the same local network have IP addresses with the same leading bits.
  • Devices on different subnets communicate through a router.
  • IP address divided into: network prefix (shared by subnet) and host identifier (unique to host).
  • CIDR Notation: IP address/prefix length (e.g., 192.168.1.23/24).
  • Subnet Mask: 32-bit number indicating the network prefix (e.g., 255.255.255.0 for a 24-bit prefix).
  • Network ID: Result of a bitwise AND between an IP address and subnet mask. Identifies the subnet.
  • To determine if two computers are on the same subnet: perform a bitwise AND on both IPs with the subnet mask. If the result is the same, they are on the same subnet.
  • Range of usable addresses: First and last address are reserved; others can be used by hosts.

3. Transport Layer

Provides a communication channel for applications.

Protocols:

  • TCP (Transmission Control Protocol): Reliable, connection-oriented. Data is sent in segments.
  • UDP (User Datagram Protocol): Unreliable, "best effort." Data is sent in datagrams.

TCP segment fits within an IP packet's data section.

Network Port Numbers: Identify specific services/processes on a host.

  • Well-known ports: 0–1023
  • Registered ports: 1024–49151
  • Dynamic ports: 49152+

Servers listen on well-known ports. Clients use ephemeral ports.

Socket: An IP address plus a port number. Represents a network endpoint.

4. Application Layer

Focuses on specific application tasks.

Examples:

  • HTTP (web content)
  • SMTP (email)
  • FTP (file transfer)

Application data is contained in the transport layer segment's data section.

Frame Structure

A frame contains:

  • Link layer header and footer
  • IP packet (header and data)
  • TCP segment (header and data)
  • Application data

Transmission Process Summary

Sending: Application data → Segment → Packet → Frame

Receiving: Frame → Packet → Segment → Application data

Picture
Published on
KembaraXtra-Computer Suite - Networking as Computing
Core Idea:
  • Networking isn't separate from computing; it's a part of it. The internet is a vast, distributed computing system.
Key Components:
  • Hardware & Software: The internet and networks rely on both.
    • Hardware: Cables, routers, switches, network interface cards (NICs).
    • Software: Protocols, operating systems, device drivers, application libraries.
  • Data Representation: Data transmitted over networks is ultimately represented as bits (0s and 1s). These bits are physically encoded (e.g., as voltages).
  • Networking Interface as I/O: A network interface card (NIC) (like Wi-Fi or Ethernet) is treated by a computer as an input/output (I/O) device.
Operating System's Role:
  • Device Drivers: The OS uses device drivers to communicate with NICs.
  • Software Libraries: The OS provides libraries that simplify network communication for applications.
  • Abstraction: The OS hides the low-level details of networking, allowing applications to send and receive data more easily.
Networking Devices:
  • Routers and switches are specialized computers.
  • They perform specific tasks like routing network traffic.
The Big Picture:
  • Extension of Local Computing: Networking extends computing beyond a single device.
  • Data Transfer & Processing: It enables data to be transferred and processed across different machines and locations.
Picture
Published on
KembaraXtra-Case Law- Security in Operating Systems
I. What is Security in the Context of Operating Systems?
  • Definition: Security means that software and users should only access appropriate parts of the system. Access is restricted to minimize damage from mistakes or malicious software.
  • Why is it Important?
    • Single-User Systems: Even on personal devices, users can make mistakes (e.g., running untrustworthy code). The OS limits damage from accidental execution of malicious software.
    • Multi-User Systems: Users should not be able to access or modify other users' data without permission.
II. Security Techniques Implemented by Operating Systems
  • User Mode Bubble:
    • Isolates applications, preventing them from interfering with other applications or the kernel.
  • Filesystem Security:
    • Controls access to files and data, allowing only authorized users and processes to access specific files.
  • Virtual Memory Security:
    • Memory regions can be marked as read-only or executable.
    • Helps prevent memory misuse (e.g., executing data as code).
  • Login System:
    • Allows the OS to manage security based on user identity.
    • Enforces access control based on user permissions.
III. Maintaining Security
  • Baseline Expectations: The above techniques are basic security measures in modern OS.
  • Vulnerabilities: Security flaws are frequently discovered, allowing malicious actors to bypass defenses.
  • Importance of Updates: Keeping internet-connected OS updated is essential to address vulnerabilities and maintain security.
Picture
Published on
KembaraXtra-Case Law- Services and Daemons
Core Concept: Background Processes
  • Definition: Services (Windows) and daemons (Unix-like systems) are processes that run automatically in the background, without direct user interaction.
  • Purpose: Provide system-level capabilities that:
    • Are not tied to a specific user.
    • Do not require kernel-mode privileges.
    • Need to be available on demand.
  • Examples:
    • Configuring network settings
    • Running scheduled tasks
Service/Daemon Management
  • Responsibility: Operating systems have components to manage services/daemons. This includes:
    • Starting services/daemons at boot.
    • Starting services/daemons in response to events.
    • Restarting services/daemons after failures.
Windows: Service Control Manager (SCM)
  • Function: Manages Windows services.
  • Executable: services.exe
  • Startup: Started early in the boot process and runs continuously.
Linux: systemd
  • Function: Manages daemons (and acts as the init process).
  • Status: Standard daemon manager for many modern Linux distributions.
  • Startup: Started very early in the boot process and runs continuously.
Terminology
  • Daemon Origin: Inspired by Maxwell's demon, a background "helper" in a physics experiment.
  • Pronunciation: "DAY-mon" (common in computing) or "demon" are both acceptable when referring to background processes.
  • Service vs. Daemon: Historically, "service" was Windows-specific, but is now also used on Linux, often for daemons managed by systemd.
Picture
Published on
KembaraXtra-Computer Science- Filesystems
1. Storage Devices & Partitions
  • Secondary Storage: Devices like HDDs and SSDs used for persistent data storage (data remains even when the power is off).
  • Partitions: Storage devices are divided into regions called partitions.
  • Filesystems: Operating systems use filesystems to organize data on storage devices into files and directories. A partition must be formatted with a particular filesystem before it can be used by the operating system.
  • Formatting: Preparing a partition with a specific filesystem.
  • Filesystem Examples:
    • Linux: ext2, ext3, ext4 (ext family)
    • Windows: FAT (File Allocation Table), NTFS (NT File System)
  • Volumes: Some OSes use "volumes" as a logical abstraction built on one or more partitions. Filesystems reside on volumes in this case.
2. Files and Directories
  • File: A container for data. The structure of the data is defined by the program that created the file.
  • Directory (Folder): A container for files and other directories.
3. Directory Structures
  • Unix-like Systems (e.g., Linux):
    • Unified Hierarchy: A single, tree-like structure of directories.
    • Root Directory: The top-level directory, represented by /. All other directories are descendants of the root.
    • Example: /usr/lib (lib is a subdirectory of usr, which is a subdirectory of root)
    • Mounting: Attaching an additional storage device to a location in the directory structure (e.g., a USB drive mounted to /mnt/usb1).
  • Microsoft Windows:
    • Drive Letters: Each volume is assigned a drive letter (A-Z).
    • Separate Hierarchies: Each drive has its own root and directory structure.
    • Directory Paths: Use backslashes (\) in directory paths and a colon (:) after a drive letter.
    • Example: C:\windows\system32
    • Historical Context: Drive letters A and B were initially reserved for floppy disks. C is typically the drive for the Windows installation.
Picture
Published on
KembaraXtra-Computer Science - Application Binary Interface (ABI)
1.

KembaraXtra-Computer Science - The Internet Protocol Suite

Overview

The internet protocol suite standardizes communication on the internet.

Key protocols: Transmission Control Protocol (TCP) and Internet Protocol (IP), collectively known as TCP/IP.

Network protocols operate in a layered model called a network stack.

Layered Model (TCP/IP Model)

Four-layer model (TCP/IP model):

  • Link
  • Internet
  • Transport
  • Application

Protocols at each layer interact with adjacent layers only (encapsulation).

Each layer has specific responsibilities handled by protocols within that layer.

OSI Model

Another network model with seven layers.

Less relevant as the internet is based on the TCP/IP model.

Table of Layers and Protocols

Layer Description Example Protocols
Application Provides application-specific functionality (e.g., email, web pages). Structures data for process-to-process communication. HTTP, SSH
Transport Provides a communication channel for applications to send and receive data between hosts. TCP, UDP
Internet Enables communication across networks. Responsible for host addressing and routing data across the internet. IP
Link Enables communication on a local network. Closely associated with networking hardware (e.g., Wi-Fi). Ethernet, Wi-Fi

Data Transmission Flow

Outgoing Transmission: Travels down the network layers (Application → Transport → Internet → Link).

Incoming Transmission: Travels up the network layers (Link → Internet → Transport → Application).

Network hosts (clients, servers) use all four layers.

Networking hardware (switches, routers) often use only lower layers.

Detailed Layer Breakdown

1. Link Layer

Connects devices on the same local network.

Uses Media Access Control (MAC) addresses to uniquely identify devices.

Data is divided into frames (header, payload, footer).

Frame Header: Contains source and destination MAC addresses, data type descriptor.

Payload: Contains the data being transmitted.

Frame Footer: Used for error detection.

Examples:

  • Wi-Fi (IEEE 802.11): Wireless communication.
  • Ethernet (IEEE 802.3): Wired communication using RJ45 connectors.

Networking devices:

  • Hub: Retransmits frames to all ports.
  • Switch: Examines MAC addresses and sends frames to the correct port.

2. Internet Layer

Allows data to travel beyond the local network (routing).

Uses Internet Protocol (IP) for addressing and routing.

Every host has an IP address.

Data is sent in packets (enclosed in a link layer frame).

IP Packet Header: Contains source and destination IP addresses, IP version, header length.

Data Section: Payload.

IP Versions:

  • IPv4: 32-bit addresses (dominant). Displayed in dotted decimal notation (e.g., 192.168.1.23).
  • IPv6: 128-bit addresses.

Subnets:

  • Devices on the same local network have IP addresses with the same leading bits.
  • Devices on different subnets communicate through a router.
  • IP address divided into: network prefix (shared by subnet) and host identifier (unique to host).
  • CIDR Notation: IP address/prefix length (e.g., 192.168.1.23/24).
  • Subnet Mask: 32-bit number indicating the network prefix (e.g., 255.255.255.0 for a 24-bit prefix).
  • Network ID: Result of a bitwise AND between an IP address and subnet mask. Identifies the subnet.
  • To determine if two computers are on the same subnet: perform a bitwise AND on both IPs with the subnet mask. If the result is the same, they are on the same subnet.
  • Range of usable addresses: First and last address are reserved; others can be used by hosts.

3. Transport Layer

Provides a communication channel for applications.

Protocols:

  • TCP (Transmission Control Protocol): Reliable, connection-oriented. Data is sent in segments.
  • UDP (User Datagram Protocol): Unreliable, "best effort." Data is sent in datagrams.

TCP segment fits within an IP packet's data section.

Network Port Numbers: Identify specific services/processes on a host.

  • Well-known ports: 0–1023
  • Registered ports: 1024–49151
  • Dynamic ports: 49152+

Servers listen on well-known ports. Clients use ephemeral ports.

Socket: An IP address plus a port number. Represents a network endpoint.

4. Application Layer

Focuses on specific application tasks.

Examples:

  • HTTP (web content)
  • SMTP (email)
  • FTP (file transfer)

Application data is contained in the transport layer segment's data section.

Frame Structure

A frame contains:

  • Link layer header and footer
  • IP packet (header and data)
  • TCP segment (header and data)
  • Application data

Transmission Process Summary

Sending: Application data → Segment → Packet → Frame

Receiving: Frame → Packet → Segment → Application data

Picture
Published on
KembaraXtra-Computer Science - Operating System Software Libraries
I. Introduction
  • An Operating System API is a programmatic interface for interacting with the OS.
  • Software libraries provide the concrete implementation for invoking the OS API.
II. OS Software Libraries
  • Definition: A collection of code included with the OS that implements the OS API.
  • Similarity to Other Libraries: Similar to programming language standard libraries or community-maintained libraries.
  • Format:
    • A file containing machine code.
    • Typically lacks an entry point, so it can't run alone.
    • Exports a set of functions for use by programs.
  • Usage: Programs import (link to) functions from the library to use them.
  • Implementation:
    • Some functions are simple wrappers for kernel system calls.
    • Other functions are fully implemented in user mode code within the library.
    • Some functions implement logic in user mode but also make system calls.
III. Examples
  • Linux: GNU C Library (glibc)
    • Provides access to Linux kernel system calls.
    • Includes the C programming language's standard library functions (some of which don't require system calls).
    • Filename example: libc.so.6 (.so = shared object, 6 = version).
    • Widely used in Linux distributions, so considered part of the standard Linux API.
  • Windows API Libraries
    • Core Libraries:
      • kernel32.dll: Exposes system calls from the NT kernel to user-mode programs.
      • user32.dll: Exposes system calls related to windowing and user interface.
      • gdi32.dll: Exposes system calls related to graphics.
    • .dll Extension: Indicates a dynamic link library (shared library code that a process can load and run).
    • "32" Suffix: Remnant from the 16-bit to 32-bit Windows transition, retained for compatibility. 64-bit Windows includes both 32-bit and 64-bit versions of these files.
IV. Direct System Calls (Alternative, but Not Recommended)
  • Method: Programs can bypass the software library by:
    • Setting values in processor registers.
    • Issuing a processor-specific instruction (e.g., SVC on ARM, SYSCALL on x86).
  • Drawbacks:
    • Requires assembly language programming.
    • Code is not portable across processor architectures.
    • Doesn't provide access to OS API functions not implemented as system calls.
V. Windows Subsystem for Linux (WSL)
  • Challenge: Linux and Windows have different system calls and executable formats, making software incompatible.
  • WSL Solution: Allows running many 64-bit Linux programs on Windows without modification.
  • WSL Versions:
    • WSL1: Intercepts Linux system calls and handles them within the NT kernel.
    • WSL2: Uses a real Linux kernel running in a virtual machine alongside the NT kernel.



Picture
Published on

KembaraXtra-Computer Science - APIs and System Calls

Key Concepts

System Call:

A mechanism for user-mode code to request services from the kernel mode.

Defines a way for applications to interact with the OS involving kernel intervention.

Operating System API (Application Programming Interface):

Describes a way for applications to interact with the OS, regardless of whether kernel-mode code is invoked.

A broader concept than system calls.

Some API functions will make system calls, while others will not.

Relationship between API and System Calls

APIs are not the same as system calls, but they are related.

System calls are a subset of the functionality exposed by an API.

An API can be implemented using system calls, but it can also provide functionality without directly using them.

Examples

Linux

Linux API (Kernel): Can be seen as a specification for using Linux system calls directly.

Android: Uses the Linux kernel, but has its own higher-level programming interfaces called Android Platform APIs.

Windows

Windows NT Kernel: Provides system calls through the Native API.

Generally not used directly by application developers.

Windows API: Acts as a wrapper around the Native API.

Provides a more user-friendly interface for developers.

Windows API Examples

CreateFileW:

Windows API function that creates or opens a file.

A wrapper around the Native API function NtCreateFile.

Requires a system call because it needs kernel-level access to manage files.

PathFindFileNameW:

Windows API function that extracts a filename from a path.

Does not make a system call.

Can be handled entirely in user mode, requiring only virtual memory access.

Summary

Feature System Call Operating System API
Purpose Request kernel-mode services Provide a programmatic interface to the OS
Scope Kernel mode operations Broader; includes both kernel and user mode operations
Implementation Direct interaction with the kernel Can be implemented with or without system calls
Abstraction Level Low-level Higher-level, often more user-friendly
Picture
Published on
KembaraXtra- Computer Science - User Mode Bubble and System Calls
I. User Mode Limitations
  • Definition: Code running in user mode has restricted system access.
  • Capabilities:
    • Read/Write to its own virtual memory.
    • Perform mathematical and logical operations.
    • Control program flow of its own code.
  • Limitations:
    • Cannot access physical memory addresses (including memory-mapped I/O).
    • Cannot directly perform I/O operations (e.g., printing, keyboard input, graphics, sound, network communication, file access).
  • "User Mode Bubble": Analogy representing user mode's isolation from direct hardware interaction.
  • Practical Effect: User mode code can do work but requires assistance to share results.
II. System Calls: Bridging the Gap
  • Definition: A request from user mode code for kernel mode code to perform a privileged operation on its behalf.
  • Purpose: Allows user mode applications to interact with the outside world (perform I/O).
  • Mechanism:
    1. User mode code requests a specific operation (e.g., reading from a file).
    2. The kernel (with device drivers) performs the operation.
    3. The kernel returns the results to the user mode process.
  • Kernel's Role:
  • Acts as an intermediary between user mode code and hardware resources.
  • Provides an abstraction layer, hiding hardware details.
  • Constraints: The kernel enforces security and access control policies (e.g., preventing unauthorized file access).
III. System Call Implementation
  • CPU Instructions: Specific instructions facilitate system calls.
    • ARM: SVC (Supervisor Call).
    • x86: SYSCALL, SYSENTER.
  • System Call Numbers: Each system call is identified by a unique number.
    • Example (Linux ARM): write (file writing) is number 4.
  • Process:
i.Load the system call number into a specific processor register.
ii.Put parameters into other registers.
iii.Execute the system call instruction.
IV. System Calls in Practice
  • Abstraction: Developers typically don't make system calls directly.
  • OS APIs and Standard Libraries: Operating systems and programming languages provide interfaces for system calls (e.g., open, CreateFileA).
  • Transparency: Programmers write code at a higher level and may not be aware of the underlying system calls.
Picture
Published on
KembaraXtra-Conputer Science - API Study Guide
I. Core Concept: Application Programming Interface (API)
  • Definition: A specification that defines how a program interacts with an operating system (OS).
  • Purpose: Allows applications to request services from the OS (e.g., creating files, accessing hardware).
  • Components:
    • Functions: Specific actions an application can request (e.g., open(), CreateFileA(), fopen()).
    • Data Structures: Formats for data passed between the application and the OS.
  • Implementation: APIs are implemented in software libraries that are included with the OS.
II. API vs. User Interface (UI)
  • UI (Shell):
    • Interface for users to interact with the OS (e.g., taskbar, Start menu, command line).
    • Translates user commands into API calls.
  • API:
    • Interface for applications to interact with the OS.
    • Applications call the API directly, bypassing the UI.
III. How APIs Work: Example - Creating a File
  1. User Action (via UI): User clicks "New File" in a graphical shell.
  2. Shell Translation: The UI translates the click into an API call (e.g., a function call to create a file).
  3. API Call: The API function is invoked (e.g., open() in Unix/Linux, CreateFileA() in Windows).
  4. OS Action: The OS code (behind the API) executes the request, creating the file.
  5. Application Action (via API): The application directly invokes open() or CreateFileA() to create a file.
IV. API Examples in Different Languages
  • C:
    • Direct access to OS APIs.
    • Example (Unix/Linux): open("hello.txt", O_WRONLY|O_CREAT);
    • Example (Windows): CreateFileA("hello.txt", GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
  • C (Standard Library):
    • Provides portable functions that work across different OSes.
    • Internally calls the OS-specific API.
    • Example: fopen("hello.txt", "w");
  • Python:
    • Uses a Python interpreter to handle OS-specific API calls.
    • The interpreter translates Python code into the correct OS API calls.
    • Example: open('hello.txt', 'w')
V. API Standards and Implementations
  • POSIX (Portable Operating System Interface):
    • Standard for Unix-like systems (Linux, macOS, etc.).
    • Defines standards for the OS API, shell behavior, and utilities.
  • macOS/iOS:
    • Cocoa (macOS): Apple's API for macOS.
    • Cocoa Touch (iOS): Apple's API for iOS.
  • Android:
    • Android Platform APIs: A set of programming interfaces for Android development.
  • Windows:
    • Win16: Original 16-bit Windows API.
    • Win32: 32-bit Windows API.
    • Win64: 64-bit Windows API.
    • Universal Windows Platform (UWP): Introduced in Windows 10 to provide a consistent API across different Windows devices.
Picture