<?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 Shabnam Rasoulian on Medium]]></title>
        <description><![CDATA[Stories by Shabnam Rasoulian on Medium]]></description>
        <link>https://medium.com/@shabnam.rasoulian?source=rss-f3789d669eb8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HEFVspf8IOgiNmQKaLWg9w.jpeg</url>
            <title>Stories by Shabnam Rasoulian on Medium</title>
            <link>https://medium.com/@shabnam.rasoulian?source=rss-f3789d669eb8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 08:06:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shabnam.rasoulian/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[A gentle introduction to TCP/IP (transport layer)]]></title>
            <link>https://medium.com/@shabnam.rasoulian/a-gentle-introduction-to-tcp-ip-transport-layer-de0f27816d1c?source=rss-f3789d669eb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/de0f27816d1c</guid>
            <category><![CDATA[tcp]]></category>
            <category><![CDATA[internet]]></category>
            <category><![CDATA[ip]]></category>
            <category><![CDATA[network]]></category>
            <dc:creator><![CDATA[Shabnam Rasoulian]]></dc:creator>
            <pubDate>Mon, 01 Oct 2018 01:24:03 GMT</pubDate>
            <atom:updated>2018-10-01T01:24:50.149Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://medium.com/@shabnam.rasoulian/a-gentle-introduction-to-tcp-ip-network-layer-e88ef73518df">Network layer</a> functionalities enable us to deliver packets from one machine to another machine on the network, but that is not enough to write a network application because:</p><ul><li>Machines can run multiple applications and we need to know which application should receive a packet.</li><li>Network layer can drop or reorder packets. Applications, on the other hand, usually require guaranteed (i.e., loss-less) and in-order delivery of bytes.</li></ul><p>TCP addresses the first issue by defining port numbers. Port numbers are essentially identifiers, helping TCP distinguish between the applications running on machine. In other words, each port number on a machine is owned by an application on that machine. Port numbers are 2-byte integers and port 0 is not usable. As a result we can have up to 65536 ports on a machine.</p><p>Using port numbers, TCP defines “connection”. A TCP connection is identified by source and destination IP addresses (from the network layer) along with source and destination port numbers. This is also known as the 4-tuple:</p><pre>(src ip, dst ip, src port, dst port)</pre><p>TCP provides guaranteed and in-order delivery of bytes for each connection in the network. To do that, TCP uses sequence numbers and acknowledgement. Every packet sent over a connection has a sequence number and a length. The sequence number indicates the offset of the byte in the stream. For example, a packet with sequence number of #2000 and length of 100, contains the 2000th-2099th bytes on this connection. When the receiver receives all the bytes up to and including the 2099th byte, it sends an acknowledgement #2100, meaning that it has received the byte before the 2100th byte.</p><p>Before starting bytes on a connection, we need to start and establish that connection. To do so, TCP uses 3-way handshake using synchronize (SYN) packets:</p><ul><li>Step 1) The client sends a SYN packet from its IP address and port number to the server’s IP address and port number.</li><li>Step 2) The server replies to that SYN packet with a SYN that acknowledges the client’s SYN packet. This is often called a SYN+ACK packet, because it has a SYN and an acknowledgment.</li><li>Step 3) Then the client acknowledges the server’s SYN.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*zRE_If0QitORysJ2giC7YA.png" /><figcaption>TCP 3-way handshake.</figcaption></figure><p>After the 3-way handshake, the client and server can exchange bytes on the connection. Based on acknowledgements from the receiver, TCP automatically detects lost packets and retransmits them, to provide guaranteed delivery. It is important to note that TCP is bidirectional: there is an stream of bytes from client to server, and there is a separate stream of bytes from server to client.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*TjwyBajywlo5GIYRANwFww.png" /><figcaption>A simple HTTP request over TCP.</figcaption></figure><p>When we are done with our connection we send finalize (FIN) packets to terminate the connection. We can also abort connections on error using reset packets (RST).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de0f27816d1c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A gentle introduction to TCP/IP (network layer)]]></title>
            <link>https://medium.com/@shabnam.rasoulian/a-gentle-introduction-to-tcp-ip-network-layer-e88ef73518df?source=rss-f3789d669eb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/e88ef73518df</guid>
            <category><![CDATA[tcp]]></category>
            <category><![CDATA[routing]]></category>
            <category><![CDATA[ip]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Shabnam Rasoulian]]></dc:creator>
            <pubDate>Sun, 30 Sep 2018 23:03:51 GMT</pubDate>
            <atom:updated>2018-11-19T17:43:47.343Z</atom:updated>
            <content:encoded><![CDATA[<p>The network layer is the third layer in the network stack that provides the data routing paths for inter-networking. The most prominent protocol in this layer is the Internet Protocol (IP), and as a result this layer is also called the IP layer. IP, at its core, provides two major functionalities: addressing and routing.</p><p>The original version of IP is IPv4 which has 32-bit addresses. These addresses are usually denoted as base-10 integers for each byte separated by dots. For example, 1.2.3.4 means first byte of the address is 4, second is 3, third is 2 and fourth is 1. However, 32-bit addresses would only support 2³² (4 billion) unique addresses, and guess what? we already have more than 4 billion nodes in the network. IPv6 the most recent version of the IP protocol has 128-bit addresses which means it can support 2¹²⁸ (4 billion *4 billion *4 billion * 4 billion) addresses. Well, that should be enough, at least for the near future ;-).</p><p>Today, most machines have both IPv4 and IPv6 addresses. If you run ifconfig, you can see the IPv4 and IPv6 addresses of your machine. Mine are <strong>192.168.1.8 </strong>and<strong> fe80::1809:d41a:a9a:d664 </strong>, respectively.</p><pre>% ifconfig<br>..<br><strong>en0</strong>: flags=8863&lt;UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500<br> ether 88:e9:fe:4c:83:5b<br> <strong>inet6</strong> <strong>fe80::1809:d41a:a9a:d664</strong>%en0 prefixlen 64 secured scopeid 0x8<br> <strong>inet</strong> <strong>192.168.1.8</strong> netmask 0xffffff00 broadcast 192.168.1.255<br> nd6 options=201&lt;PERFORMNUD,DAD&gt;<br> media: autoselect<br> status: active</pre><p>Now that we have briefly covered addressing, let’s talk about routing. IP routing is built based on rules using address prefixes. For example, a routing rule would say: <em>“if the first 2 bytes of the destination IP address is 187.50 send it on interface eth1”</em>. The IP prefix is usually denoted using “/”. For example, 187.50.0.0/16 means the first 2 bytes of an IP address is 187.50. As another example, 187.50.10.2/31 means the first 31 bits of the IP address should be 187.50.10.2 and we don’t care about the 32nd bit.</p><p>If you run “netstat -rn” on your machine, you can see the routing table on your machine. For example, my routing table says any IP packet matching 224.0.0.0/4 should be sent to link#8. If you look closely, you can see a “default” row. That row is a special rule saying that any packet that doesn’t match any other rule should be routed using this rule. It’s like the “default clause” in switch/case statements.</p><pre>% netstat -rn<br>Routing tables</pre><pre>Internet:<br>Destination Gateway            Flags        Refs      Use   Netif <br>default     192.168.1.1        UGSc           54        0     en0<br>224.0.0/4   link#8             UmCS            2        0     en0</pre><pre>Internet6:<br>Destination   Gateway       Flags         Netif Expire<br>fe80::%lo0/64 fe80::1%lo0   UcI           lo0</pre><p>All nodes on the internet have these routing tables, and this is how IP packets are routed to reach their destination.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*W-V2KYFJywON5ZBtgLUOHA.png" /><figcaption>Example of how routing works in a network.</figcaption></figure><p>If you want to see how your packets are routed in your network to reach google.com, run the following command:</p><pre>traceroute google.com</pre><p>Now that we know how packets are sent from one machine to another machine, let’s carry on to <a href="https://medium.com/@shabnam.rasoulian/a-gentle-introduction-to-tcp-ip-transport-layer-de0f27816d1c">TCP</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e88ef73518df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A gentle introduction to TCP/IP (link layer)]]></title>
            <link>https://medium.com/@shabnam.rasoulian/a-gentle-introduction-to-tcp-ip-link-layer-fcccb323a23e?source=rss-f3789d669eb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcccb323a23e</guid>
            <category><![CDATA[ip]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[tcp]]></category>
            <dc:creator><![CDATA[Shabnam Rasoulian]]></dc:creator>
            <pubDate>Sun, 30 Sep 2018 23:01:30 GMT</pubDate>
            <atom:updated>2018-10-01T01:25:05.847Z</atom:updated>
            <content:encoded><![CDATA[<p>In any network, as in any graph, each node has immediate neighbors. Link layer protocols provide the functionality needed to communicate among immediate neighbors which are directly connected via a link (e.g., physical link like a CAT5 cable, or a radio link as in WiFi).</p><p>The most famous link layer protocol is Ethernet. In Ethernet, each interface has a unique 48-bit (6 byte) address called the Media Access Control(MAC) address. If you run ifconfig on your machine, you will see the name of the network interfaces along with their MAC address. For example, on my machine the MAC address of <strong>en0</strong> is <strong>88:e9:fe:4c:83:5b</strong>.</p><pre>% ifconfig<br>...<br><strong>en0</strong>: flags=8863&lt;UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500<br> <strong>ether</strong> <strong>88:e9:fe:4c:83:5b</strong><br> inet6 fe80::1809:d41a:a9a:d664%en0 prefixlen 64 secured scopeid 0x8<br> inet 192.168.1.8 netmask 0xffffff00 broadcast 192.168.1.255<br> nd6 options=201&lt;PERFORMNUD,DAD&gt;<br> media: autoselect<br> status: active</pre><p>As you can see each byte in the MAC address is presented by its hexadecimal value separate by a colon.</p><p>Network packets sent over Ethernet links has a source and destination MAC address. To discover its neighbors, an Ethernet uses broadcast queries and announcements. Using these broadcast mechanisms, another protocol called ARP finds the mapping between neighbor’s MAC and IP addresses. If you run the arp on your machine you can see this mapping. For example, my WiFi access point has 192.168.1.1 as its IP address and 9c:3d:cf:d2:f6:d as its MAC address.</p><pre>% arp -a -n<br>? (<strong>192.168.1.1</strong>) at <strong>9c:3d:cf:d2:f6:d</strong> on en0 ifscope [ethernet]<br>? (192.168.1.5) at 80:a5:89:10:2:6f on en0 ifscope [ethernet]<br>? (192.168.1.7) at 40:9c:28:eb:9c:f6 on en0 ifscope [ethernet]<br>? (192.168.1.9) at 54:60:9:14:b2:6e on en0 ifscope [ethernet]<br>? (192.168.1.158) at 38:1:95:7:f2:7b on en0 ifscope [ethernet]</pre><p>Now that we have a mapping between MAC and IP address, let’s carry on to the <a href="https://medium.com/@shabnam.rasoulian/a-gentle-introduction-to-tcp-ip-network-layer-e88ef73518df">network layer</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcccb323a23e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A gentle introduction to TCP/IP]]></title>
            <link>https://medium.com/@shabnam.rasoulian/a-gentle-introduction-to-tcp-ip-be112e199566?source=rss-f3789d669eb8------2</link>
            <guid isPermaLink="false">https://medium.com/p/be112e199566</guid>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[internet]]></category>
            <category><![CDATA[ip]]></category>
            <category><![CDATA[tcp]]></category>
            <dc:creator><![CDATA[Shabnam Rasoulian]]></dc:creator>
            <pubDate>Sun, 30 Sep 2018 23:00:34 GMT</pubDate>
            <atom:updated>2018-11-19T17:39:11.116Z</atom:updated>
            <content:encoded><![CDATA[<p>The primary use-case of computer networks is to communicate between two machines on the network; that is, sending and receiving data. Now, let’s take a moment to think what is required to send some text from <em>AppA</em> on <em>Machine1</em> to <em>AppB</em> on <em>Machine2.</em></p><ul><li><strong>Addressing</strong>: We need <em>Machine1</em> and <em>Machine2</em> to be uniquely identifiable on the network. That’s why every host on the internet has been assigned at least one IP address.</li><li><strong>Routing</strong>: Now, let’s assume <em>Machine1</em> knows the address of <em>Machine2. </em>But, they may not be directly connected. So, we need a way for the elements on the network to route data and deliver it to the destination.</li><li><strong>Application multiplexing</strong>: With addressing and routing combined, we can deliver packets between <em>Machine1</em> and <em>Machine2</em>. But there may be many apps running on these machines. For example, the data for iMessage should be delivered to iMessage not the Chrome browser running on my laptop. So, we need a way to identify <em>AppA</em> and <em>AppB</em>, and multiplex data accordingly.</li><li><strong>Guaranteed in-order delivery</strong>: In our use-case, we want to deliver a text in exactly the same form it was sent, no character less, no character more, and in the same order. After all, if <em>AppA</em> sends “Hello”, <em>AppB</em> should receive “Hello”, not “elloH” nor “Helo”.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*Mon312dtFLAdeSz7vmRI2Q.png" /><figcaption>Functionalities required to send “HELLO” from App A to App B.</figcaption></figure><p>These functionalities are often categorized into a layered design, where each layer provides a basic/common functionality to its upper layer.</p><ul><li>The <strong>Physical Layer</strong> is the layer where data is physically moved across the network interface.</li><li>The <strong>Link Layer</strong> is responsible for data transmission into and out of a physical layer and provides point-to-point data transfer between immediate neighbors on the network.</li><li>The <strong>Internet Protocol (IP) Layer</strong> uses IP addresses to transmit data between any node on the network. This layer determines the best route between two machines in the computer network and connects them.</li><li>The <strong>Transmission Control Protocol (TCP) Layer</strong> guarantees the in-order delivery of the data and app multiplexing.</li><li>The <strong>Application Layer,</strong> at the very top of the network layer ensures the end-user services.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*WcycZHJUqfhm2mdQzudk6Q.png" /><figcaption>Layers of the networking stack. Each layer provides basic and common functionalities needed for its upper layer.</figcaption></figure><p>In the next sections, I will explain the details of each layer. Let’s start with the <a href="https://medium.com/@shabnam.rasoulian/a-gentle-introduction-to-tcp-ip-link-layer-fcccb323a23e">link layer</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be112e199566" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>