<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hiren Soni on Medium]]></title>
        <description><![CDATA[Stories by Hiren Soni on Medium]]></description>
        <link>https://medium.com/@hirensoni007?source=rss-dd0092b4d483------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bW2ElWJ8p-TrdhU2JED1Kw.png</url>
            <title>Stories by Hiren Soni on Medium</title>
            <link>https://medium.com/@hirensoni007?source=rss-dd0092b4d483------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 20:44:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hirensoni007/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[One API Call, Many Lies: Where Your Backend Time Really Goes]]></title>
            <link>https://blog.stackademic.com/one-api-call-many-lies-where-your-backend-time-really-goes-b9eb162c294c?source=rss-dd0092b4d483------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9eb162c294c</guid>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[latency-optimization]]></category>
            <dc:creator><![CDATA[Hiren Soni]]></dc:creator>
            <pubDate>Mon, 19 Jan 2026 17:30:23 GMT</pubDate>
            <atom:updated>2026-01-19T19:36:12.963Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Your code says the API takes 20 milliseconds.</strong> <strong>Your monitoring says 280 milliseconds.</strong></p><p><strong>And somehow, everyone starts optimizing the wrong thing.</strong></p><p>This is the quiet gap between what developers measure and what users experience. It is a gap filled with invisible work — work that doesn’t show up in your method timers, standard profilers, or Big-O discussions, but absolutely dominates real-world latency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CUF_hwZPFypkB7uIiNxiXg.png" /></figure><p>Let’s follow a single API call and expose the lies it tells along the way.</p><h3>The Comforting Lie: “My Code Is Fast”</h3><p>Most backend engineers start with a familiar ritual. You wrap your service method with a timer. You log the execution time. You proudly discover it finishes in <strong>15–25 ms</strong>.</p><p>You conclude: <em>The code is fast.</em></p><p>That conclusion is technically correct — and operationally useless.</p><p>Why? Because users don’t experience your method. They experience everything that happens <strong>before, around, and after it.</strong></p><h3>1. Before Your Code Even Runs</h3><p>The request hasn’t touched your business logic yet, but time is already leaking.</p><p>There is DNS resolution — maybe cached, maybe not. Then the TLS handshake, unless a connection is luckily reused. Then a load balancer hop. Sometimes two. A cold DNS lookup or fresh TLS handshake alone can quietly add tens of milliseconds before your code even wakes up.</p><p>If you’re unlucky, the request waits in a queue simply because all worker threads are busy. No CPU spike. No error logs. Just silence.</p><p><strong>None of this shows up in your method timer.</strong></p><h3>2. Inside the Server: The Illusion of Execution</h3><p>Now your code finally runs. But even here, the clock lies.</p><p>Your thread might be descheduled mid-execution by the OS. The JVM might pause briefly for Garbage Collection. CPU cache misses quietly add nanoseconds that accumulate into milliseconds.</p><p>Your “15 ms” function didn’t run in a vacuum. It ran in a crowded city.</p><h3>3. The Database Isn’t Slow — The Line Is</h3><p>Then comes the database call. You measure query execution time: <strong>8 ms</strong>. Looks great.</p><p>But the total DB call took <strong>120 ms</strong>.</p><p><em>Why?</em></p><p>Because most of that time wasn’t execution — it was waiting. Under load, a “fast” query can sit 100–200 ms just waiting for a free connection while the database itself is barely breaking a sweat.</p><ul><li>Waiting for a free connection from the pool.</li><li>Waiting for row locks.</li><li>Waiting behind other expensive queries.</li><li>Waiting due to network jitter between the app and the DB.</li></ul><p><strong>Databases are fast. Contention is not.</strong></p><h3>4. Serialization: Death by a Thousand Cuts</h3><p>The response is ready. Now it must be shipped.</p><p>Objects become JSON. JSON becomes bytes. Bytes get copied — sometimes multiple times across memory buffers.</p><p>Each step is “cheap” in isolation. Together, they are expensive. And usually, they remain invisible in most application dashboards.</p><h3>5. The Network Trip Back Home</h3><p>The response leaves your service.</p><p>It crosses the load balancer again. It goes through encryption (TLS). It traverses the public internet. It hits a mobile network that decides <em>now</em> is a good time to drop a packet.</p><p>Congratulations. Your <strong>20 ms</strong> API is now a <strong>300 ms</strong> experience.</p><h3>Why Metrics Lie</h3><p>Averages tell comforting stories. <strong>p95 and p99 tell the truth.</strong></p><p>One slow GC pause. One DB connection spike. One cold thread. Suddenly, users are complaining while your dashboards stay green.</p><p>The system didn’t break. It <em>hesitated</em>. And hesitation is what users feel.</p><h3>The Real Problem: Engineers Optimize the Wrong Thing</h3><p>When latency rises, teams react instinctively:</p><ul><li>They rewrite code.</li><li>They change sorting algorithms.</li><li>They add caching everywhere.</li></ul><p>But most latency doesn’t live in algorithms. It lives in infrastructure:</p><ul><li><strong>Queues </strong>with growing depth while CPU looks fine.</li><li><strong>Connection Pools </strong>where threads block on getConnection() even though the database is idle.</li><li><strong>Network Hops </strong>added by “just one more” service on the critical path.</li><li><strong>Schedulers </strong>that delay work because the right worker is busy.</li><li><strong>Memory Pressure </strong>that nudges the GC into more frequent or longer pauses.</li></ul><blockquote><em>You can’t optimize what you don’t see.</em></blockquote><h3>The Honest Question to Ask</h3><p>Stop asking: <em>“How fast is my code?”</em></p><p>Start asking: <strong>“Where does the time go between request arrival and response delivery?”</strong></p><p>That question changes how you design systems, how you choose metrics, and how you debug performance.</p><h3>Final Truth</h3><p>A single API call is a story told by many layers. Your code is only one paragraph. If you don’t read the whole story, you’ll keep fixing the wrong sentence.</p><p><strong>This leaves us with one big question: How do we actually see these invisible layers?</strong></p><p>In my next post, I will break down exactly how to catch these ghosts using the right tools.</p><p>Follow me so you don’t miss the toolkit that turns these invisible problems into visible metrics.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9eb162c294c" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/one-api-call-many-lies-where-your-backend-time-really-goes-b9eb162c294c">One API Call, Many Lies: Where Your Backend Time Really Goes</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Beyond Big-O: Why Algorithm Theory Fails Production Reality]]></title>
            <link>https://blog.stackademic.com/beyond-big-o-why-algorithm-theory-fails-production-reality-26a0555b2e64?source=rss-dd0092b4d483------2</link>
            <guid isPermaLink="false">https://medium.com/p/26a0555b2e64</guid>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[big-o-notation]]></category>
            <category><![CDATA[optimization]]></category>
            <dc:creator><![CDATA[Hiren Soni]]></dc:creator>
            <pubDate>Sun, 18 Jan 2026 17:52:19 GMT</pubDate>
            <atom:updated>2026-01-20T17:43:32.570Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e6euc226bXd-eHxqSILOWg.jpeg" /></figure><p>Why Better Time Complexity Does Not Guarantee Faster APIs</p><p><strong>Picture the scenario:</strong></p><ul><li>You’ve identified a bottleneck.</li><li>You refactor a brute-force approach, optimizing the core algorithm from something like O(n²) to O(n log n).</li><li>The benchmarks look great in isolation.</li><li>The code review goes smoothly.</li><li>The PR is merged.</li></ul><p><strong><em>And yet… the API is still slow.</em></strong></p><p>This moment is a rite of passage for backend engineers. It is the point where computer science theory collides with production reality, and a hard truth emerges: Better time complexity does not guarantee a faster system.</p><p>Big-O helps us reason about scalability and growth. Users, however, experience delay — milliseconds, jitters, and timeouts. While these concepts are related, they are fundamentally different metrics.</p><p>Here is why your “optimized” code might still feel slow in production.</p><h3>The Trap of the Constant Factor</h3><p>Big-O is an asymptotic model. It intentionally abstracts away hardware details to focus on growth rates. It tells you that as n approaches infinity, Algorithm A will beat Algorithm B.</p><p>But in the real world, n is rarely infinite, and those “abstracted details” are exactly what the CPU executes.</p><p>Mathematically, O(n) is really k · n, where k represents the constant overhead of an operation.</p><ul><li>Algorithm A might be O(n) with complex hashing and branching (high k).</li><li>Algorithm B might be O(n²) but consists of simple integer additions (tiny k).</li></ul><p>For moderate input sizes, the “slower” Algorithm B can outperform the “faster” Algorithm A. Extra function calls, heavy branching, object instantiation, and complex arithmetic are invisible in Big-O analysis, but very visible on the CPU clock.</p><blockquote>The takeaway: Big-O ignores constants, but CPUs do not.</blockquote><h3>The Memory Wall: A Java Case Study</h3><p>Modern performance is often less about how many instructions you execute and more about where you fetch your data.</p><p>CPUs are blazingly fast, but main memory (RAM) is comparatively slow. To mitigate this, CPUs rely on caches (L1, L2, L3).</p><p>• Sequential access (like iterating over an array) allows the CPU to prefetch data efficiently.<br>• Random access (like traversing a linked list or a complex tree) forces the CPU to stall while waiting for data from RAM.</p><p>An algorithm with “worse” complexity that respects locality of reference will often beat a “better” algorithm that jumps around in memory.</p><p>Proof: ArrayList vs LinkedList</p><p>In Big-O theory, iterating over a list to sum integers is O(n) regardless of the underlying data structure. Theory suggests they should perform similarly.</p><p>Let’s test that theory in Java:</p><pre>import java.util.ArrayList;<br>import java.util.LinkedList;<br>import java.util.List;<br>import java.util.Random;<br><br>public class ListPerformance {<br>    public static void main(String[] args) {<br>        int size = 10_000_000; // 10 million elements<br><br>        // 1. Setup Data<br>        List&lt;Integer&gt; arrayList = new ArrayList&lt;&gt;(size);<br>        List&lt;Integer&gt; linkedList = new LinkedList&lt;&gt;();<br>        Random rand = new Random();<br><br>        for (int i = 0; i &lt; size; i++) {<br>            int val = rand.nextInt();<br>            arrayList.add(val);<br>            linkedList.add(val);<br>        }<br><br>        // 2. Test ArrayList<br>        long start = System.nanoTime();<br>        long sum = 0;<br>        for (Integer n : arrayList) {<br>            sum += n;<br>        }<br>        long durationArray = System.nanoTime() - start;<br><br>        // 3. Test LinkedList<br>        start = System.nanoTime();<br>        sum = 0;<br>        for (Integer n : linkedList) {<br>            sum += n;<br>        }<br>        long durationLinked = System.nanoTime() - start;<br><br>        // 4. Results<br>        System.out.printf(&quot;ArrayList Time:  %.2f ms%n&quot;, durationArray / 1_000_000.0);<br>        System.out.printf(&quot;LinkedList Time: %.2f ms%n&quot;, durationLinked / 1_000_000.0);<br>    }<br>}</pre><p>Example result:</p><blockquote>ArrayList Time: ~15.00 ms<br>LinkedList Time: ~32.00 ms</blockquote><p>The LinkedList is over 2x slower despite having the exact same time complexity.</p><p><strong>Why?</strong><br>ArrayList stores data contiguously. When the CPU fetches index 0, it automatically pulls the next few indices into the fast L1 cache. LinkedList scatters nodes across memory (“pointer chasing”), causing constant cache misses.</p><h3>The I/O Elephant in the Room</h3><p>In distributed systems, pure computation is rarely the primary bottleneck.</p><p>You might shave 500 microseconds off your data processing logic by optimizing a sort. But if that same request requires:</p><p>• A database round-trip (10 ms), or<br>• An external API call (200 ms),</p><p>your optimization is statistically irrelevant.</p><p><strong>I/O acts as a floor for latency</strong>.<br>From a user’s perspective, reducing total request time from 250 ms to 249.5 ms is imperceptible. If the database query is slow, the algorithmic efficiency of the application layer does not matter.</p><h3>Small Inputs: Where Big-O Loses Power</h3><p>Big-O describes behavior as n approaches infinity. But what if your n is usually 50 or 100?</p><p>Most production web requests handle relatively small payloads: a list of user permissions, a page of search results, or a shopping cart. At these sizes, asymptotic growth has not kicked in. Instead, initialization costs dominate.</p><p>Setting up the data structures for a sophisticated O(n log n) algorithm might take longer than simply running a double-loop O(n²) check on 50 items. If your workload consists of millions of tiny requests, the “naive” solution is often the fastest one.</p><h3>Recursion vs Iteration: The Hidden Cost</h3><p>A particularly revealing case is recursion versus iteration. Both can have identical time complexity O(n), yet they behave very differently.</p><p>Big-O counts the number of operations. Whether you loop N times or call a function recursively N times, the abstract operation count is roughly the same.</p><ul><li><strong>Recursion:</strong> Every single step adds a new “Stack Frame” to memory. This frame stores the return address, local variables, and parameters. It consumes memory and CPU cycles to create and destroy these frames.</li><li><strong>Iteration:</strong> Uses a single stack frame. It simply updates the values of existing variables in CPU registers.</li></ul><p>Let’s test that theory in Java:</p><pre>public class RecursionVsIteration {<br>    public static void main(String[] args) {<br>        // Warning: Large N causes StackOverflow in recursion<br>        long n = 15_000; <br>        int iterations = 10_000;<br><br>        // 1. Test Recursion<br>        try {<br>            long start = System.nanoTime();<br>            for(int i=0; i&lt;iterations; i++) {<br>                recursiveSum(n);<br>            }<br>            long durationRec = System.nanoTime() - start;<br>            System.out.printf(&quot;Recursion Time: %.2f ms%n&quot;, durationRec / 1_000_000.0);<br>        } catch (StackOverflowError e) {<br>            System.out.println(&quot;Recursion failed: StackOverflowError!&quot;);<br>        }<br><br>        // 2. Test Iteration<br>        long start = System.nanoTime();<br>        for(int i=0; i&lt;iterations; i++) {<br>            iterativeSum(n);<br>        }<br>        long durationIter = System.nanoTime() - start;<br>        System.out.printf(&quot;Iteration Time: %.2f ms%n&quot;, durationIter / 1_000_000.0);<br>    }<br><br>    // O(N) Recursion<br>    static long recursiveSum(long n) {<br>        if (n == 0) return 0;<br>        return n + recursiveSum(n - 1);<br>    }<br><br>    // O(N) Iteration<br>    static long iterativeSum(long n) {<br>        long sum = 0;<br>        for (long i = 1; i &lt;= n; i++) {<br>            sum += i;<br>        }<br>        return sum;<br>    }<br>}</pre><p>Example result:</p><blockquote>Recursion Time: 452.78 ms<br>Iteration Time: 49.03 ms</blockquote><p>To the Big-O observer, they are equivalent. To the production runtime, the iterative approach is almost always more stable and predictable.</p><h3>The Noisy Neighbor Problem</h3><p>Big-O assumes your algorithm is running in a vacuum with uninterrupted CPU access.</p><p>Production environments are chaotic:</p><ul><li><strong>Garbage collection</strong>: A perfectly efficient O(n) operation can pause for hundreds of milliseconds if the GC stops the world.</li><li><strong>Resource contention</strong>: Threads compete for CPU time, locks block execution, and context switching adds jitter.</li></ul><p>An algorithm that relies on heavy locking might be theoretically efficient but practically slow due to contention. A lock-free algorithm doing “more work” can finish sooner because it avoids system-level waits.</p><h3><strong>The Verdict: Latency vs Throughput</strong></h3><p>Time complexity is a tool for predicting throughput — how much work the system can handle as load grows. Users, however, care about latency — how long they wait right now.</p><p>A system can scale beautifully (good Big-O) yet still feel sluggish due to queuing, network hops, or cold starts.</p><p>Does this mean Big-O is useless? Absolutely not. It is essential for preventing architectural disasters and ensuring your system does not collapse when the user base doubles. But it is a safety guardrail, not a stopwatch.</p><p>Great engineers understand the theory, but they trust the telemetry. When performance matters, stop staring at Big-O notation and start staring at the profiler.</p><blockquote><strong>Big-O predicts growth. Users experience delay.</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26a0555b2e64" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/beyond-big-o-why-algorithm-theory-fails-production-reality-26a0555b2e64">Beyond Big-O: Why Algorithm Theory Fails Production Reality</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Journey of Single Click]]></title>
            <link>https://blog.stackademic.com/journey-of-single-click-4401ea07c468?source=rss-dd0092b4d483------2</link>
            <guid isPermaLink="false">https://medium.com/p/4401ea07c468</guid>
            <category><![CDATA[osi]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[layer-2]]></category>
            <category><![CDATA[network]]></category>
            <dc:creator><![CDATA[Hiren Soni]]></dc:creator>
            <pubDate>Thu, 08 Jan 2026 04:32:56 GMT</pubDate>
            <atom:updated>2026-01-12T07:11:04.931Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Journey of a Single Click: How Data Travels Through the 7-Layer OSI Model</h3><p>What really happens in the milliseconds between clicking a link and seeing a webpage appear?</p><p>In under <strong>200 milliseconds</strong>, your request may traverse dozens of routers, cross multiple countries, switch physical media, and pass through several abstraction layers — long before a single pixel is rendered on your screen.</p><p>It feels instantaneous.</p><p>But beneath the surface, a precisely coordinated, highly engineered process is unfolding.</p><p>To understand how data reliably travels across your room or around the world, engineers use a conceptual framework called the <strong>OSI (Open Systems Interconnection) Model</strong>. It breaks networking into <strong>seven distinct layers</strong>, each with a clearly defined responsibility. While modern networks implement the TCP/IP model in practice, the OSI model remains invaluable for understanding, designing, and debugging networked systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PjcdtfYEnrwl0Z0QXPkUFg.png" /></figure><p>In this article, we’ll trace a simple network request — loading https://example.com—as it travels <strong>down through the seven OSI layers</strong>, across the network, and <strong>back up again</strong> on the receiving server.</p><h3>The Fundamental Concept: <strong>Encapsulation</strong></h3><p>Before diving into the layers, we must understand <strong>Encapsulation</strong>.</p><p>Think of it like sending a delicate letter.</p><ol><li>You write the letter (<strong>data</strong>).</li><li>You put it in an envelope (<strong>header</strong> added)</li><li>You put that envelope in a courier bag (<strong>header</strong> added)</li><li>The courier puts the bag in shipping container (<strong>header</strong> added)</li></ol><p>Networking works the same way.</p><p>As data moves <strong>down the OSI layers</strong> on the sender’s side, each layer wraps the data from the layer above with its own header (and sometimes a trailer). This wrapping process is called <strong>encapsulation</strong>.</p><p>When the data reaches its destination, the process reverses. Each layer removes its corresponding header — this is <strong>decapsulation</strong> — until the original data reaches the receiving application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6i7IzEhCJa8uG59tzoXvoA.png" /></figure><h3>The Journey Down: Sender Side</h3><p>Let’s trace what happens when you type <a href="https://example.com/">https://example.com</a> into your browser and press <strong>Enter</strong>.</p><blockquote>At each layer, the data has a specific name called a <strong>Protocol Data Unit (PDU)</strong>.</blockquote><h4>Layer 7: Application Layer</h4><p>This is the layer closest to the user. It doesn’t include the application itself (like Chrome or curl), but rather the <strong>protocols</strong> that applications use to communicate over the network.</p><p><strong>Action:</strong></p><ul><li>Your browser generates an HTTP request asking the server for a resource.</li></ul><p><strong>PDU: </strong>Raw application data. Below code block showing layer 7 data when sending get request through curl.</p><pre>#Layer 7: HTTP Request<br><br>GET / HTTP/1.1<br>Host: example.com<br>User-Agent: curl/8.4.0<br>Accept: */*</pre><p><strong>Common protocols: </strong>HTTP, HTTPS, SMTP, POP3, IMAP, DNS, FTP</p><h4>Layer 6: Presentation Layer</h4><p>This layer ensures data is <strong>readable and secure</strong> for the receiving system.</p><p><strong>Action:</strong></p><ul><li>Translates data formats (e.g., ASCII vs Unicode)</li><li>Encrypts data when using HTTPS (via TLS)</li><li>Optionally compresses data</li></ul><blockquote>In real-world TCP/IP stacks, TLS spans multiple layers, but it maps conceptually to the Presentation layer in OSI.</blockquote><p><strong>PDU: </strong>Still referred as Data but now its formatted, compressed and secured.</p><pre>#Layer 6: Encrypted &amp; Compressed Binary data of HTTP Request (conceptually)<br><br>9f a3 4b 7c 91 e2 ...</pre><p><strong>Common protocols/formats: </strong>SSL, TLS, ASCII, EBCDIC</p><h4>Layer 5: Session Layer</h4><p>This layer manages <strong>sessions</strong> — logical conversations between applications.</p><p><strong>Action:</strong></p><ul><li>Establishes, maintains, and terminates communication sessions</li><li>Ensures the request belongs to the correct conversation</li></ul><blockquote>In modern networking, Session-layer responsibilities are often handled by the Application or Transport layers, but OSI keeps it separate for conceptual clarity.</blockquote><p><strong>PDU: </strong>Still referred as Data. (No modification in payload)</p><h4>Layer 4: Transport Layer</h4><p>Now we get to the heavy lifting of ensuring data arrives correctly. This layer receives the large chunk of data from the upper layers and prepares it for transport.</p><p><strong>Action:</strong></p><ul><li>It breaks the large amount of data into smaller manageable chunks called <strong>Segments</strong>.</li><li>Adds port numbers to ensure the message gets to the right application on the computer.</li><li>Handles reliability, ordering, and retransmission (TCP)</li></ul><p><strong>PDU: </strong>Referred as a Segment (for TCP) or Datagram (for UDP)</p><pre>#Layer 4: PDU generated by upper layers converted into one/many segments <br>┌────────────────────────────────────────┐<br>│ Source Port      : 52344               │<br>│ Destination Port : 443                 │<br>│ Sequence Number  : 1029384756          │<br>│ Acknowledgment   : 5566778899          │<br>│ Flags            : PSH, ACK            │<br>│ Window Size      : 64240               │<br>│ Checksum         : 0xA91C              │<br>└────────────────────────────────────────┘<br>│ Payload Partition-0(Data).             │<br>│ [Encrypted / Encoded / Raw bytes]      │<br>└────────────────────────────────────────┘</pre><p><strong>Common protocols:</strong> TCP (Transmission Control Protocol), UDP (User Datagram Protocol)</p><h4>Layer 3: Network Layer</h4><p>This layer is responsible for routing data across different networks to its final destination.</p><p><strong>Action:</strong></p><ul><li>Adds logical addressing (IP addresses)</li><li>Determines the best path to the destination</li><li>Routers operate primarily at this layer</li></ul><p>It does logical addressing, basically it wraps the TCP Segment into an IP Packet. It adds as header containing the Source IP address and the Destination IP address. Routers examine the destination IP address and consult their routing tables to determine the best path.</p><p><strong>PDU: </strong>Referred as a Packet</p><pre>#Layer 3: Wrapped Segment referred as Packet<br>┌───────────────────────────────────────────┐<br>│ Version          : 4                      │<br>│ Header Length    : 20 bytes               │<br>│ Total Length     : 552 bytes              │<br>│ Identification   : 0x1C46                 │<br>│ Flags / Offset   : DF                     │<br>│ Time To Live     : 64                     │<br>│ Protocol         : 6 (TCP)                │<br>│ Header Checksum  : 0xB861                 │<br>│ Source IP        : 192.168.1.10           │<br>│ Destination IP   : 93.184.216.34          │<br>└───────────────────────────────────────────┘<br>│ Payload (Layer 4 Segment)                 │<br>│ [TCP Header + Data]                       │<br>└───────────────────────────────────────────┘</pre><p><strong>Common protocols :</strong> IPv4, IPv6, ICMP</p><h4>Layer 2: Data Link Layer</h4><p>The Network layer handles the long-distance journey; the Data Link layer is responsible for the immediate next hop — getting the data from your computer’s network card to your Wi-Fi router.</p><p><strong>Action:</strong></p><ul><li>Wraps packets into frames</li><li>Uses <strong>MAC addresses</strong></li><li>Performs error detection using CRC/FCS</li></ul><p>It does physical addressing, basically it wraps the IP Packet into a Frame. It adds a header containing the MAC (Media Access Control) addresses. The destination MAC is not the final server, but the immediate next device(your router). It also does error detection, it adds a trailer (FCS — Frame check sequence) to the end of the frame to ensure the data wasn’t corrupted during the hop to the router.</p><blockquote>At every router hop, the Layer 2 frame is stripped and rebuilt with new MAC addresses, while the IP packet remains intact.</blockquote><p><strong>PDU: </strong>Referred as a Frame</p><pre>#Layer 2: Wrapped Packet, now referred as Frame<br>┌──────────────────────────────────────────────┐<br>│ Destination MAC : 00:1A:2B:3C:4D:5E          │<br>│ Source MAC      : 08:00:27:AA:BB:CC          │<br>│ EtherType       : 0x0800 (IPv4)              │<br>└──────────────────────────────────────────────┘<br>│ Payload (Layer 3 Packet)                     │<br>│ [IP Header + TCP Segment + Data]             │<br>└──────────────────────────────────────────────┘<br>│ Frame Check Sequence (CRC)                   │<br>└──────────────────────────────────────────────┘</pre><p><strong>Common protocols :</strong> Ethernet (IEEE 802.3), Wi-Fi (IEEE 802.11), PPP (Point-to-Point Protocol)</p><h4>Layer 1: Physical Layer</h4><p>This is where bits meet physics.</p><p><strong>Action:</strong></p><ul><li>Converts binary data into physical signals</li><li>No headers, no addresses — just signalsThe Network Interface Card (NIC) takes the binary 1s and 0s that make up the Frame and converts them into physical signals suitable for the medium.</li><li>If Ethernet: Electrical voltage pulses over copper wire.</li><li>If Wi-Fi: Radio frequency waves through the air.</li><li>If Fiber: Pulses of light down a glass strand.</li></ul><blockquote>At this layer, there are <strong>no addresses, no headers, and no protocols to interpret</strong> — just raw bits transmitted according to electrical, optical, or radio standards.</blockquote><p><strong>PDU: </strong>Stream of Bits</p><pre>#Layer 1: Conceptual Bit stream<br>10110010 11001001 00101101 ...</pre><p><strong>Common standards:</strong> RJ45, USB, Bluetooth, DSL, ISDN</p><h3>The Journey Back Up: Receiver Side</h3><p>The physical signals travel across the internet, hopping from router to router. At the destination server, the entire process happens in exact reverse order (<strong>Decapsulation</strong>).</p><p>The server’s physical layer receives signals and turns them into bits. The Data Link layer checks the MAC address and strips the frame header. The Network layer checks the IP and strips the IP header. This continues up to the Application layer, which finally receives the raw “Get me the homepage” request and processes it.</p><p>The server then generates a response, encapsulates it through the same OSI layers in reverse order, sends it back across the network, and the sender side decapsulates the response to finally render the webpage in the browser.</p><h3>Why the OSI Model Still Matters</h3><p>The OSI model isn’t about memorizing layers — it’s about knowing <strong>where to look when things break</strong>.</p><ul><li>TLS handshake failing? → Layer 6 / 7</li><li>Packet loss or retransmissions? → Layer 4</li><li>Wrong IP or routing issue? → Layer 3</li><li>Network cable unplugged? → Layer 1</li></ul><p>Even though real networks use TCP/IP, the OSI model remains one of the most powerful mental tools for understanding and debugging how the internet works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LDNyomOdUM2URQMqlwjHIw.png" /></figure><p>Every click you make still follows this journey — quietly, reliably, and incredibly fast.</p><p>Thanks for reading…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4401ea07c468" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/journey-of-single-click-4401ea07c468">Journey of Single Click</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>