<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ computer network - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ computer network - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Thu, 21 May 2026 10:21:50 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/computer-network/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ What is DNS? Basics for Beginners ]]>
                </title>
                <description>
                    <![CDATA[ When you access a website like www.google.com, would it surprise you to learn that the URL isn't really the website address?  There is some work "under the hood" to ensure that, when you type in a human friendly name like Google, it takes you to the ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/what-is-dns-for-beginners/</link>
                <guid isPermaLink="false">66bc55f9d94fa6cb67b84529</guid>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ dns ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Kealan Parr ]]>
                </dc:creator>
                <pubDate>Tue, 25 Jul 2023 18:07:28 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/02/dns.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>When you access a website like <a target="_blank" href="https://www.google.com/">www.google.com</a>, would it surprise you to learn that the URL isn't <em>really</em> the website address? </p>
<p>There is some work "under the hood" to ensure that, when you type in a human friendly name like Google, it takes you to the website you're expecting it to.  </p>
<p>So, what's happening under the hood?</p>
<h1 id="heading-what-are-urls">What are URLs?</h1>
<p>You may be familiar with what a URL is. It's a simple link to a bit of content on the web. People use URL's daily to share videos, pictures, sites, articles – almost anything on the internet.</p>
<p>URL is an acronym for <strong>Uniform Resource Locator,</strong> and we can break them down into multiple smaller "pieces". Here's what makes up a standard URL:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/02/image-264.png" alt="Image" width="600" height="400" loading="lazy">
<em>Anatomy of a URL showing the Scheme, Domain Name, Path, and Parameters</em></p>
<p>A <strong>URL</strong> is just an address for a resource. The resources differ like we discussed, but they're just pointers all over the internet to take you to content you want to view.</p>
<p>As you can see in the graphic above, the breakdown of a URL is often:</p>
<ul>
<li><strong>Scheme:</strong> this is the protocol a browser uses to access your content. Normally for websites it's HTTP (insecure), or HTTPS (secure).</li>
<li><strong>Domain name:</strong> the website name ("www.google.com" here)</li>
<li><strong>Port:</strong> a network <a target="_blank" href="https://en.wikipedia.org/wiki/Port_(computer_networking)">port</a> (80 in this example)</li>
<li><strong>Path:</strong> a path to a particular resource on the server</li>
<li><strong>Parameters:</strong> often key-value pairs, to serve extra data to the web server.</li>
</ul>
<h1 id="heading-what-are-ip-addresses">What are IP Addresses?</h1>
<p>Humans and computers navigate the web very differently. Whilst most humans use <strong>URL's</strong> like we just discussed, to communicate between computers, computers use the <strong>Internet Protocol</strong> <strong>(IP).</strong> </p>
<p>The <strong>IP</strong> is a set of rules that route and address data packets (all the data you want to view) to make sure it arrives to your computer.</p>
<p>The Internet Protocol relies on devices and domains, all having their own <strong>IP address</strong> to connect and identify all the different segments (packets!) of the internet. </p>
<p>An <strong>IP address</strong> is a series of standardised numbers that range from 0 to 255 – separated by dots. </p>
<p>If you want to see <strong>IP addresses</strong> in action, and are familiar with terminals, you can type <code>ping google.com</code> in whichever terminal you like and you can see the <strong>IP address</strong> of Google.com.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-56.png" alt="Image" width="600" height="400" loading="lazy">
<em>A screenshot from a PowerShell terminal, showing a ping command to 216.58.212.206, and 0% packet loss.</em></p>
<p>You can test this further by typing <strong>216.58.212.206</strong> directly into your browser and seeing if it takes you to Google. </p>
<p>Hopefully this small example highlights why we use <strong>URL's</strong>. If both addresses (<strong>IP address</strong> and <strong>domain name</strong>) took you to the same place, would you rather be asked to remember <strong>Google.com</strong> or <strong>216.58.212.206</strong>?</p>
<p>Note that some IP addresses change day to day (called <a target="_blank" href="https://support.opendns.com/hc/en-us/articles/227987827-What-is-a-Dynamic-IP-Address-">dynamic IP addresses</a>) – so the above <strong>IP address</strong> may not work, depending on if the IP address is dynamic or static.</p>
<p>Static IP addresses are ones that don't change – but to assign a single <strong>IP address</strong> to every machine would be impractical. It would be a logistical nightmare, too, as some people only log onto computers once a month to send an email, for example. </p>
<p>We could very realistically run out of IP addresses on today's current technology if we gave every device a unique <strong>IP address</strong> (if you want to read how IP addresses are allocated in greater detail, <a target="_blank" href="https://www.freecodecamp.org/news/ipv4-vs-ipv6-what-is-the-difference-between-ip-addressing-schemes/">read here</a>).</p>
<h1 id="heading-what-is-a-dns">What is a DNS?</h1>
<p>If we know computers communicate via the <strong>Internet Protocol</strong> and communicate using <strong>IP Addresses</strong>, how do we turn <a target="_blank" href="https://www.freecodecamp.org/news/p/addfad35-db16-4e8d-abf6-c36009bd5bca/www.google.com">google.com</a> into the website we use so regularly?</p>
<p>The answer is using a <strong>Domain Name System (DNS)</strong>. The job of the Domain Name System is to transform human readable <strong>domain names</strong> into <strong>IP addresses</strong>.</p>
<p>There are four servers specifically that we'll discuss.</p>
<h2 id="heading-dns-recursor">DNS Recursor</h2>
<p>A <strong>DNS Recursor</strong> is like a waiter in a restaurant. It acts like a "front facing" part of the system to receive orders (normally from browsers) where the waiter then heads into the back to get what is needed.</p>
<p>In reality, it's just a server that receives <strong>DNS queries</strong> from browsers and returns information.</p>
<p>There are 3 different places the DNS recursor can generally get the information from depending on if any data has been cached:</p>
<ul>
<li>Root nameserver</li>
<li>TLD nameserver</li>
<li>Authoritative nameserver</li>
</ul>
<p>So let's discuss them one by one.</p>
<h3 id="heading-what-is-a-root-nameserver">What is a Root Nameserver?</h3>
<p>The root nameserver's main job is to return the <strong>Top-Level Domain (TLD) server</strong>.  <em>**</em>  </p>
<p>This is an important step to map hostnames into IP addresses.</p>
<p>The root nameserver essentially acts like a catalogue that points to more specific locations.</p>
<h3 id="heading-what-is-a-top-level-domain-tld-server">What is a Top-Level Domain (TLD) Server?</h3>
<p>If the root nameserver acts like a catalogue, the <strong>TLD server</strong> acts like a page in a catalogue.</p>
<p>The TLD server generally returns the final part of the host-name, like <strong>com</strong> for example, in "google.com".</p>
<h3 id="heading-what-is-an-authoritative-nameserver">What is an Authoritative Nameserver?</h3>
<p>This server is like a row entry on the specific page of the catalogue.</p>
<p>The <strong>authoritative nameserver</strong> now can return the IP address for the requested hostname from the browser, back to the DNS recursor – which can hand it back to the browser.</p>
<p>DNS can be super confusing, and to understand the whole process may take a little while, so let's tie it together with a final example.    </p>
<h2 id="heading-example-request">Example Request</h2>
<p>Let's break down an example request from a user, and hopefully tie together this pretty complex process.</p>
<p>Each step in the flow starts to point closer and closer to the final address the user will eventually end up hitting.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/07/image-168.png" alt="Image" width="600" height="400" loading="lazy">
<em>Diagram showing the steps in the request process</em></p>
<p>Let's break down what's going on in this graphic:</p>
<h3 id="heading-step-1">Step 1:</h3>
<p>A user types 'kealanparr.com' into their browser, and the query hits the DNS recursor.</p>
<h3 id="heading-step-2">Step 2:</h3>
<p>The DNS recursor then queries a Root nameserver</p>
<h3 id="heading-step-3">Step 3:</h3>
<p>The Root nameserver then responds to the DNS recursor with the address of a Top Level Domain server (TLD) such as .com. </p>
<h3 id="heading-step-4">Step 4:</h3>
<p>The DNS recursor then makes a request to the .com TLD.</p>
<h3 id="heading-step-5">Step 5:</h3>
<p>The .com TLD server then responds with the IP address of the Domain’s nameserver, kealanparr.com.</p>
<h3 id="heading-step-6">Step 6:</h3>
<p>The DNS recursor sends a query to the domain’s nameserver.</p>
<h3 id="heading-step-7">Step 7:</h3>
<p>The IP address for kealanparr.com is then returned to the resolver from the Domain nameserver.</p>
<h3 id="heading-step-8">Step 8:</h3>
<p>The DNS recursor responds to the web browser request with the IP address of the domain requested.</p>
<h3 id="heading-step-9">Step 9:</h3>
<p>At this point, the DNS lookup has returned enough data for the browser to make the request for the web page.</p>
<ul>
<li>The browser makes a HTTP request to the IP address.</li>
<li>The server at that IP returns the webpage content to be rendered in the browser.</li>
</ul>
<h1 id="heading-conclusion">Conclusion</h1>
<p>I hope this article has helped you to understand a few networking principles that affect the websites you use everyday. </p>
<p>IP addresses, DNS, and more are all technologies most people use daily but may not be very familiar with.</p>
<p>Cloudflare has an article that was helpful as I researched for this article, which you can read <a target="_blank" href="https://www.cloudflare.com/en-gb/learning/dns/what-is-dns/">here</a>.</p>
<p>I tweet my articles <a target="_blank" href="https://twitter.com/kealanparr">here</a> if you would like to read more.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ What is Socket Programming in Python? ]]>
                </title>
                <description>
                    <![CDATA[ In this article, you will learn how to code a socket program in Python. But before that, let's understand what a socket is and where you might use it. We can define a socket as a quick connection which allows the transmission of data between two proc... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/socket-programming-in-python/</link>
                <guid isPermaLink="false">66d460c9b3016bf139028d8b</guid>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ P S Mohammed Ali ]]>
                </dc:creator>
                <pubDate>Thu, 25 May 2023 14:25:40 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/05/ab_networks_network_8uds-1030x438-1.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In this article, you will learn how to code a socket program in Python. But before that, let's understand what a socket is and where you might use it.</p>
<p>We can define a socket as a quick connection which allows the transmission of data between two processes on the same machine or different machines over a network. It is commonly used in client-server interaction, as sockets allow applications to communicate using the built-in mechanisms of the hardware and operating system.</p>
<p>Many of the today’s most used software – including web browsers, file sharing software, and social media instant messaging applications like WhatsApp and others – fundamentally depend on the concept of sockets.</p>
<p>Usually, a socket program is comprised of two main programs called the client and server. Here, the <strong>client acts as the requester</strong>, where it requests some data. The <strong>server acts as the listener</strong> and provides the client the requested data as the response.</p>
<p>In Python, creating a client and server program is a simple task, as Python has many inbuilt modules to help with this.</p>
<h2 id="heading-how-to-code-the-server">How to Code the Server</h2>
<p>First, let's code our server program. To keep it simple, let's assume that the server listens to the host on a particular port. Whatever data it receives, it just prints and send some random ASCII letters as a response.</p>
<pre><code class="lang-python"><span class="hljs-comment"># server.py</span>
<span class="hljs-comment"># Importing neccessary inbuilt modules</span>
<span class="hljs-keyword">import</span> socket
<span class="hljs-keyword">import</span> random
<span class="hljs-keyword">import</span> string

<span class="hljs-comment"># Creating a socket instance</span>
server_object = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)

<span class="hljs-comment"># Connecting to the localhost</span>
ip_address = <span class="hljs-string">'127.0.0.1'</span>
port = <span class="hljs-number">5555</span>
server_object.bind((ip_address, port))
server_object.listen()

<span class="hljs-comment">#Once the client connects to the particular port, the server starts to accept the request.</span>
connection_object, _ = server_object.accept()


<span class="hljs-keyword">if</span> connection_object:
    <span class="hljs-comment"># Connected to client successfully</span>
    print(<span class="hljs-string">"SERVER CONNECTED TO CLIENT"</span>)

    <span class="hljs-comment"># sending initial message to the client</span>
    connection_object.send(<span class="hljs-string">b"type the message"</span>)

    <span class="hljs-comment"># receiving message from the client</span>
    data_receive = connection_object.recv(<span class="hljs-number">1024</span>)

    <span class="hljs-keyword">while</span> data_receive != <span class="hljs-string">b'stop'</span>:
        print(<span class="hljs-string">"{}: {}"</span>.format(<span class="hljs-string">"CLIENT MESSAGE: "</span>, data_receive.decode(<span class="hljs-string">'utf-8'</span>)))
        server_input = random.choice(string.ascii_letters)
        connection_object.send(server_input.encode(<span class="hljs-string">'utf-8'</span>))
        data_receive = connection_object.recv(<span class="hljs-number">1024</span>)
</code></pre>
<p>In the above code, we created a socket instance for the server. You can see that <code>family=socket.AF_INET</code> defines the address family that this socket can accept – only IPv4 addresses. And <code>type=socket.SOCK_STREAM</code> defines that the socket accepts only TCP (Transmission Control Protocol) connections.</p>
<p>For the server socket instance to listen and accept requests, it needs an IP address and a port. So, we have <code>ip_address = '127.0.0.1'</code> and <code>port = 5555</code>. Here, we have localhost as our IP address as the server and client reside in the same machine.</p>
<p>In the next step, the server instance <code>server_object</code> establishes (binds) an address so that clients can use it to find the server. The <code>bind((ip_address,port))</code> method assigns a local IP address and a port number to this <code>server_object</code> instance explicitly as the server programs listens on the published port <code>port</code>. A port and local IP address neds to be assigned.</p>
<p>It then starts to actively listens on that particular port. When the client connects to that port from the client side, the server instance accepts the client's request for a connection. It then creates a new <code>connection_object</code> and returns to the server instance.</p>
<p>This <code>connection_object</code> contains all the necessary information about the client and server. Now, we use this <code>connection_object</code> to send a message from the server to client. So we print a <code>SERVER CONNECTED TO CLIENT</code> message if the <code>connection_object</code> is created successfully.</p>
<p>Once the <code>connection_object</code> is created, then the instance sends an initial message <code>type the message</code> in bytes to the client and receives the request from the client.</p>
<p>In the <code>while</code> loop, the connection instance <code>connection_object</code> prints the client message. Then as a response it sends random ASCII letters and waits for the client request. This <code>while</code> loop will execute in the server program until the client sends the request message <code>stop</code>.</p>
<h2 id="heading-how-to-code-the-client">How to Code the Client</h2>
<p>Up to this point, we have seen the server side code. Now, lets code the client side which is pretty simple.</p>
<pre><code class="lang-python"><span class="hljs-comment"># client.py</span>

<span class="hljs-comment">#importing socket module</span>
<span class="hljs-keyword">import</span> socket

<span class="hljs-comment"># creating socket instance</span>
client_object = socket.socket(family=socket.AF_INET, type=socket.SOCK_STREAM)

<span class="hljs-comment"># target ip address and port</span>
ip_address = <span class="hljs-string">'127.0.0.1'</span>
port = <span class="hljs-number">5555</span>

<span class="hljs-comment"># instance requesting for connection to the specified address and port</span>
client_object.connect((ip_address,port))

<span class="hljs-comment"># receiving response from server</span>
data_receive = client_object.recv(<span class="hljs-number">1024</span>)

<span class="hljs-comment"># if response is not null</span>
<span class="hljs-keyword">if</span> data_receive:
    <span class="hljs-comment"># Connection is successful</span>
    print(<span class="hljs-string">"CLIENT CONNECTED TO SERVER"</span>)
    print(data_receive.decode(<span class="hljs-string">'utf-8'</span>))


    <span class="hljs-keyword">while</span> data_receive:
        <span class="hljs-comment"># user input</span>
        client_input = input().encode(<span class="hljs-string">'utf-8'</span>)

        <span class="hljs-comment"># sending request to the server</span>
        client_object.send(client_input)

        <span class="hljs-comment"># receiving response from the server</span>
        data_receive = client_object.recv(<span class="hljs-number">1024</span>)
        <span class="hljs-keyword">if</span> data_receive:
            print(<span class="hljs-string">"{}: {}"</span>.format(<span class="hljs-string">"SERVER"</span>,data_receive.decode(<span class="hljs-string">'utf-8'</span>)))
</code></pre>
<p>In the client side code, we have created a similar socket instance <code>client_object</code>, the target <code>ip_address</code>, and <code>port</code>, just like we created in the server side program.</p>
<p>The next step is to use the <code>client_object</code> instance and connect to the respective target address and port using the <code>connect()</code> method.</p>
<p>Once the connection is successful and the <code>connection_object</code> is created on the server side, then the server sends the response <code>type the message</code> which gets stored in the <code>data_receive</code> in the client side.</p>
<p>Since the server has sent the message, we use this message to confirm that the connection is successful. So, we print <code>CLIENT CONNECTED TO SERVER</code> and then print the message sent by the server <code>type the message</code>.</p>
<p>In the <code>while</code> loop, we first give the input in a string using the <code>input()</code> inbuilt function. Then we convert it to bytes using the <code>encode('utf-8')</code> method and store it in <code>client_input</code> (as the data can be sent only in bytes). We then send the <code>client_input</code> to the server using <code>client_object.send(client_input)</code>.</p>
<p>We receive the response data from the server after sending the request to the server. The server will accept and give a response to the client until the user types <code>stop</code> as a request to the server.</p>
<p><strong>Note:</strong> We have to first execute the server program and then the client program because when client wants to connect to the target, there should be a server listening, up and running.</p>
<p>Here's the execution of of <code>server.py</code> and then <code>client.py</code>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/05/ff.PNG" alt="Image" width="600" height="400" loading="lazy"></p>
<p><em>Left-Side: Server Program, Right-Side: Client Program</em></p>
<p>As you can see, once the execution started, the server displayed <code>SERVER CONNECTED TO CLIENT</code> so the user can tell it's working, and sent the initial message to the client.</p>
<p>On the client side, when the client received the message, it displayed <code>CLIENT CONNECTED TO SERVER</code> and also printed <code>type the message</code> received from the client.</p>
<p>Since the client is waiting for the input from the user, once the user entered the input, it sends it to the server and the server prints the client message. It then sent the random ASCII letter as the response to the client.</p>
<p>The flow looped until the client sent the <code>stop</code> message as the request to the server. Once the server received the <code>stop</code> request, it terminated from the socket session.</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this tutorial, We understood socket is one of the most fundamental technologies of computer networking and learnt how to set up a socket program in Python using the socket module in client-side and server-side programs.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ What is SSH? SSH Meaning in Linux ]]>
                </title>
                <description>
                    <![CDATA[ By Shittu Olumide Secure Shell (SSH) is a widely used network protocol that provides a secure way to access remote servers and computers.  In Linux, SSH is an essential tool for remote administration and file transfer. In this article, we will go ove... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/ssh-meaning-in-linux/</link>
                <guid isPermaLink="false">66d461413bc3ab877dae2243</guid>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ssh ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 02 May 2023 13:29:50 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/05/Shittu-Olumide-What-is-SSH-SSH-Meaning-in-Linux.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Shittu Olumide</p>
<p>Secure Shell (SSH) is a widely used network protocol that provides a secure way to access remote servers and computers. </p>
<p>In Linux, SSH is an essential tool for remote administration and file transfer. In this article, we will go over the meaning of SSH in Linux, its history, features, configuration, and use cases.</p>
<h2 id="heading-what-is-ssh">What is SSH?</h2>
<p>SSH is a cryptographic network protocol that allows secure communication between networked devices. It was developed as a replacement for <a target="_blank" href="https://en.wikipedia.org/wiki/Telnet">Telnet</a>, which sends all data, including passwords, in clear text, making it susceptible to eavesdropping and interception. </p>
<p>SSH provides encryption and authentication mechanisms to protect the confidentiality and integrity of network communications.</p>
<h2 id="heading-brief-history-of-ssh">Brief History of SSH</h2>
<p>The first version of SSH, SSH-1, was developed by <a target="_blank" href="https://www.usenix.org/conference/lisa13/speaker-or-organizer/tatu-yl%C3%B6nen-ssh-communications-security">Tatu Ylönen in 1995</a> as a response to the insecurity of Telnet and FTP. </p>
<p>In 1996, SSH Communications Security released a commercial version of SSH-1, which became widely used in the industry. </p>
<p>But SSH-1 had some security vulnerabilities, and in 1998, Ylönen developed SSH-2, which addressed these issues and became the most widely used version of SSH.</p>
<h2 id="heading-how-ssh-works">How SSH Works</h2>
<p>SSH uses a client-server architecture, where the client initiates a connection to the server and requests a secure communication channel. The server responds by generating a pair of cryptographic keys, one public and one private.</p>
<p>The public key is sent to the client, while the private key is kept securely on the server. The client then encrypts a random session key using the server's public key and sends it back to the server. The server decrypts the session key using its private key and sends an acknowledgement to the client. From this point on, all data transmitted between the client and server is encrypted using the session key.</p>
<h2 id="heading-ssh-features">SSH Features</h2>
<ul>
<li><strong>Encryption</strong>: SSH uses strong encryption algorithms, such as AES, to protect the confidentiality and integrity of data transmitted over the network.</li>
<li><strong>Secure file transfer</strong>: It provides secure file transfer (SFTP) capabilities, which allow users to transfer files between remote servers securely.</li>
<li><strong>Remote login</strong>: SSH provides a secure way to login to remote servers and computers, without exposing login credentials to attackers.</li>
<li><strong>Port forwarding</strong>: It provides port forwarding capabilities, which allow users to access restricted services on remote servers through a secure communication channel.</li>
<li><strong>X11 forwarding</strong>: SSH provides X11 forwarding capabilities, which allow users to run graphical applications remotely, without having to install them locally.</li>
<li><strong>Agent forwarding</strong>: It also provides agent forwarding capabilities, which allow users to use SSH keys for authentication on remote servers, without having to enter their password every time.</li>
</ul>
<h2 id="heading-ssh-configuration">SSH Configuration</h2>
<p>SSH configuration involves various settings and options that can be customized to optimize the SSH connection and improve security. Here are some common SSH configuration tasks:</p>
<ul>
<li><strong>Generating SSH keys</strong>: Before using SSH, users must generate a pair of cryptographic keys, one public and one private. The public key is shared with the server, while the private key is kept securely on the user's computer.</li>
<li><strong>Editing configuration files</strong>: Users can create and edit SSH configuration files to customize their SSH settings, such as specifying the preferred encryption algorithm or setting up port forwarding. The SSH configuration files are usually located in the <code>/etc/ssh/</code> directory.</li>
<li><strong>Authentication methods</strong>: SSH supports various authentication methods, such as password authentication, public key authentication, and multi-factor authentication. Users can choose the most suitable authentication method based on their security needs.</li>
<li><strong>Secure SSH configuration</strong>: To ensure maximum security, users should follow best practices for secure SSH configuration, such as disabling root login, enforcing strong passwords, and limiting the number of failed login attempts. Users can also use tools like Fail2Ban to prevent brute-force attacks on SSH.</li>
<li><strong>Enabling X11 forwarding</strong>: SSH provides X11 forwarding capabilities, which allow users to run graphical applications remotely, without having to install them locally. To enable X11 forwarding, users can add the -X or -Y flag when connecting to the remote server.</li>
<li><strong>Port forwarding</strong>: SSH allows users to set up port forwarding, which can be useful for accessing restricted services on remote servers through a secure communication channel. Users can set up local or remote port forwarding, depending on their needs.</li>
<li><strong>Compression</strong>: SSH supports data compression, which can improve the performance of the SSH connection, especially when transferring large files or running resource-intensive applications. Users can enable compression by adding the <code>-C</code> flag when connecting to the remote server.</li>
</ul>
<h2 id="heading-ssh-examples-and-use-cases">SSH Examples and Use Cases</h2>
<ul>
<li><strong>Remote server administration</strong>: SSH is commonly used for remote server administration, allowing users to execute commands and manage servers from a remote location.</li>
<li><strong>Secure file transfer</strong>: provides a secure way to transfer files between remote servers, without exposing the files or login credentials to attackers.</li>
<li><strong>Running graphical applications remotely</strong>: allows users to run graphical applications remotely, without having to install them locally, which can be useful for resource-intensive applications or when using a low-power device.</li>
<li><strong>Port forwarding for accessing restricted services</strong>: allows users to access restricted services on remote servers through a secure communication channel, by setting up port forwarding.</li>
<li><strong>Tunneling for secure communication</strong>: SSH allows users to set up encrypted tunnels for secure communication between two networked devices, which can be useful for accessing resources on a private network.</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>To end this article, here's a recap of what we covered and what you should know about SSH:</p>
<ul>
<li>SSH is a secure protocol for remote communication in Linux.</li>
<li>SSH uses encryption to protect data and authentication mechanisms to verify users.</li>
<li>SSH is a reliable and efficient way to communicate securely over the internet, and is a vital tool for Linux system administration and development.</li>
<li>SSH provides remote login, secure file transfer, port forwarding, X11 forwarding, and agent forwarding capabilities.</li>
<li>To use SSH, users must generate a pair of cryptographic keys, one public and one private.</li>
<li>SSH configuration files can be customized to optimize the SSH connection and improve security.</li>
<li>SSH supports various authentication methods, such as password authentication, public key authentication, and multi-factor authentication.</li>
<li>To ensure maximum security, users should follow best practices for secure SSH configuration, such as disabling root login, enforcing strong passwords, and limiting the number of failed login attempts.</li>
<li>SSH can be used for remote server administration, secure file transfer, running graphical applications remotely, port forwarding, and tunneling for secure communication.</li>
<li>SSH is a widely used and supported protocol, with many SSH clients and servers available for different platforms.</li>
</ul>
<p>Let's connect on <a target="_blank" href="https://www.twitter.com/Shittu_Olumide_">Twitter</a> and on <a target="_blank" href="https://www.linkedin.com/in/olumide-shittu">LinkedIn</a>. You can also subscribe to my <a target="_blank" href="https://www.youtube.com/channel/UCNhFxpk6hGt5uMCKXq0Jl8A">YouTube</a> channel.</p>
<p>Happy Coding!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Learn Network Architecture Basics for Beginners ]]>
                </title>
                <description>
                    <![CDATA[ Networking is engineering, magic, and skilled trade all rolled into one. Getting all the countless pieces to talk nicely – and reliably – to each other is complicated. Troubleshooting unexpected outages is worse.  But, once you've got it all running ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/network-architecture-basics/</link>
                <guid isPermaLink="false">66b99616d9d170feecefbba3</guid>
                
                    <category>
                        <![CDATA[ architecture ]]>
                    </category>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Security ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ David Clinton ]]>
                </dc:creator>
                <pubDate>Tue, 11 Apr 2023 19:05:27 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/04/pexels-brett-sayles-2881232.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Networking is engineering, magic, and skilled trade all rolled into one. Getting all the countless pieces to talk nicely – and reliably – to each other is complicated. Troubleshooting unexpected outages is worse. </p>
<p>But, once you've got it all running nicely, well that's when you should really be worried: because that's exactly when the bad guys start banging away at the door trying to find a way in.</p>
<p>In this article we're going to cover just enough of the most important networking fundamentals so that discussions of network security that you may encounter will make sense. </p>
<p>This article comes from <a target="_blank" href="https://www.udemy.com/course/complete-lpi-security-essentials-exam-study-guide/?referralCode=C2B6802EDB99578238B5">The Complete LPI Security Essentials Exam Study Guide</a>. You can also follow along using this video:</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/tsAEFWVJKsc" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
<h2 id="heading-understanding-ipv4-and-nat-routing">Understanding IPv4 and NAT Routing</h2>
<p>IP networks (where IP stands for Internet Protocol) are the backbone of the Internet, connecting devices and transmitting data over the network.</p>
<p>IP is responsible for routing data packets from one device to another, and IP version 4 is the most widely used IP address format. IPv4 uses a 32-bit address, and consists of four 8-bit numbers called octets. IPv4 addresses are written in a decimal notation where each octet is separated by a dot.</p>
<p>An example of an IPv4 host address might look something like this:</p>
<pre><code><span class="hljs-number">192.168</span><span class="hljs-number">.2</span><span class="hljs-number">.34</span>
</code></pre><p>Network Address Translation is a method used to allow private IPv4 addresses to access the Internet. NAT maps private IP addresses to a single public IP address, which is assigned by an Internet Service Provider (ISP). </p>
<p>When a device in a private network wants to access the Internet, it sends a request to the NAT gateway. The NAT gateway translates the private IP address of the device into the public IP address assigned by the ISP and forwards the request to the Internet.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/slide-11.png" alt="Image" width="600" height="400" loading="lazy">
<em>NAT addressing explained in a diagram</em></p>
<p>When the response from the Internet is received, the NAT gateway translates the public IP address back into the private IP address of the device and sends the response to the device. </p>
<p>In this way, NAT enables multiple devices in a private network to share a single public IP address and access the Internet, while hiding their private IP addresses from the public. NAT also provides a basic level of security by hiding the internal network from the Internet.</p>
<h2 id="heading-understanding-ipv6">Understanding IPv6</h2>
<p>IP version 6 is the latest IP address format. IPv6 uses a 128-bit address, and is made up of eight 16-bit hexadecimal segments separated by colons.</p>
<p>Here is an example of what an IPv6 address might look like:</p>
<pre><code><span class="hljs-number">2001</span>:<span class="hljs-number">0</span>db8:<span class="hljs-number">85</span>a3:<span class="hljs-number">0000</span>:<span class="hljs-number">0000</span>:<span class="hljs-number">8</span>a2e:<span class="hljs-number">0370</span>:<span class="hljs-number">7334</span>
</code></pre><p>IPv6 was created because we were running out of IPv4 addresses – since IPv4's 32-bit addresses allow for a maximum of only 4.3 billion unique addresses. </p>
<p>This was great in the early days of the Internet, but as the number of Internet-connected devices has grown, the demand for unique IP addresses has surpassed the number available in the IPv4 address space.</p>
<p>To address this shortage, IPv6 was developed with its larger address space, allowing for 340 trillion, trillion, trillion unique addresses. This large address space ensures that there will be enough unique IP addresses for all Internet-connected devices forever. Literally.</p>
<p>Additionally, IPv6 addresses overcome some other limitations of IPv4, such as improved security, auto-configuration, and support for hierarchical address allocation and routing.</p>
<h2 id="heading-defining-routing-protocols">Defining Routing Protocols</h2>
<p>TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) are two of the most common transport layer protocols used in IP networks. </p>
<p>TCP is a reliable connection-oriented protocol that provides error-checking and flow control. UDP is a connectionless protocol that provides fast data transmission but with less reliability.</p>
<p>ICMP (Internet Control Message Protocol) is a network layer protocol used to send error messages, test network connectivity (in particular, through a tool called <code>ping</code>), and perform other functions.</p>
<p>DHCP (Dynamic Host Configuration Protocol) is a protocol used to dynamically assign IP addresses to devices on a network. In a home or small business network, DHCP is usually performed by a router or a dedicated DHCP server, which is responsible for dynamically assigning IP addresses to devices on the network.</p>
<p>Here's how the process of DHCP typically works:</p>
<ul>
<li>When a device connects to the network, it broadcasts a request for an IP address.</li>
<li>The DHCP server receives the request and assigns a unique IP address to the device, along with other network information such as the subnet mask, default gateway, and DNS server addresses.</li>
<li>The device receives the assigned IP address and other network information from the DHCP server and uses it to configure its network settings.</li>
<li>Finally, the DHCP server maintains a table of assigned IP addresses and the devices that have been assigned them, so it can ensure that each device on the network has a unique IP address.</li>
</ul>
<p>In a home or small business network, the router or DHCP server is usually configured to automatically assign IP addresses to devices on the network. This eliminates the need for manual IP address configuration and makes it easy for devices to connect to the network.</p>
<p>With those basics, you'll be in a much better position to understand the stuff you hear and read about network security issues. </p>
<p>This article and the accompanying video are excerpted from <a target="_blank" href="https://www.udemy.com/course/complete-lpi-security-essentials-exam-study-guide/?referralCode=C2B6802EDB99578238B5">my Complete LPI Security Essentials Exam Study Guide course</a>. And there's much more technology goodness available at <a target="_blank" href="https://bootstrap-it.com/">bootstrap-it.com</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Setting a Static IP in Ubuntu – Linux IP Address Tutorial ]]>
                </title>
                <description>
                    <![CDATA[ In most network configurations, the router DHCP server assigns the IP address dynamically by default. If you want to ensure that your system IP stays the same every time, you can force it to use a static IP.  That's what we will learn in this article... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/setting-a-static-ip-in-ubuntu-linux-ip-address-tutorial/</link>
                <guid isPermaLink="false">66adea771ad24d82983fd255</guid>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Ubuntu ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Zaira Hira ]]>
                </dc:creator>
                <pubDate>Thu, 02 Mar 2023 21:24:59 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/03/setting-static-ip-ubuntu.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In most network configurations, the router DHCP server assigns the IP address dynamically by default. If you want to ensure that your system IP stays the same every time, you can force it to use a static IP. </p>
<p>That's what we will learn in this article. We will explore two ways to set a static IP in Ubuntu.</p>
<p>Static IP addresses find their use in the following situations:</p>
<ul>
<li>Configuring port forwarding.</li>
<li>Configuring your system as a server such as an FTP server, web server, or a media server.</li>
</ul>
<p><strong>Pre-requisites:</strong></p>
<p>To follow this tutorial you will need the following:</p>
<ul>
<li>Ubuntu installation, preferably with a GUI.</li>
<li><code>sudo</code> rights as we will be modifying system configuration files.</li>
</ul>
<h2 id="heading-how-to-set-a-static-ip-using-the-command-line">How to Set a Static IP Using the Command Line</h2>
<p>In this section, we will explore all the steps in detail needed to configure a static IP.</p>
<h3 id="heading-step-1-launch-the-terminal">Step 1: Launch the terminal</h3>
<p>You can launch the terminal using the shortcut <code>Ctrl+ Shift+t</code>. </p>
<h3 id="heading-step-2-note-information-about-the-current-network">Step 2: Note information about the current network</h3>
<p>We will need our current network details such as the current assigned IP, subnet mask, and the network adapter name so that we can apply the necessary changes in the configurations.</p>
<p>Use the command below to find details of the available adapters and the respective IP information.</p>
<pre><code class="lang-bash">ip a
</code></pre>
<p>The output will look something like this:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-14.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>For my network, the current adapter is <code>eth0</code>. It could be different for your system</p>
<ul>
<li><strong>Note the current network adapter name</strong></li>
</ul>
<p>As my current adapter is <code>eth0</code>, the below details are relevant.</p>
<pre><code class="lang-bash">6: eth0: &lt;BROADCAST,MULTICAST,UP,LOWER_UP&gt; mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:15:5d:df:c3:ad brd ff:ff:ff:ff:ff:ff
    inet 172.23.199.129/20 brd 172.23.207.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::215:5dff:fedf:c3ad/64 scope link
       valid_lft forever preferred_lft forever
</code></pre>
<p>It is worth noting that the current IP <code>172.23.199.129</code> is dynamically assigned. It has <code>20</code> bits reserved for the netmask. The broadcast address is <code>172.23.207.255</code>.</p>
<ul>
<li><strong>Note the subnet</strong></li>
</ul>
<p>We can find the subnet mask details using the command below:</p>
<pre><code class="lang-bash">ifconfig -a
</code></pre>
<p>Select the output against your adapter and read it carefully.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-15.png" alt="Image" width="600" height="400" loading="lazy">
<em>IP is <code>172.23.199.129</code> and subnet mask is <code>255.255.240.0</code></em></p>
<p>Based on the class and subnet mask, the usable host IP range for my network is: <code>172.23.192.1 - 172.23.207.254</code>.</p>
<p>Subnetting is a vast topic. For more info on subnetting and your usable IP ranges, check out this <a target="_blank" href="https://www.freecodecamp.org/news/subnet-cheat-sheet-24-subnet-mask-30-26-27-29-and-other-ip-address-cidr-network-references/">article</a>.</p>
<h3 id="heading-step-3-make-configuration-changes">Step 3: Make configuration changes</h3>
<p><a target="_blank" href="https://netplan.io/">Netplan</a> is the default network management tool for the latest Ubuntu versions. Configuration files for Netplan are written using YAML and end with the extension <code>.yaml</code>.</p>
<p>Note: Be careful about spaces in the configuration file as they are part of the syntax. Without proper indentation, the file won't be read properly.</p>
<ul>
<li>Go to the <code>netplan</code> directory located at <code>/etc/netplan</code>.</li>
</ul>
<p><code>ls</code> into the <code>/etc/netplan</code> directory.</p>
<p>If you do not see any files, you can create one. The name could be anything, but by convention, it should start with a number like <code>01-</code> and end with <code>.yaml</code>. The number sets the priority if you have more than one configuration file. </p>
<p>I'll create a file named <code>01-network-manager-all.yaml</code>. </p>
<p>Let's add these lines to the file. We'll build the file step by step.</p>
<pre><code class="lang-bash">network:
 version: 2
</code></pre>
<p>The top-level node in a Netplan configuration file is a <code>network:</code> mapping that contains <code>version: 2</code> (means that it is using network definition version 2).</p>
<p>Next, we'll add a renderer, that controls the overall network. The renderer is <code>systemd-networkd</code> by default, but we'll set it to <code>NetworkManager</code>.</p>
<p>Now, our file looks like this:</p>
<pre><code class="lang-bash">network:
 version: 2
 renderer: NetworkManager
</code></pre>
<p>Next, we'll add <code>ethernets</code> and refer to the network adapter name we looked for earlier in step#2. Other device types supported are <code>modems:</code>, <code>wifis:</code>, or <code>bridges:</code>.</p>
<pre><code class="lang-bash">network:
 version: 2
 renderer: NetworkManager
 ethernets:
   eth0:
</code></pre>
<p>As we are setting a static IP and we do not want to dynamically assign an IP to this network adapter, we'll set <code>dhcp4</code> to <code>no</code>.</p>
<pre><code class="lang-bash">network:
 version: 2
 renderer: NetworkManager
 ethernets:
   eth0:
     dhcp4: no
</code></pre>
<p>Now we'll specify the specific static IP we noted in step #2 depending on our subnet and the usable IP range. It was <code>172.23.207.254</code>.</p>
<p>Next, we'll specify the gateway, which is the router or network device that assigns the IP addresses. Mine is on <code>192.168.1.1</code>.</p>
<pre><code class="lang-bash">network:
 version: 2
 renderer: NetworkManager
 ethernets:
   eth0:
     dhcp4: no
     addresses: [172.23.207.254/20]
     gateway4: 192.168.1.1
</code></pre>
<p>Next, we'll define <code>nameservers</code>. This is where you define a DNS server or a second DNS server. Here the first value is  <code>8.8.8.8</code> which is Google's primary DNS server and the second value is <code>8.8.8.4</code> which is Google's secondary DNS server. These values can vary depending on your requirements.</p>
<pre><code class="lang-bash">network:
 version: 2
 renderer: NetworkManager
 ethernets:
   eth0:
     dhcp4: no
     addresses: [172.23.207.254/20]
     gateway4: 192.168.1.1
     nameservers:
         addresses: [8.8.8.8,8.8.8.4]
</code></pre>
<h3 id="heading-step-4-apply-and-test-the-changes">Step 4: Apply and test the changes</h3>
<p>We can test the changes first before permanently applying them using this command:</p>
<pre><code class="lang-bash">sudo netplan try
</code></pre>
<p>If there are no errors, it will ask if you want to apply these settings.</p>
<p>Now, finally, test the changes with the command <code>ip a</code> and you'll see that the static IP has been applied.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-17.png" alt="Image" width="600" height="400" loading="lazy">
<em>Static IP applied</em></p>
<h2 id="heading-how-to-set-a-static-ip-using-the-gui">How to Set a Static IP Using the GUI</h2>
<p>It is very easy to set a static IP through the Ubuntu GUI/ Desktop. Here are the steps:</p>
<ul>
<li>Search for <code>settings</code>.</li>
<li>Click on either Network or Wi-Fi tab, depending on the interface you would like to modify.</li>
<li>To open the interface settings, click on the gear icon next to the interface name.</li>
<li>Select “Manual” in the IPV4 tab and enter your static IP address, Netmask and Gateway. </li>
<li>Click on the <code>Apply</code> button.</li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-16.png" alt="Image" width="600" height="400" loading="lazy">
<em>Manually setting a static IP using Ubuntu Desktop.</em></p>
<ul>
<li>Verify by using the command <code>ip a</code></li>
</ul>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/03/image-18.png" alt="Image" width="600" height="400" loading="lazy">
<em>Static IP updated via GUI</em></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this article, we covered two methods to set the static IP in Ubuntu. I hope you found the article useful.</p>
<p>What’s your favorite thing you learned from this tutorial? Let me know on <a target="_blank" href="https://twitter.com/hira_zaira">Twitter</a>!</p>
<p>You can read my other posts <a target="_blank" href="https://www.freecodecamp.org/news/author/zaira/">here</a>.</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Learn Wireshark – Computer Networking Tutorial ]]>
                </title>
                <description>
                    <![CDATA[ In this post, you will learn about the single most important and useful tool in Computer Networks – Wireshark. This post relies on basic knowledge of computer networks. Be sure to check my previous post about the five layers model if you need a refre... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/learn-wireshark-computer-networking/</link>
                <guid isPermaLink="false">66c17c3dea5637f064224a0a</guid>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ computer networking ]]>
                    </category>
                
                    <category>
                        <![CDATA[ information security ]]>
                    </category>
                
                    <category>
                        <![CDATA[ #infosec ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Omer Rosenbaum ]]>
                </dc:creator>
                <pubDate>Mon, 23 Jan 2023 23:35:33 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/01/Computer-Networks-Ethernet--3-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In this post, you will learn about the single most important and useful tool in Computer Networks – Wireshark.</p>
<p>This post relies on basic knowledge of computer networks. Be sure to check my <a target="_blank" href="https://www.freecodecamp.org/news/the-five-layers-model-explained/">previous post about the five layers model</a> if you need a refresher.</p>
<h1 id="heading-what-is-wireshark">What is Wireshark?</h1>
<p>Wireshark is a sniffer, as well as a packet analyzer.</p>
<p>What does that mean?</p>
<p>You can think of a <strong>sniffer</strong> as a measuring device. We use it to examine what’s going on inside a network cable, or in the air if we are dealing with a wireless network. A sniffer shows us the data that passes through our network card.</p>
<p>But Wireshark does more than that. A sniffer could just display a stream of bits - ones and zeroes, that the network card sees. Wireshark is also a <strong>packer analyzer</strong> that displays lots of meaningful data about the frames that it sees.</p>
<p>Wireshark is an open-source and free tool, and is widely used to analyze network traffic.</p>
<p>Wireshark can be helpful in many cases. It might be helpful for debugging problems in your network, for instance – if you can’t connect from one computer to another, and want to understand what’s going on. </p>
<p>It can also help programmers. For example, imagine that you were implementing a chat program between two clients, and something was not working. In order to understand what exactly is being sent, you may use Wireshark to see the data transmitted over the wire.</p>
<p>So, let’s get to know Wireshark.</p>
<h1 id="heading-how-to-download-and-install-wireshark">How to Download and Install Wireshark</h1>
<p>Start by downloading Wireshark from its official website:</p>
<p><a target="_blank" href="https://www.wireshark.org/#download">https://www.wireshark.org/#download</a></p>
<p>Follow the instructions on the installer and you should be good to go.</p>
<h1 id="heading-how-to-sniff-traffic-with-wireshark">How to Sniff Traffic with Wireshark</h1>
<p>Launch Wireshark, and start by sniffing some data. For that, you can hit <code>Ctrl+K</code> (PC) or <code>Cmd+K</code> (Mac)  to get the <code>Capture Options</code> window. Notice that you can reach this window in other ways. You can go to <code>Capture-&gt;Options</code>. Alternatively, you can click the <code>Capture Options</code> icon.</p>
<p>I encourage you to use keyboard shortcuts and get comfortable with them right from the start, as they'll allow you to save time and work more efficiently.</p>
<p>So, again, I’ve used <code>Ctrl+K</code> (or <code>Cmd+K</code>) and got this screen:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-208.png" alt="Image" width="600" height="400" loading="lazy">
<em>The <code>Capture Options</code> window in Wireshark (Source: <a target="_blank" href="https://www.youtube.com/watch?v=nbTJXIdEzlo">Brief</a>)</em></p>
<p>Here we can see a list of interfaces, and I happen to have quite a few. Which one is relevant? If you’re not sure at this point, you can look at the <code>Traffic</code> column, and see which interfaces currently have traffic. </p>
<p>Here we can see that <code>Wi-Fi 3</code> has got traffic going through it, as the line is high. Select the relevant network interface, and then hit <code>Enter</code>, or click the button <code>Start</code>.</p>
<p>Let Wireshark sniff the network for a bit, and then stop the sniff using <code>Ctrl+E</code> / <code>Cmd+E</code>. Again, this can be achieved in other ways – such as going to <code>Capture-&gt;Stop</code> or clicking the <code>Stop</code> icon.</p>
<p>Consider the different sections:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-210.png" alt="Image" width="600" height="400" loading="lazy">
<em>Wireshark's sections (Source: <a target="_blank" href="https://www.youtube.com/watch?v=nbTJXIdEzlo">Brief</a>)</em></p>
<p>The section marked in red includes Wireshark’s menu, with all kinds of interesting options.</p>
<p>The main toolbar is marked in blue, providing quick access to some items from the menu.</p>
<p>Next, marked in green, is the <strong>display filter</strong>. We will get back to it shortly, as this is one of the most important features of Wireshark.</p>
<p>Then follows:</p>
<h1 id="heading-the-packet-list-pane">The Packet List Pane</h1>
<p>The packet list pane is marked in orange. It displays a short summary of each packet captured.</p>
<p>(Note: the term Frame belongs to a sequence of bytes in the <a target="_blank" href="https://www.freecodecamp.org/news/the-five-layers-model-explained/">Data Link layer</a>, while a Packet is a sequence of bytes from the <a target="_blank" href="https://www.freecodecamp.org/news/the-five-layers-model-explained/">Network layer</a>. In this post I will use the terms interchangeably, though to be accurate, every packet is a frame, but not every frame is a packet, as there are frames that don't hold network layer data.)</p>
<p>As you can see in the image above, we have a few columns here:</p>
<p>NUMBER (No.) – The number of the packet in the capture file. This number won’t change, even if we use filters. This is just a sequential number – the first frame that you have sniffed gets the number 1, the second frame gets the number 2, and so on.</p>
<p>Time – The timestamp of the packet. It shows how much time has passed from the very first packet we have sniffed until we sniffed the packet in question. Therefore, the time for packet number 1 is always 0.</p>
<p>Source – The address where this packet is coming from. Don’t worry if you don’t understand the format of the addresses just yet, we will cover different addresses in future tutorials.</p>
<p>Destination – The address where this packet is going.</p>
<p>Protocol – The protocol name in a short version. This will be the top protocol – that is, the protocol of the highest layer.</p>
<p>Length – The length of each packet, in bytes.</p>
<p>Info – Additional information about the packet content. This changes according to the protocol.</p>
<p>By clicking on packets in this pane, you control what is displayed in the other two panes which I will now describe.</p>
<h1 id="heading-the-packet-details-pane">The Packet Details Pane</h1>
<p>Click on one of the captured packets. In the example below I clicked on packet number 147:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-211.png" alt="Image" width="600" height="400" loading="lazy">
<em>Selecting a specific packet changes the packet details pane (Source: <a target="_blank" href="https://www.youtube.com/watch?v=nbTJXIdEzlo">Brief</a>)</em></p>
<p>Now, the <strong>packet details pane</strong> displays the packet selected in the packet list pane in more detail. You can see the layers here. </p>
<p>In the example above, we have Ethernet II as the second layer, IPv4 as the third layer, UDP as the fourth layer, and some data as a payload.</p>
<p>When we click on a specific layer, we actually see the <strong>header</strong> of that layer.</p>
<p>Notice that we don’t see the first layer on its own. As a reminder, the first layer is responsible for <strong>transmitting a single bit</strong> – 0 or 1 – over the network (if you need a refresher about the different layers, <a target="_blank" href="https://www.freecodecamp.org/news/the-five-layers-model-explained/">check out this post</a>).</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-215.png" alt="Image" width="600" height="400" loading="lazy">
<em>The packet bytes pane in Wireshark (Source: <a target="_blank" href="https://www.youtube.com/watch?v=nbTJXIdEzlo">Brief</a>)</em></p>
<p>Below the packet details pane, we have the <strong>packet bytes pane</strong>. It displays the data from the packet selected in the packet list pane. This is the actual data being sent over the wire. We can see the data in hexadecimal base, as well as ASCII form.</p>
<h1 id="heading-how-to-use-the-display-filter">How to Use the Display Filter</h1>
<p>Wireshark has many different functions, and today we will focus on one thing – the display filter. </p>
<p>As you can see, once you start sniffing data, you get a LOT of traffic. But you definitely don’t want to look at everything. </p>
<p>Recall the example from before – using Wireshark in order to debug a chat program that you’ve implemented. In that case, you would like to see the traffic related to the chat program only.</p>
<p>Let’s say I want to filter only messages sent by the source address of frame number 149 ( <code>192.168.1.3</code> ). I will cover IP addresses in future posts, but for now you can see that it consists four numbers, delimited by a dot:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-217.png" alt="Image" width="600" height="400" loading="lazy">
<em>The <code>display filter</code> in Wireshark (Source: <a target="_blank" href="https://www.youtube.com/watch?v=nbTJXIdEzlo">Brief</a>)</em></p>
<p>Now, even if you don’t know how to filter only packets sent from this IP address, you can use Wireshark to show you how it’s done. </p>
<p>For that, go to the right field we would like to filter – in this case, the source IP address. Then right click -&gt; and choose <code>filter -&gt; Apply as Filter</code>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-218.png" alt="Image" width="600" height="400" loading="lazy">
<em>Applying a display filter (Source: <a target="_blank" href="https://www.youtube.com/watch?v=nbTJXIdEzlo">Brief</a>)</em></p>
<p>After applying the filter, you only see packets that have been sent from this address. Also, you can look at the display filter line and see the command used. In this way, you can learn about the display filter syntax (in this example, it is <code>ip.src</code> for the IP source address field):</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-219.png" alt="Image" width="600" height="400" loading="lazy">
<em>Applying a display filter (Source: <a target="_blank" href="https://www.youtube.com/watch?v=nbTJXIdEzlo">Brief</a>)</em></p>
<p>Now, try to filter only packets that have been sent from this address, and <strong>to</strong> the address <code>172.217.16.142</code> (as in Frame 130 in the image above). How would you do that?</p>
<p>Well, you could go to the relevant field – in this case, the IP destination address. Now, right click -&gt; <code>Apply as Filter</code> -&gt; and select <code>...and Selected</code>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-220.png" alt="Image" width="600" height="400" loading="lazy">
<em>Applying a display filter (Source: <a target="_blank" href="https://www.youtube.com/watch?v=nbTJXIdEzlo">Brief</a>)</em></p>
<p>If you look at the display filter line after applying this filter:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-221.png" alt="Image" width="600" height="400" loading="lazy">
<em>Applying a display filter (Source: <a target="_blank" href="https://www.youtube.com/watch?v=nbTJXIdEzlo">Brief</a>)</em></p>
<p>You can also learn that you can use the <code>&amp;&amp;</code> operand in order to perform <code>and</code>. You could also write the word <code>and</code>, instead, and get the same result.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-222.png" alt="Image" width="600" height="400" loading="lazy">
<em>Applying multiple conditions using <code>&amp;amp;&amp;amp;</code> or <code>and</code> (Source: <a target="_blank" href="https://www.youtube.com/watch?v=nbTJXIdEzlo">Brief</a>)</em></p>
<h1 id="heading-how-to-use-wireshark-to-research-the-ping-utility">How to Use Wireshark to Research the Ping Utility</h1>
<p><strong>Ping</strong> is a useful utility to check for remote servers’ connectivity.</p>
<p><a target="_blank" href="https://www.howtogeek.com/235101/10-ways-to-open-the-command-prompt-in-windows-10/">This page</a> explains how to use <code>ping</code> in Windows, and <a target="_blank" href="https://macpaw.com/how-to/use-terminal-on-mac">this page</a> explains how to do that in OSX.</p>
<p>Now, we can try to <code>ping &lt;address&gt;</code> using the command line. By default, ping sends <code>4</code> requests and waits for a <strong>pong</strong> answer. If we want it to send a single request, we could use <code>-n 1</code>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-224.png" alt="Image" width="600" height="400" loading="lazy">
<em>Using the command line to ping Google (Source: <a target="_blank" href="https://www.youtube.com/watch?v=nbTJXIdEzlo">Brief</a>)</em></p>
<p>You can see that Google has responded. The time it took for the message to return was 92 milliseconds. We will learn about the meaning of TTL in future posts.</p>
<p>Ping is useful to determine whether a remote service is available, and how fast it is to reach that service. If it takes a very long time to reach a reliable server such as google.com, we might have a connectivity problem.</p>
<h2 id="heading-try-it-yourself">Try it yourself</h2>
<p>Now, try to use Wireshark to answer the following questions:</p>
<p>1) What protocol does the <strong>ping</strong> utility use?</p>
<p>2) Using only Wireshark, compute the RTT (Round Trip Time) – how long it took since your ping request was sent and until the ping reply was received?</p>
<p>Next, run the following command:</p>
<p><code>ping -n 1 -l 342 www.google.com</code></p>
<p>3) What is the main difference between the packet sent by this command, and the packet sent by the previous command? Where in Wireshark can you see this difference, inspecting the packets?  </p>
<p>4) What is the content (data) provided in the ping request packet? What is the content provided in the ping response packet?</p>
<h2 id="heading-lets-solve-it-together">Let's solve it together</h2>
<p>So the first question is:</p>
<h3 id="heading-what-protocol-does-the-ping-utility-use">What protocol does the ping utility use?</h3>
<p>To answer that question, start sniffing in Wireshark, and simply run the <code>ping</code> command. Stop the sniff, and consider the packets pane:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-225.png" alt="Image" width="600" height="400" loading="lazy">
<em>Sniffing while running ping (source: <a target="_blank" href="https://www.youtube.com/watch?v=B5iEmaZK9xI&amp;t=2s">Brief</a>)</em></p>
<p>Wireshark marks the packets as <code>Echo (ping) request</code> and <code>Echo (ping) reply</code>.</p>
<p>Considering these packets, we can see they consist of <code>Ethernet</code> for the Data Link layer (though that may differ from one network to another), <code>IPv4</code> as the Network layer, and then <code>ICMP</code> as the protocol for Ping itself. So the answer we found is: <strong>ICMP</strong>.</p>
<p>Next question:</p>
<h3 id="heading-using-only-wireshark-compute-the-round-trip-time">Using only Wireshark, compute the Round Trip Time</h3>
<p>Looking at the captured packets, we can see the <code>Time</code> column, and subtract the time of the Pong packet ( <code>7.888...</code> ) from the time of the Ping packet ( <code>7.796...</code>).</p>
<p>So in this case the RTT was: <strong>92 ms</strong>. Of course, the value can be different when you run the <code>ping</code> utility.</p>
<h3 id="heading-what-is-the-main-difference-between-the-packet-sent-by-this-command-and-the-packet-sent-by-the-previous-command">What is the main difference between the packet sent by this command, and the packet sent by the previous command?</h3>
<p>For question number 3, we are asked to run the following command:</p>
<blockquote>
<p>ping -n 1 -l 342 www.google.com</p>
</blockquote>
<p>Looking at the first run of <code>ping</code>, we can see the length of the packets are <code>74</code> bytes:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-225.png" alt="Image" width="600" height="400" loading="lazy">
<em>Sniffing while running ping (source: <a target="_blank" href="https://www.youtube.com/watch?v=B5iEmaZK9xI&amp;t=2s">Brief</a>)</em></p>
<p>Observing the packets sent after running <code>ping</code> with the <code>-l 342</code> argument, we can see that the value is bigger:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-228.png" alt="Image" width="600" height="400" loading="lazy">
<em>Sniffing while running ping (source: <a target="_blank" href="https://www.youtube.com/watch?v=B5iEmaZK9xI&amp;t=2s">Brief</a>)</em></p>
<p>So the main difference is the amount of bytes sent as the data.</p>
<p>Question number four:</p>
<h3 id="heading-what-is-the-content-data-provided-in-the-ping-request-packet">What is the content (data) provided in the ping request packet?</h3>
<h3 id="heading-what-is-the-content-provided-in-the-ping-response-packet">What is the content provided in the ping response packet?</h3>
<p>Click on the request packet to observe the data sent:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-230.png" alt="Image" width="600" height="400" loading="lazy">
<em>Observing the data sent by the <code>ping</code> utility (source: <a target="_blank" href="https://www.youtube.com/watch?v=B5iEmaZK9xI&amp;t=2s">Brief</a>)</em></p>
<p>The answer for the ping request is <code>a</code> through <code>w</code>, over and over again.</p>
<p>Regarding the ping response – it is the same as the request.</p>
<h1 id="heading-summary">Summary</h1>
<p>Wireshark is a wonderful tool for anyone working with Computer Networks. It can help you understand how protocols work and also help you debug applications or network issues. </p>
<p>As you have seen, you can learn how things work by simply running Wireshark in the background while using them and then inspect the traffic. With this tool under your belt, the sky is the limit. </p>
<p>In future tutorials, we will also rely on our knowledge of Wireshark and use it to further understand various concepts in computer networks.</p>
<h2 id="heading-about-the-author">About the Author</h2>
<p><a target="_blank" href="https://www.linkedin.com/in/omer-rosenbaum-034a08b9/">Omer Rosenbaum</a> is <a target="_blank" href="https://swimm.io/">Swimm</a>’s Chief Technology Officer. He's the author of the Brief <a target="_blank" href="https://youtube.com/@BriefVid">YouTube Channel</a>. He's also a cyber training expert and founder of Checkpoint Security Academy. He's the author of <a target="_blank" href="https://data.cyber.org.il/networks/networks.pdf">Computer Networks (in Hebrew)</a>. You can find him on <a target="_blank" href="https://twitter.com/Omer_Ros">Twitter</a>.</p>
<h3 id="heading-additional-references">Additional References</h3>
<ul>
<li><a target="_blank" href="https://www.youtube.com/playlist?list=PL9lx0DXCC4BMS7dB7vsrKI5wzFyVIk2Kg">Computer Networks Playlist - on my Brief channel</a>.</li>
<li><a target="_blank" href="https://www.wireshark.org/">Wireshark's website</a>.</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Handle Errors in Computer Networks ]]>
                </title>
                <description>
                    <![CDATA[ There are some magical things about the Internet, and one thing in particular is that it works. In spite of so many obstacles, we can deliver our packets over the globe, and do so fast. Even more specifically, one amazing thing about the Internet is ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-handle-errors-in-computer-networks/</link>
                <guid isPermaLink="false">66c17c3858ee0865d2671b5d</guid>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ computer networking ]]>
                    </category>
                
                    <category>
                        <![CDATA[ error ]]>
                    </category>
                
                    <category>
                        <![CDATA[ error handling ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Omer Rosenbaum ]]>
                </dc:creator>
                <pubDate>Wed, 18 Jan 2023 16:05:43 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/01/Copy-of-Computer-Networks-Hub-Switch.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>There are some magical things about the Internet, and one thing in particular is that it works. In spite of so many obstacles, we can deliver our packets over the globe, and do so fast.</p>
<p>Even more specifically, one amazing thing about the Internet is its ability to handle errors. </p>
<p>What do I mean by errors? When a packet or a frame is received by a machine, we say it contains an error if the data that had been sent is not the data that was received. For instance, a single <code>1</code> was mistakenly received as a <code>0</code> after its transmission. </p>
<p>This can happen due to many different reasons. Perhaps there was some disturbance in the wire where the data was transmitted – say, a child rode her bicycle over the wire. Perhaps there was some collision in the air as many people transmitted at once. Maybe it was a device's error.</p>
<p>Regardless of the specific reason, you still get valid data on the Internet. Without handling errors, you may read the last sentence and instead of <code>errors</code> read <code>errbbb</code>. Weird, isn't it? So how does the Internet handle errors?</p>
<p>There are two main approaches for handling errors – detection, and correction. We shall start by describing detection, and then talk about correction.</p>
<h1 id="heading-what-is-error-detection">What is Error Detection?</h1>
<p>When dealing with error detection, we are looking for a boolean result – <code>True</code>, or <code>False</code>. Is the frame/packet valid, or not. That is all. We don’t want to know where the error occurred. If the frame is invalid, we will simply drop it.</p>
<p>So when the receiver receives a frame, they will determine whether an error has occurred. If the frame is valid, they will read it. If the frame contains errors - the receiver will drop it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-84.png" alt="Image" width="600" height="400" loading="lazy">
_Error Detection: we only want to know if the frame/packet is valid or not. (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>One method for error detection is using a <strong>checksum</strong>. A common implementation of a checksum is called <strong>CRC – Cyclic Redundancy Check</strong>. </p>
<p>In this post we will not trouble ourselves with the mathematical implementation of CRCs in the real world (if you're interested, check out <a target="_blank" href="https://en.wikipedia.org/wiki/Cyclic_redundancy_check">Wikipedia</a>). Rather, we'll simply try to understand the concept. To do so, let’s implement a very simple checksum mechanism ourselves.</p>
<p>Consider a protocol for transmitting 10-digit phone numbers between endpoints. This protocol is extremely simple: each packet includes exactly 10 bytes, each one representing a digit. For example, a packet might include the following digits:</p>
<p><code>5551234567</code></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-85.png" alt="Image" width="600" height="400" loading="lazy">
_A packet with a payload of 10 digits (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>For simplicity's sake, we will omit the headers of the packet and focus solely on the payload. </p>
<p>Now, we will add a checksum. Say that we <strong>add</strong> all the digits. So in this example, we would calculate <code>5</code> + <code>5</code> +<code>5</code> +<code>1</code>+… all the way through <code>7</code>. We would get <code>43</code>. This would be our checksum value.</p>
<p>Now, the sender won’t only send the phone number, but also the checksum value right after it. In this example, the sender would send:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-86.png" alt="Image" width="600" height="400" loading="lazy">
_The packet's data is followed by a checksum. (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>Now, as the receiver, you can do the same thing. You will read the phone number, and calculate the checksum. You will add the digits, and get <code>43</code>. </p>
<p>Since you've received the correct result (that is, your calculation based on the data matches the checksum value sent in the packet), you can assume that the frame is valid.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-89.png" alt="Image" width="600" height="400" loading="lazy">
_The sender compares their calculated checksum value and the checksum in the packet. If the values match, the packet is assumed to be valid (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>What happens in case of an error? 🤔</p>
<p>Let’s say, for instance, that the digit <code>2</code> was replaced by an <code>8</code>. Now, even though the sender sent the same stream as before ( <code>555123456743</code> ), you, as the receiver, see something a bit different:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-90.png" alt="Image" width="600" height="400" loading="lazy">
_A packet containing an error (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>Now, you are calculating the checksum, adding all the digits. You get <code>49</code>. Since this value is different from the checksum value specified in the original frame, <code>43</code>, the frame is considered to be invalid and you drop it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-91.png" alt="Image" width="600" height="400" loading="lazy">
_The sender compares their calculated checksum value and the checksum in the packet. If the values don't match, the packet is assumed to be invalid (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>Are there problems with this method? 🤔</p>
<p>Yes, there are. Consider, for example, what happens if there are two errors – and instead of the original stream ( <code>555123456743</code> ), you receive the following:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-92.png" alt="Image" width="600" height="400" loading="lazy">
_A packet received with two errors, resulting in the stream <code>456123456743</code> (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>What happens when you add the digits?</p>
<p>Even though the digits are not the same as the original packet, the checksum will remain correct, and the frame will be regarded as valid.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-93.png" alt="Image" width="600" height="400" loading="lazy">
_Despite the errors, the checksum value happens to be correct, resulting in a false assumption that the packet is valid (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>Real checksum functions, such as CRCs, are of course much better implemented than the one in our example – but in extremely rare cases, such problems may occur. </p>
<p>Notice that using this kind of method, error detection, we don’t know where the problem occurred, but only whether the frame is valid or not. If the checksum value is invalid, we assume that the frame is invalid and drop it.</p>
<h1 id="heading-what-is-error-correction">What is Error Correction?</h1>
<p>As mentioned earlier, detection is not the only way to handle errors. Another approach might be to find the error and correct it. How can we do that?</p>
<p>An extremely simple way would be to transmit the data many times – let’s say, three times. For example, the stream <code>5551234567</code> would be transmitted as follows:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-94.png" alt="Image" width="600" height="400" loading="lazy">
_Sending the same data multiple times (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>So we basically sent the data three times.</p>
<p>Now, in case of an error in one digit, the receiver can look at the other two digits, and choose the one that appears two times out of three.</p>
<p>So, for instance, if we had a problem and <code>2</code> was replaced with an <code>8</code>, the receiver would get this stream:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-95.png" alt="Image" width="600" height="400" loading="lazy">
_An error in one of the occurrences of the data (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>Now, as a receiver, you can say: “I have <code>2</code>, <code>8</code>, <code>2</code>… so it was probably <code>2</code> in the original message”.</p>
<p>Is this problematic? Well, in some rare cases, we might get the same error twice. So it is possible, even though unlikely, that two of the original twos have been received as eights.</p>
<p>So while the sender sent this stream:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-94.png" alt="Image" width="600" height="400" loading="lazy">
_Sending the same data multiple times (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>The first <code>2</code> was mistakenly read as an <code>8</code>, and also the second <code>2</code> was received as an <code>8</code>:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-96.png" alt="Image" width="600" height="400" loading="lazy">
_Two identical errors; Rare, but possible (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p> Now, it looks as if the original message included an <code>8</code>, and not a <code>2</code>.</p>
<p>What can you do in order to lower the probability of such scenario?</p>
<p>The most simple solution would be to simply send the data even more times. Let’s say, five times. So now we duplicate all the data, and send it 5 times in total… </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-97.png" alt="Image" width="600" height="400" loading="lazy">
_Sending the data five(!) times (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>Now, say that two errors occurred, and again two of the <code>2</code> digits were replaced with <code>8</code>s.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-98.png" alt="Image" width="600" height="400" loading="lazy">
_Two identical errors; Rare, but possible (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>Clearly, it is very unlikely to get the same error twice, but even in this case, we still get <code>2</code> three times, so as the receiver you can tell, with a high probability, that the original message contained a <code>2</code>, rather than an <code>8</code>.</p>
<h2 id="heading-whats-the-overhead">What's the Overhead?</h2>
<p>Now would be a good time to introduce the term <strong>overhead</strong>. When we say overhead, we basically mean data or time needed to convey the actual message. Let’s first understand what this term means in general, and then consider it in the context of handling errors.</p>
<p>Let’s say that I have a lesson to teach in my university. My goal is to teach the lesson itself, which is also called the <strong>payload</strong> in that context – that is, the actual data or message I would like to convey.</p>
<p>In order to teach the lesson, or to convey the payload, I first have to physically get to the university – so I get out of my home, walk to the bus station, wait for the bus, take the bus, get off the bus, walk to the building, wait for the lesson to start – and only then do I actually get to teach the lesson. </p>
<p>This entire process is <strong>overhead</strong> that I have to pay in order to deliver the <strong>payload</strong>, in this case – to teach the lesson.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-99.png" alt="Image" width="600" height="400" loading="lazy">
_Overhead and Payload are two extremely important terms in Computer Networks (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>The same applies in computer networks. Our <strong>payload</strong> is the data, and there is always some <strong>overhead</strong> associated with sending it. </p>
<h2 id="heading-back-to-handling-errors">Back to Handling Errors</h2>
<p>In the context here – sending the data three times, as suggested earlier, means that for every byte of payload we have two bytes of overhead. If we send the data five times, then for every byte of payload, we have four bytes of overhead. That’s a LOT!</p>
<p>Consider error <em>detection</em>, on the other hand. In our example protocol for sending phone numbers, how much overhead did we have?</p>
<p>Recall that for every ten-digit phone number, that is ten bytes, we included a two-digit checksum value. In other words, we had two bytes of overhead for ten bytes of payload. It is clear that in our example, error detection yields much smaller overhead in comparison to error correction.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-100.png" alt="Image" width="600" height="400" loading="lazy">
_In the sample protocol, for every ten-digit phone number (ten bytes of payload), we included a two-digit checksum value (two bytes of overhead) (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>There are better ways to achieve error correction with high accuracy than to simply send the data so many times, but they are more complicated and out of scope for this post. Even with very complicated error correction techniques, they still require lots of overhead when compared to error detection.</p>
<p>Also, notice that except for the bytes sent as overhead in case of error correction, error detection is much simpler. </p>
<h1 id="heading-error-correction-vs-error-detection-which-is-better">Error Correction vs Error Detection – Which is Better?</h1>
<p>We already concluded that error detection is simpler, and with a smaller payload compared to error correction.</p>
<h3 id="heading-so-when-would-we-prefer-error-correction">So, when would we prefer error correction?</h3>
<p>One case might be when we have a one-way link. That is, a network where we can only transfer data in one direction. </p>
<p>For example, say you have a secret agent that you need to send a message to. The agent knows that they need to look up to the sky at exactly midnight, and they will see a series of flashes indicating the secret message. </p>
<p>The secret agent cannot reply, or their location and identity will be revealed. In addition, you don’t want to send the message over and over again, as not to draw much attention, and to make it harder for someone to intercept the message.</p>
<p>In this case, you definitely want your agent to receive the exact message that you’ve sent. Consider a case where you want to send them the message “do not place the bomb”. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-101.png" alt="Image" width="600" height="400" loading="lazy">
_A sensitive message for a secret agent (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>Of course, you don’t want to risk the unfortunate scenario of the agent reading the message as “do <strong>now</strong> place the bomb”, due to an error.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-102.png" alt="Image" width="600" height="400" loading="lazy">
_An error may change the meaning of the message substantially (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>If you use error <em>detection</em>, the agent might be aware that the message they received is invalid in case of an error, but they won’t be able to tell you that they need you to send the message again. As you want the agent to be able to read your message correctly and without sending any data back to us, error correction is preferred.</p>
<p>So, one-way link is one case where we prefer error correction. What about other cases?</p>
<p>Sometimes you just <em>can’t</em> send the data again, perhaps because it has been erased from the memory of your machine. That is, the data is deleted right after it has been sent. In this case, you'd clearly prefer error correction, as sending the data again, as we would do with error detection, is just impossible.</p>
<p>Also, if sending the data again is possible, but extremely expensive, error correction may be preferable. </p>
<p>For example, if you send a message to the moon, say, with a spaceship – it might be really expensive to send it over again in case of an error. Using error correction, you send the data only once and the receiver should be able to deal with it, even if an error occurred.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/01/image-103.png" alt="Image" width="600" height="400" loading="lazy">
_Cases where correction is preferred (<a target="_blank" href="https://www.youtube.com/watch?v=H_bYtVDF6T4&amp;ab_channel=Brief">Source: Brief</a>)_</p>
<p>In general, we prefer error correction when retransmitting the data is costly or impossible. </p>
<h3 id="heading-when-would-we-prefer-error-detection">When would we prefer error detection?</h3>
<p>Well, in case we can retransmit the data, we usually prefer error detection since it comes with very little overhead compared to error correction. Especially, when sending the data is relatively cheap.</p>
<p>For example, on the Internet, if an error occurs when you send a frame, no problem – you can simply send it again! </p>
<p>For example, when I covered <a target="_blank" href="https://www.freecodecamp.org/news/the-complete-guide-to-the-ethernet-protocol/">the Ethernet protocol in a previous post</a>, I mentioned that Ethernet protocol uses change detection, namely <code>CRC32</code> – that is, 32 bits (or 4 bytes) of a checksum for every frame. </p>
<p>Note that it doesn’t mean that error detection is simply better. It just better fits the Internet than error correction. As mentioned before, error correction is preferable in other cases.</p>
<h1 id="heading-wrapping-up">Wrapping Up</h1>
<p>In this tutorial, we discussed various methods for handling errors. We looked at <strong>error detection</strong>, where we only know whether a frame is valid or not. We also considered <strong>error correction</strong>, where the receiver can restore the correct value of an erroneous frame. We also introduced the term <strong>overhead</strong>. </p>
<p>We then understood why we use error detection on the Internet, rather than error correction. Stay tuned for more posts in this series about Computer Networks 💪🏻</p>
<h2 id="heading-about-the-author"><strong>About the Author</strong></h2>
<p><a target="_blank" href="https://www.linkedin.com/in/omer-rosenbaum-034a08b9/">Omer Rosenbaum</a> is <a target="_blank" href="https://swimm.io/">Swimm</a>’s Chief Technology Officer. He's the author of the Brief <a target="_blank" href="https://youtube.com/@BriefVid">YouTube Channel</a>. He's also a cyber training expert and founder of Checkpoint Security Academy. He's the author of <a target="_blank" href="https://data.cyber.org.il/networks/networks.pdf">Computer Networks (in Hebrew)</a>. You can find him on <a target="_blank" href="https://twitter.com/Omer_Ros">Twitter</a>.</p>
<h2 id="heading-additional-resources"><strong>Additional Resources</strong></h2>
<ul>
<li><a target="_blank" href="https://www.youtube.com/playlist?list=PL9lx0DXCC4BMS7dB7vsrKI5wzFyVIk2Kg">Computer Networks Playlist - on my Brief channel</a></li>
<li><a target="_blank" href="https://en.wikipedia.org/wiki/Cyclic_redundancy_check">CRC - Wikipedia</a></li>
<li><a target="_blank" href="https://www.freecodecamp.org/news/the-complete-guide-to-the-ethernet-protocol/">The Complete Guide to Ethernet Protocol</a></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ How to Use Scapy – Python Networking Tool Explained ]]>
                </title>
                <description>
                    <![CDATA[ In this post you will learn about an amazing tool named Scapy. Scapy is a Python library that enables us to send, sniff, and dissect network frames.  It is useful in a variety of use cases, one of which is to actually get some hands-on experience whe... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-to-use-scapy-python-networking/</link>
                <guid isPermaLink="false">66c17c3b675b2f6950fa0bfa</guid>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ computer networking ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Python ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Omer Rosenbaum ]]>
                </dc:creator>
                <pubDate>Wed, 21 Dec 2022 21:02:17 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/12/Computer-Networks-Hub-Switch--1-.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In this post you will learn about an amazing tool named <strong>Scapy</strong>. Scapy is a Python library that enables us to send, sniff, and dissect network frames. </p>
<p>It is useful in a variety of use cases, one of which is to actually get some hands-on experience when you learn Computer Networks. Wouldn't it be great if, when <a target="_blank" href="https://www.freecodecamp.org/news/the-complete-guide-to-the-ethernet-protocol/">learning about Ethernet</a>, for example, you could create, send, sniff and parse Ethernet frames on your own? Scapy is the perfect tool for that.</p>
<p>In addition, you can use Scapy for creating networking-based applications, parsing network traffic to analyze data, and many other cases.</p>
<p>This post assumes you have some background knowledge in Computer Networks, for example about <a target="_blank" href="https://www.freecodecamp.org/news/the-five-layers-model-explained/">the layers model</a>. It also assumes you have some basic Python knowledge.</p>
<h1 id="heading-what-will-you-learn">What will you learn?</h1>
<p>In this post we will start from the very basics – what Scapy is, and how to install it. </p>
<p>You will learn how to sniff data and parse it with Scapy, and how to display it in a meaningful manner. </p>
<p>You will also learn how to create frames or packets, and how to send them. Altogether, you should have a new powerful tool under your belt.</p>
<h1 id="heading-how-to-install-scapy">How to Install Scapy</h1>
<p>To install Scapy, you can simply use <code>pip install scapy</code>.</p>
<p>If you run into trouble, simply follow <a target="_blank" href="https://scapy.readthedocs.io/en/latest/installation.html">the official documentation</a>.</p>
<h1 id="heading-how-to-use-scapy">How to Use Scapy</h1>
<p>For now, let’s open up the command line and type in <strong><code>scapy</code></strong>.</p>
<p>You should expect something like the following:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-83.png" alt="Image" width="600" height="400" loading="lazy">
_Running Scapy from the CLI (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Note that the warning messages are fine.</p>
<p>Since this is a Python environment, <em>dir</em>, <em>help</em>, and any other Python function for information retrieval are available for you. Of course, you can always combine Python code with your Scapy scripts.</p>
<h1 id="heading-how-to-work-with-packets-and-frames-in-scapy">How to Work with Packets and Frames in Scapy</h1>
<p>Packets and frames in Scapy are described by objects created by stacking different layers. So a packet can have a variable number of layers, but will always describe the sequence of bytes that have been sent (or are going to be sent) over the network.</p>
<p>Let's create a frame that consists of an Ethernet layer, with an IP layer on top:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-85.png" alt="Image" width="600" height="400" loading="lazy">
_Stacking Layers (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Look how easy that is! We’ve used the <code>/</code> operator in order to stack the IP layer on top of the Ethernet layer. </p>
<p>Note that when looking at this object, it only tells us non-default values. The type of Ethernet is <code>0x800</code> (in hexadecimal base) as this is the type when an IP layer is overloaded.</p>
<p>Let's look more deeply at the fields of the packet:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-86.png" alt="Image" width="600" height="400" loading="lazy">
_With the <code>show</code> method we can observe all fields of the frame (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Pretty cool! 😎</p>
<h1 id="heading-how-to-sniff-with-scapy">How to Sniff with Scapy</h1>
<p>Scapy also allows us to sniff the network by running the <strong>sniff</strong> command, like so:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-87.png" alt="Image" width="600" height="400" loading="lazy">
_Sniffing with the <code>sniff</code> command (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>After running <code>sniff</code> with <code>count=2</code>, Scapy sniffs your network until <code>2</code> frames are received. Then it returns – and in this case, the variable <code>packets</code> will store the frames that have been received.</p>
<p>The return value of sniff can be treated as a list. Therefore <code>packets[0]</code> will contain the first packet received, and <code>packets[1]</code> will contain the second:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-88.png" alt="Image" width="600" height="400" loading="lazy">
_The return value of <code>sniff</code> is an iterable, so it can be accessed as a list (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>A helper function <code>summary</code> is available too and will provide minimal information regarding the packet collection:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-89.png" alt="Image" width="600" height="400" loading="lazy">
_Using <code>summary</code> we can get some information of the packet collection (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>When looking at a specific frame, every layer or field can be accessed in a very elegant way. For instance, in order to get the <strong>IP</strong> section of the packet, we can access it like so:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-90.png" alt="Image" width="600" height="400" loading="lazy">
_Accessing a specific layer (and its payload) (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Note that this shows us everything from the IP layer and <em>above</em> (that is, the <em>payload</em> of the IP layer). Let's now observe the source Ethernet address of this frame:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-91.png" alt="Image" width="600" height="400" loading="lazy">
_Accessing a specific field (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Nice and easy. Now, you will learn how to run a specific command for every frame that you sniff. </p>
<p>First, create the callback function that will be run on every packet. For example, a function that will just print the source Ethernet address of the received frame:  </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-92.png" alt="Image" width="600" height="400" loading="lazy">
_Defining a callback function that receives a frame as its argument (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Now, we can pass this function to <code>sniff</code>, using the <code>prn</code> argument:  </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-93.png" alt="Image" width="600" height="400" loading="lazy">
_Run a callback function on every sniffed frame (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>The Ethernet addresses have been printed as a result of <code>print_source_ethernet</code> being executed, where every time, it receives a sniffed frame as an argument.<br>Note that you can write the same in Python using a lambda function, as follows:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-94.png" alt="Image" width="600" height="400" loading="lazy">
_Define the callback function using <code>lambda</code> (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>If you prefer to write an explicit function like the one we’ve written above, that’s perfectly fine.</p>
<p>We usually want to <strong>filter</strong> traffic that we receive – and look only at relevant frames. Scapy’s <code>sniff</code> function can take a filter function as an argument – that is, a function that will be executed on every frame, and return a <code>boolean</code> value – whether this frame is filtered or not.</p>
<p>For example, say we would like to filter only frames that are sent to broadcast. Let’s write a simple filtering function that does just that:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-95.png" alt="Image" width="600" height="400" loading="lazy">
_A simple filtering function (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Now, we can use the <code>lfilter</code> parameter of <code>sniff</code> in order to filter the relevant frames:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-96.png" alt="Image" width="600" height="400" loading="lazy">
_Filtering frames based on a filter function (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>In order to clarify, let’s draw this process:  </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-97.png" alt="Image" width="600" height="400" loading="lazy">
_The process of sniffing and filtering with <code>lfilter</code> (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>A frame <code>f</code> is received by the network card. It is then transferred to <code>lfilter(f)</code>. If the filter function returns <code>False</code>, <code>f</code> is discarded. If the filter returns <code>True</code>, then we execute the <code>prn</code> function on <code>f</code>.</p>
<p>So we can now combine these two arguments of <code>sniff</code>, namely <code>lfilter</code> and <code>prn</code>, and print the source address of every frame that is sent to the broadcast address. Let’s do this now using <code>lambda</code>:  </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-98.png" alt="Image" width="600" height="400" loading="lazy">
_Combining <code>lfilter</code> and <code>prn</code> 💪🏻 (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>This is equivalent to writing the following line, without lambda:</p>
<pre><code class="lang-py">sniff(count=<span class="hljs-number">2</span>, lfilter=is_broadcast_frame, prn=print_source_ethernet)
</code></pre>
<p>Readable, quick, and useful. Have you noticed that I love Scapy? 🥰</p>
<p>Alright, so far we’ve learnt how to sniff frames. When sniffing, we know how to filter only relevant frames, and how to execute a function on each filtered frame.</p>
<h1 id="heading-how-to-create-frames-in-scapy">How to Create Frames in Scapy</h1>
<p>To create a frame, simply create an Ethernet layer using <code>Ether()</code>. Then, stack additional layers on top of it. For instance, to stack an <code>IP</code> layer:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-99.png" alt="Image" width="600" height="400" loading="lazy">
_Creating a frame with two stacked layers (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Alternatively, we can just add raw data, as follows:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-100.png" alt="Image" width="600" height="400" loading="lazy">
_Using Raw data as the payload (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>If you want to specify a specific value, for instance the destination address of the frame, you can do it when you initially create the frame, like so:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-101.png" alt="Image" width="600" height="400" loading="lazy">
_Creating a frame and specifying specific values (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Or, we can modify the specific field after creation:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-102.png" alt="Image" width="600" height="400" loading="lazy">
_Modifying specific values (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>How can we look at the frame we’ve just created? One way is to observe a frame using <code>show</code>, as we’ve done above. Another way of looking at a frame is by looking at its byte stream, just like in Wireshark. You can do this using the <code>hexdump</code> function:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-103.png" alt="Image" width="600" height="400" loading="lazy">
_Viewing the hexadecimal byte stream (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Well, even better – we can just look at it inside Wireshark! By running <code>wireshark(frame)</code>.</p>
<h1 id="heading-how-to-send-frames-in-scapy">How to Send Frames in Scapy</h1>
<p>You can send frames using <code>sendp</code>, as follows:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-104.png" alt="Image" width="600" height="400" loading="lazy">
_Sending frames with <code>sendp</code> (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Let's sniff in wireshark while sending the frame to make sure that it’s actually sent:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-105.png" alt="Image" width="600" height="400" loading="lazy">
_Observing the frame we've sent using Wireshark (Source: <a target="_blank" href="https://www.youtube.com/watch?v=f0vpwwNAcdI&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Note that we use <code>sendp</code> only when we send an entire frame, using the second layer and above. If you want to send a packet including only the third layer and above, use <code>send</code> instead.</p>
<h1 id="heading-recap">Recap</h1>
<p>In this post you got to know an awesome tool called Scapy. You saw how you can sniff, how to filter packets, and how to run a function on sniffed packets. You also learned how to create and send frames.</p>
<h2 id="heading-about-the-author">About the Author</h2>
<p><a target="_blank" href="https://www.linkedin.com/in/omer-rosenbaum-034a08b9/">Omer Rosenbaum</a> is <a target="_blank" href="https://swimm.io/">Swimm</a>’s Chief Technology Officer. He's the author of the Brief <a target="_blank" href="https://youtube.com/@BriefVid">YouTube Channel</a>. He's also a cyber training expert and founder of Checkpoint Security Academy. He's the author of <a target="_blank" href="https://data.cyber.org.il/networks/networks.pdf">Computer Networks (in Hebrew)</a>. You can find him on <a target="_blank" href="https://twitter.com/Omer_Ros">Twitter</a>.</p>
<h2 id="heading-additional-resources"><strong>Additional Resources</strong></h2>
<ul>
<li><a target="_blank" href="https://www.youtube.com/playlist?list=PL9lx0DXCC4BMS7dB7vsrKI5wzFyVIk2Kg">Computer Networks Playlist - on my Brief channel</a></li>
<li><a target="_blank" href="https://scapy.readthedocs.io/en/latest/">Official Scapy documentation</a></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Linux Networking Commands You Should Know as a Beginner ]]>
                </title>
                <description>
                    <![CDATA[ Can you imagine what it would be like to have a laptop but not to be able to access the internet? If you're a developer (or an aspiring one), you'll likely use the internet every day. So you should learn a few useful networking commands.  To learn ne... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/linux-networking-commands-for-beginners/</link>
                <guid isPermaLink="false">66ba10e990067134b63982c7</guid>
                
                    <category>
                        <![CDATA[ beginner ]]>
                    </category>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ computer networking ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Linux ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Arunachalam B ]]>
                </dc:creator>
                <pubDate>Fri, 09 Dec 2022 18:54:20 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/12/FreeCodeCamp---Networking-in-Linux.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Can you imagine what it would be like to have a laptop but not to be able to access the internet?</p>
<p>If you're a developer (or an aspiring one), you'll likely use the internet every day. So you should learn a few useful networking commands. </p>
<p>To learn networking in Linux, you should also know how to use the Terminal. Because using terminal commands is way more powerful than using the UI. It'll also be faster and more efficient.</p>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>A basic understanding of the Linux terminal is enough to learn networking in Linux.</p>
<h2 id="heading-how-to-find-the-ip-address-of-your-machine">How to Find the IP Address of Your Machine</h2>
<p>This is the most basic question in networking and it's the starting point of learning networking.</p>
<p>But, Wait.</p>
<h3 id="heading-whats-an-ip-address">What's an IP Address?</h3>
<p>IP stands for "Internet Protocol," which is the protocol (set of rules) governing how data are sent via the internet or a local network. </p>
<p>An IP address is basically a unique address to identify a device on the internet or on a local network.</p>
<p>Ok, now that we know what an IP address is, let's continue.</p>
<p>Being a professional web developer, I work on developing websites along with their backend services. </p>
<p>One day an intern asked me some questions about an interesting project he was working on. He wanted his site to be responsive on desktop, mobile, and tablet.</p>
<p>Though the site looked responsive, once I adjusted the browser window and switched to the mobile view on his laptop, the outcome on the phone after deployment was not so impressive.</p>
<p>So, he asked me for help,</p>
<p>"I wanted to check the site's responsiveness with my mobile in development mode. Is it possible?" he asked.</p>
<p>"Yes, it is. Connect your laptop and mobile on the same network. Find your laptop IP, and navigate to <code>ip:&lt;server_port&gt;</code> on your mobile browser", I replied.</p>
<p>So he opened a new tab in the browser and started typing "https://whatismy...", I stopped him and asked what he was searching for.</p>
<p>He told me he was finding his IP address.</p>
<p>"Use <code>ifconfig</code> command to find the IP address of your machine", I replied.</p>
<p>He opened up the terminal and tried out the command, like this:</p>
<pre><code class="lang-bash">ifconfig
</code></pre>
<p><img src="https://lh3.googleusercontent.com/ikkm_6NNhq1HetyT5ahF0dKUda-E23afbdn6seevR-tZTEalhOBN-W75GhUApYv1Xiw-ojtm9YLqIAXcalxsSpal53tsOefrLuzbhMzlK-2N7bkyUu4PZyharx0XzsQSN-9KBNjZ4pk_kLnnaTiyQcsYDBaSF5mAUSz0EGZx1pGJGlBO0PYhQZEpOjVCVg" alt="Image" width="600" height="400" loading="lazy">
<em>Sample Output of the ifconfig command</em></p>
<p>"Oh, Man! I'm confused now. Which is my IP here?", was his next question.</p>
<p>So I explained to him about each block in the above output: </p>
<p>Before walking into each block, you can find that few items are common for all blocks. Let's learn about them. </p>
<h3 id="heading-characteristics-of-network-interface">Characteristics of Network Interface</h3>
<p>The first line shows UP, LOOPBACK, RUNNING, NOARP, MULTICAST, etc. These are the characteristics of the network interface. For example, able to do BROADCAST, able to do MULTICAST. By default, the <code>ifconfig</code> command lists only the UP devices. The interface can also made down. </p>
<h3 id="heading-what-is-mtu">What is MTU?</h3>
<p>MTU stands for Maximum Transmission Unit. It determines the maximum payload size of a packet that is sent. The default standard value is <strong>1500 bytes</strong>. However, you can increase the payload size of the packet, which allows you to send more data and increase the data transfer rates. </p>
<h3 id="heading-inet-row-in-ifconfig">inet row in ifconfig</h3>
<p><strong>inet</strong> is the internet(IPv4) address assigned to that particular interface.  It will be set by DHCP client. </p>
<p>A <strong>Netmask</strong> is a 32-bit "mask" used to divide an IP address into subnets and specify the network's available hosts. </p>
<p><strong>Broadcast</strong> address refers to all hosts on the specified network simultaneously. </p>
<p><strong>Destination</strong> adress is the address of the remote host at the other end of the point-to-point link. </p>
<p><strong>inet6</strong> is the IPv6 address assigned to that particular interface. </p>
<p><strong>prefixlen</strong> is called Prefix length which specifies the number of bits in the IP address that are to be used as the subnet mask. </p>
<p><strong>scopeid</strong> is a id assigned for a zone. A scope is a topological area within which the IPv6 address can be used as a unique identifier for an interface or a set of interfaces. </p>
<h3 id="heading-rx-and-tx">RX and Tx</h3>
<p>Rx / Tx packets – displays the number of received / transmitted packets<br>Rx / Tx bytes – displays the packets size in buckets<br>Rx / Tx errors – displays the amount of error packets<br>Rx / Tx drop – displays the amount of dropped packets<br>Rx / Tx overrun – displays the amount of overrun packets  </p>
<p>All the items mentioned above are self-explanatory except overrun. Here's a quick definition of overrun.<br>An <strong>overrun</strong> is a packet that does not get sent out during a specific polling cycle. This is due to scheduling. It does not indicate a failure of the packet, merely that it was not sent. Overrun packets are re-scheduled for the next cycle, but it is possible that the same packet may be overrun once more. </p>
<p>Let's explore what's each block for. </p>
<p>The first block starting with <code>enx...</code> (previously called <code>eth0</code>) is for Ethernet connection. Since, I have not connected an ethernet cable, it does not show any data. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-34.png" alt="Image" width="600" height="400" loading="lazy">
<em>Ethernet block in ifconfig command</em></p>
<p>The block starting with <code>lo</code> is called LoopBack Interface. This is a special interface that the system uses to communicate with itself.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-35.png" alt="Image" width="600" height="400" loading="lazy">
<em>LoopBack Interface block in ifconfig command</em></p>
<p>The block starting with <code>tun0</code> is called Tunneling Interface. It contains information about the VPN you are connected to. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-36.png" alt="Image" width="600" height="400" loading="lazy">
<em>Tunnel Interface block in ifconfig command</em></p>
<p>The block starting with <code>wlp2s0</code> is called Wireless on PCI. This is the main interface that is connected to the WIFI of your Local network. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/12/image-37.png" alt="Image" width="600" height="400" loading="lazy">
<em>Wireless Interface block in ifconfig command</em></p>
<p>If you're connected to your Wifi, you have to use the last one. </p>
<h2 id="heading-how-to-download-a-file-using-the-linux-terminal">How to Download a File Using the Linux Terminal</h2>
<p>One fine day my boss sent a bunch of downloadable links to me and asked me to download and wrap them in a Zip file and send it back to him.  </p>
<p>I thought it would be easy work, but then I realized that it had 100+ downloadable links 🥲.</p>
<p>Activating Zen mode, I started searching for a way to automate this. This is when I found out about the <code>wget</code> command. You can use this terminal command to download a resource from a link.</p>
<p>The <code>wget</code> command is highly flexible and you can use it in scripts and cron jobs. As <code>wget</code> is non-interactive, it can independently download resources in the background and does not require a user to be active or logged in.</p>
<p>The following command will download an image from the w3schools website, as an example, in your current folder:</p>
<pre><code class="lang-bash">wget https://www.w3schools.com/html/img_chania.jpg
</code></pre>
<p><img src="https://lh5.googleusercontent.com/qOuoghtmQbA7z0LYjN0vyL_UmDcJr_GIcOx_eU2RbUAo5IJFJ1_PiS6ncoTcUm_MUDHBEkk9N5oEnq3nH6ClbIwXFstZzBKqCHcU-0EUw0wObDngNWeMWOAUOBMBzpzrlJxGSNBP9omCkqVCMuujevN1-x6QnS-ZME0v6uPK0eKir02c5mSdfvfZEFSQog" alt="Image" width="600" height="400" loading="lazy">
<em>Command to download file using Linux Terminal</em></p>
<p>You can pass another argument to specify the destination folder where the file should be downloaded, like this:</p>
<pre><code class="lang-bash">wget https://www.w3schools.com/html/img_chania.jpg /home/user/downloads/pics/
</code></pre>
<p>I wrote a script to download all the files using the <code>wget</code> command and handed them over to my boss in just 15 minutes. He was pretty amazed.</p>
<h2 id="heading-how-to-find-out-if-your-system-is-connected-to-the-internet-using-a-terminal-command">How to Find Out if Your System is Connected to the Internet Using a Terminal Command</h2>
<p>You've likely faced this issue at least once in your lifetime.</p>
<p>My Laptop is connected to wifi. But why I'm not able to access the internet whereas the people around me can? </p>
<p>By default, most people typically try to disconnect and re-connect to the same or a different wifi network. 99% of the time this won't work, and you'll end up facing a "<strong>Hmm. We’re having trouble finding that site.</strong>" message in <strong>Firefox</strong>, or "<strong>No internet</strong>" with a dinosaur game in <strong>Chrome</strong>.</p>
<p>This is when you just need to be patient to figure out the issue. You need to discover whether it's an issue with your system or your browser. You have to figure out if you're able to access the internet without using a browser.</p>
<p>You can achieve this by using the <code>ping</code> terminal command. It looks like this:</p>
<pre><code class="lang-bash">ping google.com
</code></pre>
<p><img src="https://lh6.googleusercontent.com/2XfEhTdEZNavg-ZMMyWDjhBzQAe4ZSXmXkeUUElef6KSrmCcfJ1Y9G2-R2BFo8iO7SoIuKMp37PAUvIYMOzrODEHaUdatGqonjUOKLXpyJBoSInyfqdpy5_0SFhrXPyqkMO5utbvsC4vBekygIq4FX4OG1_YL7C6a07KYqnuPrCtWf-1aNWz-qaUhVkLSA" alt="Image" width="600" height="400" loading="lazy">
<em>Sample output of ping command</em></p>
<p>You can use the ping command to check your network connectivity. This command takes the URL or IP address as an argument and sends data packets to that specified address. Then it prints the response from the server with the transition time. It will print the response continuously until you cancel that process (with CTRL + C). Finally it will return the following details:</p>
<ol>
<li>Minimum Time taken to receive a response</li>
<li>Average Time taken to receive a response</li>
<li>Maximum Time taken to receive a response</li>
</ol>
<p>We can specify the number of packets to send using the <code>-c</code> flag, like this:</p>
<pre><code class="lang-bash">ping google.com -c 10
</code></pre>
<p>And we can specify the packet size also using the <code>-s</code> flag:</p>
<pre><code class="lang-bash">ping google.com -s 40
</code></pre>
<p>We can also specify the next request time using the <code>-i</code> flag:</p>
<pre><code class="lang-bash">ping google.com -i 2
</code></pre>
<p>and many more.</p>
<p>After executing the above command, hopefully you should be able to find if your system is connected to the internet. Most probably, your browser will be the culprit. Reinstalling the browser will fix this issue.</p>
<h2 id="heading-how-to-find-the-ip-address-of-a-website">How to Find the IP Address of a Website</h2>
<p>Before we move on, you should be able to answer the following:</p>
<h3 id="heading-what-is-a-dns">What is a DNS?</h3>
<p>DNS stands for Domain Name System. Every website we use has a domain (for example google.com or freecodecamp.org). Each of these domain names will point to particular IP address of a server. DNS is basically a system that has a table that maps each domain with the IP address.</p>
<p>Now it's time to move back on track and learn how to find the IP address of a site.</p>
<p><strong><code>nslookup</code></strong> (stands for “Name Server Lookup”) is a command to query the DNS server. It is a network administration tool for querying the Domain Name System (DNS) to get the domain name or IP address mapping or any other specific DNS record. System Admins and DevOps use it to troubleshoot DNS related issues.</p>
<p>Here's how to use it:</p>
<pre><code class="lang-bash">nslookup google.com
</code></pre>
<p><img src="https://lh3.googleusercontent.com/lwSLDftMWk2HsBYdKfc7FTwksBDqe4DqYBeNj6YEtU22Qi9cMVhbxy3SKFORTptHl2MOf4n8RZqmGDPPpFZoa5yyythXFKBVtIQBeioK3rLOgK6ExQ3_CUiC76DNMIreiW2zdLrVGgtI9DMIU4Tx8dj8Gg0pHh1PF5pdwl6vNBmf4bsSOX--dquLupoJbw" alt="Image" width="600" height="400" loading="lazy">
<em>Sample output of nslookup command</em></p>
<h2 id="heading-how-to-know-which-user-is-logged-in">How to Know Which User is Logged-In</h2>
<p>Linux supports multiple users and lets you manage those users. Each time you can log in as a different user. And you can use the <code>who</code> command to know which user you have been logged in as. </p>
<pre><code class="lang-bash">who
</code></pre>
<p>It looks like this: </p>
<p><img src="https://lh5.googleusercontent.com/H6ceH-av643ixKZD2Zj5R13uPoNrHKH4gqcipQmWUMCIREKz9AAPZ8jV5eVYXvGldFPZKQzL5CiRZ-DXUSfVNH6Ot0jXo-5BkrcQ2DMr3Zs-TUCAFA0VmOwRQYvPLjwIRW3mZfpdkiMw5CC22edsvC4rNi4rcbf3Je0cXEfWSRyg30ohFChk8w93klrSXg" alt="Image" width="600" height="400" loading="lazy">
<em>Terminal command to find Logged-In user in Linux Terminal</em></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this article, you have learned some basic networking commands in Linux.</p>
<p>You can subscribe to my newsletter on my <a target="_blank" href="https://5minslearn.gogosoon.com/">personal site</a> to receive more such insightful articles straight to your inbox. You'll also find a consolidated list of all my blogs. </p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Network Devices – How Hubs and Switches Work and How to Secure Them ]]>
                </title>
                <description>
                    <![CDATA[ In a previous post I described every bit and byte of the Ethernet protocol. In this post you will learn about two network devices, how they work, and how this knowledge may be used by hackers. How Classic Ethernet Works Before describing the network ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/how-hub-switch-work-and-how-to-protect-them/</link>
                <guid isPermaLink="false">66c17c3558ee0865d2671b5b</guid>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ computer networking ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Security ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Omer Rosenbaum ]]>
                </dc:creator>
                <pubDate>Thu, 27 Oct 2022 14:30:00 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/10/Computer-Networks-Hub-Switch.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>In <a target="_blank" href="https://www.freecodecamp.org/news/the-complete-guide-to-the-ethernet-protocol/">a previous post</a> I described every bit and byte of the Ethernet protocol. In this post you will learn about two network devices, how they work, and how this knowledge may be used by hackers.</p>
<h1 id="heading-how-classic-ethernet-works">How Classic Ethernet Works</h1>
<p>Before describing the network devices, consider a network without special network devices. That is, a network using classic Ethernet where all computers are attached to a single cable.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-168.png" alt="Image" width="600" height="400" loading="lazy">
_Four devices connected using classic Ethernet (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>In this case, if computer A sends a message to another computer, for instance – B, the message is sent over the shared cable, and all devices receive it.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-169.png" alt="Image" width="600" height="400" loading="lazy">
_With classic Ethernet, If A sends a message to B - all devices (except for A) receive this message (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Can you think of some problems with this network structure?</p>
<p>First, <strong>overload –</strong> all network frames are received by all computers. Let’s say A wants to send a frame to B. C also sees this frame, and has to realize that it is not destined to his address, and thus discard it. This process takes time and resources. The same process happens at machine D, of course.</p>
<p>Second, <strong>privacy –</strong> if C sees every message sent from A to B and vice versa, this means that the privacy is violated. We would rather have a network where only A and B see the messages sent between them.</p>
<p>Third, <strong>extensibility –</strong> this network is not really extensible. Assume that up to 10 computers can attach to this cable. What happens when you need to add one more computer? You'd have to replace the entire cable. This is expensive and inconvenient. </p>
<p>Well, the person who actually has to replace the cable is probably the I.T. person - you know, the one who makes sure that everything runs well in your network and is rarely noticed until something bad happens (at least when you work in an organization large enough to have I.T. people). </p>
<p>Just to be clear – we LOVE the I.T. person. We want their life to be good, we don’t want them to be running around buying cables all the time.</p>
<p>Fourth, <strong>collisions</strong> – let’s say A wants to send a message to B, and C wants to send a message to D. At the same time, both of them might start their transmission, and the messages will <em>collide</em>. </p>
<p>In this case, we get errors – much like the case where two people start to speak at the same time, and it is impossible to understand either of them.</p>
<p>Fifth, this network structure might lead to <strong>starvation</strong> – let’s say that A is transmitting a frame. If the other stations wish to avoid collisions, they will refrain from sending data. But now, machine A can keep on transmitting forever, thereby taking all the bandwidth to itself and not letting any other station speak. This is called starvation.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-181.png" alt="Image" width="600" height="400" loading="lazy">
_Five major problems with classic Ethernet networks (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Well, this doesn’t seem like the best network, does it?</p>
<p>We'll now get to know network devices that help deal with these issues.</p>
<h1 id="heading-how-network-devices-solve-these-problems">How Network Devices Solve These Problems</h1>
<h2 id="heading-what-is-a-hub">What is a Hub?</h2>
<p>One device that solves only the <strong>extensibility</strong> issue is called a <strong>Hub</strong>. A hub is a device with multiple ports that single Ethernet cables are connected to:  </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-182.png" alt="Image" width="600" height="400" loading="lazy">
_An Ethernet hub is a device with multiple ports, each connected to a single Ethernet cable (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>So now, instead of having one cable with multiple ports with many computers attached to it, we have instead a single hub, and each computer is connected to it via a single cable. This makes the I.T. person's life much easier.</p>
<p>The hub simply takes the pulse it receives and multiplies it – that is, sends it to all other ports. For example, if A sends a frame to B, the hub will send this frame to B, C and D – all ports except A’s port.</p>
<p>The hub doesn’t understand Ethernet, and doesn’t know anything about MAC addresses. For the hub, all bits are just bits transmitted over the wire, and these bits should get to all other ends.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-183.png" alt="Image" width="600" height="400" loading="lazy">
_A hub simply takes a bitstream and multiplies it to all ports but the source port (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Now, if you need to add a new computer to the network, you can simply connect it to the hub. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-199.png" alt="Image" width="600" height="400" loading="lazy">
_To add a new device to the network, we simply connect it to the Hub (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>What happens if the hub runs out of ports? No problem, we will connect it to another Hub, like so:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-200.png" alt="Image" width="600" height="400" loading="lazy">
_In case you run out of ports, you can add another Hub (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Nice! This is a lot easier to maintain than classic Ethernet.</p>
<p>Yet, at least with classic hubs, all other issues still remain. Since all computers receive the frame sent from A to B, there is no <strong>privacy</strong>, the network is <strong>overloaded</strong>, <strong>collisions</strong> may occur, and the network is prone to <strong>starvation</strong>. </p>
<p>What we really want is a device that, when A sends a frame to B, forwards that frame to B and <strong>only</strong> B. This device is called a <strong>switch</strong>.</p>
<h2 id="heading-what-is-a-switch">What is a Switch?</h2>
<p>If all the stations are connected via a <strong>switch</strong>, and A sends a frame to B, only B receives it. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-201.png" alt="Image" width="600" height="400" loading="lazy">
_With a Switch, if A sends a message to B - only B will receive it (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Notice that this means that all issues are indeed solved. The devices won’t be overloaded as every frame will get only to the relevant recipients. There are no privacy issues since, apart from the switch, only A and B see the frame. The network is easily extensible by plugging additional switches if needed.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-202.png" alt="Image" width="600" height="400" loading="lazy">
_Similar to working with Hubs, the network is easily extensible by adding multiple Switches (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>The switch can avoid collisions as every connection between a switch and an endpoint is a single <strong>collision domain</strong> – that is, the switch will refrain from sending more than one frame on a single wire at the same time.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-204.png" alt="Image" width="600" height="400" loading="lazy">
_Every connection between the Switch and another device forms an independent collision domain (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Similarly, there will be no starvation as B and C can communicate with one another while A is sending data. Even if A keeps sending frames destined to the entire network, that is the broadcast address, the switch can allow messages sent by other hosts to be transferred in between.</p>
<p>But, how can this magical switch operate?</p>
<p>Let’s say we have just bought a brand new switch and plugged it into the network. A sends a frame destined to B. How does the switch know where computer B resides?</p>
<p>One option would be to manually configure the switch. That is, have a table mapping between a MAC address and the relevant port, and have someone manually configure that table.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-205.png" alt="Image" width="600" height="400" loading="lazy">
_The Switch may hold a table mapping MAC addresses to physical ports (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>When we say <em>someone</em>, we usually mean the I.T. person. And, well, we LOVE I.T. people. We wouldn’t want to make them do this tedious job every time. </p>
<p>In addition, I don’t know about you, but most people don’t usually have an I.T. person at home for every time they plug a device into their network.</p>
<p>Another option would be to send a special message from the switch to every port, and then the endpoints will reply with their MAC addresses. The major downside here is that we now have to make all devices aware of the switch. We need to change the devices’ behavior so they reply to that special message.</p>
<p>It would be so much better if the switch were just <strong>transparent</strong> – no endpoint would need to know that it’s there, but it would still do the job.</p>
<p>Apparently, this can indeed be achieved!</p>
<p>Consider this network, with a brand new switch that has just been added to the network. The switch stores a table, mapping a MAC address to a physical port. This table is empty.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-206.png" alt="Image" width="600" height="400" loading="lazy">
_When a Switch joins a new network, the table mapping MAC addresses to physical ports is empty (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Now, A sends a frame to B.</p>
<p>The switch understands Ethernet, and can look at the Frame’s header and read the <strong>source address</strong>. Since this source address maps to “A”, and since the message has been sent from physical port number 2, the switch adds the mapping of A’s MAC address and port number 2 to its table.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-207.png" alt="Image" width="600" height="400" loading="lazy">
_When machine A sends a frame, the Switch inspects the frame, reads the source address, and maps it with the corresponding physical port (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>But what will the switch do with the frame? Well, for now, the switch doesn’t know where B resides, so the switch simply multiplies the frame and sends it to all ports, just like a hub would do. So for now, B, C and D all get the frame.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-208.png" alt="Image" width="600" height="400" loading="lazy">
_Since the Switch's table doesn't include a record for B, a frame destined to B is actually sent to all ports but the source port - the same as a Hub would do (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Next, A sends another message to B. The switch looks at it, and already knows that A’s MAC address is plugged to port number 2. It still doesn’t know B, so this frame is sent to all other ports as well.</p>
<p>Now, C sends a frame to A. The switch looks at the <strong>source address</strong>, and adds the mapping between C’s MAC address and port number 5 to its table.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-209.png" alt="Image" width="600" height="400" loading="lazy">
_Upon receiving a frame from C, the Switch parses its header, extracts the source address, and associates it with the corresponding physical port - port number 5 (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>This time, since the frame is destined to A’s MAC address, and since the switch knows that address – the frame can be forwarded to port number 2, and port number 2 only. Yay! 👏🏻👏🏻👏🏻</p>
<p>Now, B sends a message to C. The switch creates a mapping between port number 7 and B’s MAC address, which appears at the <strong>source address</strong> field.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-210.png" alt="Image" width="600" height="400" loading="lazy">
_The Switch keeps on learning the addresses gradually, filling in its internal mappings (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>The switch can also forward the message to C, as it already knows C's address.</p>
<p>So, in general, the switch uses the <strong>source address</strong> field of Ethernet frames to dynamically learn what addresses reside behind every port.</p>
<p>Now, a question for you: Is it possible for two different addresses to map to a single port? For example, to have the address of computer A map to port number 3, and also have the address of computer B map to port number 3? 🤔</p>
<p>Well, the answer is yes. Consider the following network:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-211.png" alt="Image" width="600" height="400" loading="lazy">
_A network diagram with five endpoints and three Switches (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Now, given that the switches know the network, when A sends a message to D, it will be sent to Switch 1, and then to Switch 2, and finally forwarded by Switch 2 to D. When Switch 2 sees the frame, what address does it see in the <strong>source address</strong> field?</p>
<p>The address of computer A, of course. Notice that switches are transparent, and never modify the MAC addresses. So Switch 2 learns that the MAC address of computer A resides behind port number 3. </p>
<p>Next, when computer B sends a frame to computer C, this message will also be transferred via switch 1 and then switch 2. So now, switch 2 learns that the MAC address of computer B resides behind port number 3 as well. So, in this case, both the MAC address of A and that of B reside behind port number 3. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-213.png" alt="Image" width="600" height="400" loading="lazy">
_Given this network diagram, switch 2 registers both the MAC address of A as well as that of B - with port number 3 (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Youk8eUjkgQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>NOTE that a switch is <strong>not</strong> an additional <em>hop</em>! We are not talking about routing here. As we’ve said earlier, a switch is a <strong>transparent</strong> device. From the endpoints’ perspective, there is no switch – A “feels” as if it were directly connected to B, C and D.</p>
<p>All devices that are connected via one <strong>hop</strong> are said to be in the same <strong>network segment</strong>. So here, all computers and switches – A, B, C, D, switch 1 and switch 2 – all reside within the same segment.</p>
<p>In the resources section below, I’ve added a link to an exercise about hubs and switches. You are welcome to solve it in order to make sure everything is clear. If you have any questions, feel free to reach out 😊</p>
<h2 id="heading-interim-summary">Interim Summary</h2>
<p>So far you learned about two network devices. First, a hub, which is basically a first layer device. That is, it only transmits bits from one port to other ports, without understanding any protocols. </p>
<p>Second, you got to know a second layer network device, namely a switch, which already "understands" the Ethernet protocol and MAC addresses. It uses that knowledge in order to transfer frames only to relevant ports, at least once it knows the network.</p>
<h1 id="heading-security-twist">Security Twist 😈</h1>
<p>Now that you understand how hubs and switches work under the hood, it's time to consider their security implications.</p>
<p>Assume that I am connected to a certain Ethernet segment, and you run on computer A. B sends a message to C. Is it possible for you to see that message?</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-214.png" alt="Image" width="600" height="400" loading="lazy">
_Four PCs, B is sending a frame to C (Source: <a target="_blank" href="https://www.youtube.com/watch?v=YVcBShtWFmo&amp;t=3s&amp;ab_channel=Brief">Brief</a>)_</p>
<p>In case the computers are connected via a hub, you certainly will see the message, as the hub simply forwards the frame to all ports (except for the source port) regardless of the destination address.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-215.png" alt="Image" width="600" height="400" loading="lazy">
_A hub would simply multiply the frame and send it to A, C and D (Source: <a target="_blank" href="https://www.youtube.com/watch?v=YVcBShtWFmo&amp;t=3s&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Furthermore, if the computers are connected via a switch, but the switch has not yet learned the address of the destination, this message will also be sent to your port – and, in general to all ports other than the source port, just like a hub would act.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-216.png" alt="Image" width="600" height="400" loading="lazy">
_A new switch acts just like a hub until it learns the destination address (Source: <a target="_blank" href="https://www.youtube.com/watch?v=YVcBShtWFmo&amp;t=3s&amp;ab_channel=Brief">Brief</a>)_</p>
<p>So, in these cases, your network card will receive the frames, but will it handle them?</p>
<p>As I covered in <a target="_blank" href="https://www.freecodecamp.org/news/the-complete-guide-to-the-ethernet-protocol/">a previous tutorial</a>, the first field of an Ethernet frame is the destination address. By default, the network card will discard frames that are not destined to its address, or to a group which its system belongs to, such as the broadcast address. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-217.png" alt="Image" width="600" height="400" loading="lazy">
_Ethernet frame structure - the devices first consider the destination address (Source: <a target="_blank" href="https://www.youtube.com/watch?v=YVcBShtWFmo&amp;t=3s&amp;ab_channel=Brief">Brief</a>)_</p>
<p>So, by default, if your network card happens to receive a frame that was not destined to it, the frame will be discarded. This is exactly where <strong>promiscuous mode</strong> comes in handy. When the network card is in promiscuous mode, it will not discard frames based on their destination MAC addresses.</p>
<p>Now, consider a network with a switch, and that switch has already learned all addresses of the network, thereby achieving privacy.</p>
<p>Let’s say that a malicious person works from computer C, and wants to see the communication being sent to computer B, even though the switch forwards those frames to B only.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-218.png" alt="Image" width="600" height="400" loading="lazy">
_A network with a switch that has already learned the MAC addresses and their corresponding ports. Can a malicious person see private communication? (Source: <a target="_blank" href="https://www.youtube.com/watch?v=YVcBShtWFmo&amp;t=3s&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Can the malicious person do something in order to steal the data?</p>
<p>Well, the malicious person can pretend that they have B’s address. That is, the malicious person will send a frame with the source address of B. It doesn’t really matter what the destination address of that frame would be.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-219.png" alt="Image" width="600" height="400" loading="lazy">
_The malicious person sends a frame and impersonates B by specifying B's MAC address as the source address of the frame (Source: <a target="_blank" href="https://www.youtube.com/watch?v=YVcBShtWFmo&amp;t=3s&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Now, the switch sees a frame being sent from B’s address and from C’s port, in our diagram, port 5, and changes the mapping of B’s address to port 5. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-220.png" alt="Image" width="600" height="400" loading="lazy">
_As a result, the Switch changes the port associated with B's address (Source: <a target="_blank" href="https://www.youtube.com/watch?v=YVcBShtWFmo&amp;t=3s&amp;ab_channel=Brief">Brief</a>)_</p>
<p>As I mentioned earlier, it is indeed possible to have two different MAC addresses map to the same port number (for instance in case of an additional switch that connects the devices that have these addresses). But it is not possible to have B’s address mapped to two different ports.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-221.png" alt="Image" width="600" height="400" loading="lazy">
_As far as the Switch is concerned, B and C may indeed both be attached to it via port 5, perhaps through another Switch (Source: <a target="_blank" href="https://www.youtube.com/watch?v=YVcBShtWFmo&amp;t=3s&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Now, if A sends a message to B, it will actually get to C, but not to B! 😨</p>
<p>This technique is called <strong>MAC SPOOFING</strong>. The malicious entity is said to <strong>spoof</strong> B’s MAC address.</p>
<p>Is this technique very useful for the attacker? 🤔</p>
<p>Well, not really. Once B sends <em>any</em> frame at all to the network, the switch will replace the entry for B’s MAC address to that of the correct port number. So, for the attacker to keep receiving data, they will have to keep sending more frames on B’s behalf, thereby causing the switch to rewrite the table entry again and again.</p>
<p>This way, C will send a frame using B’s address, and the switch will map B’s MAC address to C’s port. Then, B will send a frame, and the switch will map B’s MAC address to B’s port again.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-223.png" alt="Image" width="600" height="400" loading="lazy">
_Once B send any frame, the Switch will overwrite its entry and the original value will be restored (Source: <a target="_blank" href="https://www.youtube.com/watch?v=YVcBShtWFmo&amp;t=3s&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Hence, B will receive some of the traffic, and this attack is easily noticeable.</p>
<p>There are many ways to defend a switch from such attacks. One would be to set the port with a maximum number of MAC addresses that are attached to it. For instance, if no other switch is supposed to be connected to a certain port, the maximum number of linked MAC addresses can be set to one.</p>
<p>How cool is that?! By understanding how a switch operates, we are able to estimate security issues that stem from its way of operation, as well as relevant countermeasures. 🤯</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>In this post you learned about two important network devices, a hub and a switch. </p>
<p>You learned that a hub simply multiplies the bitstream it receives to all ports other than the port that received the bitstream, whereas a switch forwards the frame only to the right port (once it has learned the network). You also learned how switches are able to achieve this ability automatically. </p>
<p>Lastly, you learned about a security problem that arises from the way switches operate, and how it may be mitigated.</p>
<h2 id="heading-about-the-author">About the Author</h2>
<p><a target="_blank" href="https://www.linkedin.com/in/omer-rosenbaum-034a08b9/">Omer Rosenbaum</a> is <a target="_blank" href="https://swimm.io/">Swimm</a>’s Chief Technology Officer. He's the author of the Brief <a target="_blank" href="https://youtube.com/@BriefVid">YouTube Channel</a>. He's also a cyber training expert and founder of Checkpoint Security Academy. He's the author of <a target="_blank" href="https://data.cyber.org.il/networks/networks.pdf">Computer Networks (in Hebrew)</a>. You can find him on <a target="_blank" href="https://twitter.com/Omer_Ros">Twitter</a>.</p>
<h2 id="heading-additional-resources">Additional Resources</h2>
<ul>
<li><a target="_blank" href="https://www.youtube.com/playlist?list=PL9lx0DXCC4BMS7dB7vsrKI5wzFyVIk2Kg">Computer Networks Playlist - on my Brief channel</a></li>
<li><a target="_blank" href="https://drive.google.com/file/d/1WeHTbRNph7mevNLwGeIkys1aP6_Z-Fbk/view">A DIY exercise about Hubs and Switches</a></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ What is the Five Layers Model? The Framework of the Internet Explained ]]>
                </title>
                <description>
                    <![CDATA[ Computer Networks are a beautiful, amazing topic. Networks involve so much knowledge from different fields, from physics to algorithms.  When dealing with Computer Networks, there is one framework that puts everything into place – and that is the lay... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/the-five-layers-model-explained/</link>
                <guid isPermaLink="false">66c17c4cc711c748ec71e875</guid>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ computer networking ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Omer Rosenbaum ]]>
                </dc:creator>
                <pubDate>Mon, 17 Oct 2022 13:37:19 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/10/d.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Computer Networks are a beautiful, amazing topic. Networks involve so much knowledge from different fields, from physics to algorithms. </p>
<p>When dealing with Computer Networks, there is one framework that puts everything into place – and that is the layers model. </p>
<p>In this post you'll learn <em>why</em> we need layers, as well as <em>what</em> the five layers model is. You will also understand the role of each layer in this model. </p>
<h1 id="heading-why-layers">Why Layers?</h1>
<p>Imagine you are given the task to design and implement the Internet! Where do you start? What do we actually want from a network, and an important one such as the Internet? </p>
<p>Well, we actually want quite a lot of things. To name a few:</p>
<ul>
<li>We want it to be <strong>fast</strong> – that is, allow fast communication. We don’t want to wait long for a message to get from one host to another.</li>
<li>It should also be <strong>reliable</strong> – when sending a message, we want the receiver to actually receive it.</li>
<li>The network should be <strong>extendable</strong> – that is, allow more devices to join. We wouldn’t want to start with two computers, and then not bee able to add a third one.</li>
<li>The network should support <strong>different devices and connections</strong> – it should be able to connect a wired PC, wireless laptop, and a cellphone, for example.</li>
</ul>
<p>And this is just a partial list.</p>
<p>So, how do we go about implementing the internet when we want to achieve so many different things?</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-58.png" alt="Image" width="600" height="400" loading="lazy">
<em>Computer Networks are complex (Source: <a target="_blank" href="https://xkcd.com/2259/">XKCD</a>)</em></p>
<p>In order to simplify things and make networks flexible, the communication is divided into <strong>layers</strong>.</p>
<p>Each layer has its own responsibility. It provides services to an upper layer, and uses services provided by a lower layer.</p>
<p>Consider an example network consisting of three devices:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-51.png" alt="Image" width="600" height="400" loading="lazy">
_An example network with three devices (Source: <a target="_blank" href="https://www.youtube.com/watch?v=iHp5J_f_ToQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>We have two layers:</p>
<p><strong>Layer Alpha</strong> is responsible for transmitting data between hosts that are directly connected to each other. In the diagram above, it's between hosts A and B, or between hosts B and C.</p>
<p><strong>Layer Beta</strong> is responsible for transmitting data between distant hosts. In the diagram, it's between hosts A and C.</p>
<p>What did we gain from this division? We gained a lot of <strong>flexibility</strong>.</p>
<p>Each layer can be developed and implemented by different people. The upper layer doesn’t care about the implementation of the lower layer, and vice versa.</p>
<p>For instance, the connection between hosts A and B could be a WiFi connection, while the connection between B and C could consist of a carrier pigeon. These are (completely) different implementations of Layer Alpha. </p>
<p>Notice that this way also enables us to have different specializations and expertise – an expert in training carrier pigeons does not necessarily have to be qualified at building solid WiFi network cards, or vice versa.  </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-52.png" alt="Image" width="600" height="400" loading="lazy">
_The Alpha Layer may have different implementations on the same network (Source: <a target="_blank" href="https://www.youtube.com/watch?v=iHp5J_f_ToQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Developers of Layer Beta don’t need to bother themselves with this difference. At this layer, host A needs to know that in order to reach host C, it first needs to send his message to host B, rather than, say, host D. Then, host B will forward it to host C.</p>
<p>This way, Layer Beta is only responsible for finding the route to send the message. It uses the service provided by Layer Alpha – transmitting data between directly connected hosts.</p>
<p>In general, networks are very complicated, and have various requirements. Dividing the communication into layers will allow us to simplify things and make communication more flexible.</p>
<p>Now that you understand <em>why</em> we need layers, we can go on to learn about the layers that are actually used in networks. </p>
<h1 id="heading-what-is-the-five-layers-model">What is the Five Layers Model?</h1>
<p>There have been a few layer models proposed along the years – most notably, the five layers model, the 7 layers model (aka OSI model), or the 4 layers model (aka the TCP/IP model). </p>
<p>They are way more similar than different, and I choose to focus on the five layers model as it is the most practical of all – and best describes the way the Internet actually works.</p>
<h2 id="heading-the-first-layer-the-physical-layer">The First Layer – The Physical Layer</h2>
<p>The first layer is responsible for <strong>transmitting a single bit</strong> – 0 or 1 – over the network.</p>
<p>To get some intuition as to what this layer is responsible for, consider the time of transmission. Assume that we have some kind of cable to transmit our data, and we use <code>+5</code> Voltage to transmit <code>1</code>, and <code>-5</code> Voltage to transmit <code>0</code>. What bits does the following diagram represent?</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-53.png" alt="Image" width="600" height="400" loading="lazy">
_A physical layer implementation encoding 1 as +5 Voltage and 0 as -5 Voltage (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Q3qqd6Y2FbQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Well, it might be <code>1001</code>. That is the case if it takes <em>this</em> long to transmit a single bit (demonstrated by the dashed orange line in the diagram below):</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-54.png" alt="Image" width="600" height="400" loading="lazy">
_An example bitstream encoded by this signal (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Q3qqd6Y2FbQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>However, it might also represent other bit streams. For instance, if it only takes half the time to transmit a single bit (demonstrated by the dashed green line below), then the bit stream might be <code>11000011</code>:  </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-55.png" alt="Image" width="600" height="400" loading="lazy">
_Another possible bitstream encoded by the same signal (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Q3qqd6Y2FbQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>The difference lies in the time dedicated for transmitting a single bit. This is called the <strong>bitrate –</strong> that is, the number of bits that are conveyed per unit of time.</p>
<p>Of course, achieving a high bitrate is preferable, as it means we can send many bits in a short timeframe. But it is hard to achieve high bitrates without getting many errors.</p>
<p>This is only one of the things that the first layer needs to take into consideration. The important thing for now is the goal of this layer: to transmit and receive a single bit.</p>
<h2 id="heading-the-second-layer-the-data-link-layer">The Second Layer – The Data Link Layer</h2>
<p>The second layer is responsible for transmitting data between <strong>two hosts that are directly linked</strong>, despite possible errors.</p>
<p>What do we mean by “directly linked”? For now, imagine that there is no device in between the two devices. So, if we have two computers here – computer A and computer B, and they are connected via computer M – then computer A and computer B are NOT directly linked. But computer A and computer M <strong>are</strong> directly linked, and so are computer M and computer B.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-56.png" alt="Image" width="600" height="400" loading="lazy">
_Two remote hosts connected via another device (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Q3qqd6Y2FbQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Another way to put it is that computer A and computer M are <strong>one hop</strong> away from one another, whereas computer A and computer B are <strong>two hops</strong> away. </p>
<p>That is, in order to get from computer A to computer B we need two “hops” – one hop from A to M, and another hop from M to B.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-57.png" alt="Image" width="600" height="400" loading="lazy">
_Every direct connection is called a Hop (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Q3qqd6Y2FbQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Going back to the second layer's responsibility – we mentioned it is responsible for transmitting data between two hosts that are directly linked, <strong>despite possible errors</strong>.</p>
<p>What do we mean by <strong>errors</strong>? The physical layer might provide erroneous data. For example, <code>1</code> instead of <code>0</code>. So a stream of bits such as <code>000110</code>, might be received as <code>001110</code>. </p>
<p>Many reasons might cause these kind of errors. For instance, we can think of a truck literally running over the wire where the bits are transmitted, causing some problem. Regardless of the reason, the second layer must handle the communication despite these errors.</p>
<p>The second layer sends data in <em>datagrams</em>, that is, in chunks. Datagrams in this layer are called <strong>Frames</strong>. Frames will usually contain <strong>MAC addresses</strong>, which are physical addresses, one identifying the sender, and another identifying the receiver.  </p>
<p>Why would we need a MAC address?</p>
<p>First, the receiving devices would like to know whether the frame is intended for them. The receiver wouldn’t like to waste precious time reading data intended for someone else. If the frame contains a MAC address that doesn’t belong to a receiver's device, that device can simply ignore this frame.</p>
<p>Second, for privacy reasons - we would like messages to arrive only at intended receivers, so only they can read the data.</p>
<p>Third, the sender would like the receiver to know who sent the frame. That way, the receiver will be able to send their response back to the sender, and not to someone else.</p>
<p>Note that we would like these addresses to be unique. That is, we want one address to identify a single device. That way, we know that if we send a message to a specific address it will be sent to the intended device only.</p>
<h2 id="heading-the-third-layer-the-network-layer">The Third Layer – The Network Layer</h2>
<p>The third layer is responsible for <strong>routing</strong> – that is, determining the path where the data will “travel”.</p>
<p>You can think of this layer as the successful routing app, Google Maps. When you get in the car and use Google Maps, you tell the app your destination, and Google Maps finds out the best route for you to drive in. </p>
<p>Notice that Google Maps is dynamic – it won’t necessarily pick the same route each time. Sometimes, one path will have a traffic jam, so Google Maps will prefer another route.</p>
<p>We said that the second layer has physical addresses, called MAC addresses. The third layer is responsible for <strong>logical addresses</strong>, such as <strong>IP addresses</strong>.</p>
<p>In this layer, datagrams are called <strong>packets</strong>.</p>
<p>Consider the following network diagram:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-59.png" alt="Image" width="600" height="400" loading="lazy">
_A network diagram with Computer A in France, Computer B in the US, and 10 routers in between (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Q3qqd6Y2FbQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>We have two computers here – one in France, and one in the United States. Of course, they are not directly linked. Rather, they are linked via third layer devices called <strong>routers</strong>.</p>
<p>Which layer is responsible for each connection?</p>
<p>Consider the connection between Computer A and Router 1. The second layer is responsible for this connection. What about the connection between Router 2 and Router 5? Right, again, this is the second layer. The same applies for each connection between two directly linked devices.</p>
<p>The third layer is responsible for defining the route – that the message sent from Computer A to Computer B will go through Routers 1, 2, 5, 8 and 10, and not in another way.</p>
<p>Note that there may be different implementations for each layer. For instance, we may have different implementations of the second layer. So while the connection between computer A and Router 1 might be over an Ethernet cable, the connection between Router 1 and 2 might be wireless and use WiFi. The connection between Router 2 and Router 5 might use a carrier pigeon, while the connection between router 5 and 9 will also use WiFi.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-61.png" alt="Image" width="600" height="400" loading="lazy">
_The second layer may be implemented differently on every link (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Q3qqd6Y2FbQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>The third layer does not care about these changes, but the second layer definitely does. If the carrier pigeon that transmits data from Router 2 to Router 5 is sick, the second layer will have to handle it. The data link layer will also have to make sure the data transmitted over the air between routers 1 and 5 is valid and without errors. </p>
<h2 id="heading-interim-summary">Interim Summary</h2>
<p>So far we have covered three of the five layers.  To recap:</p>
<ul>
<li>The physical layer is responsible for transmitting a single bit, <code>1</code> or <code>0</code>, over the network. </li>
<li>The data link layer is responsible for transmitting data between directly linked devices, that is – devices connected via a single hop. </li>
<li>The third layer is responsible for transferring data between hosts that are connected via multiple hops. It determines the route, the path that the packets will travel.</li>
</ul>
<h2 id="heading-the-fourth-layer-the-transportation-layer">The Fourth Layer – The Transportation Layer</h2>
<p>The fourth layer is an end-to-end layer. That is, it is responsible for communication from the source, all the way to the ultimate destination.</p>
<p>It allows <strong>multiplexing</strong> of multiple services. For example, one server may serve as a Web server, as well as a Mail server. When a client turns to that server, the client should be able to specify which service it would like to access. While the third layer specifies the address of the server, the transport layer identifies which <strong>service</strong> is relevant for the current communication.</p>
<p>In addition, the transport layer <em>may</em> ensure reliability. So when this layer receives data from the upper layer, it splits it into chunks, sends them, and makes sure that all those chunks arrive correctly at the other end. </p>
<p>Notice that the network layer is usually <em>not</em> reliable. Packets may arrive in incorrect order, they can arrive with incorrect data, or even not arrive at all. A reliable transportation layer makes sure that the data is correctly received.</p>
<p>In this layer, datagrams are called <strong>segments</strong>.</p>
<p>Consider the following network diagram once more:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-59.png" alt="Image" width="600" height="400" loading="lazy">
_The network diagram again (Source: <a target="_blank" href="https://www.youtube.com/watch?v=Q3qqd6Y2FbQ&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Which layer is responsible for what?</p>
<p>We have already said that the network layer is responsible for the route, that is, the path in which the packets travel. We also mentioned that the second layer is responsible for the transmission of the data between two, directly connected devices. For example, the link between Router 1 and Router 2.</p>
<p>The fourth layer views all of this network diagram as an abstract cloud. It doesn’t know the routers, and it doesn’t care about the structure of the network, or the routing. It assumes that the network can send a packet from one end to another:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-62.png" alt="Image" width="600" height="400" loading="lazy">
_The fourth layer sees the network as an abstract cloud (Source: <a target="_blank" href="https://www.youtube.com/watch?v=LYH4DwydVAM&amp;ab_channel=Brief">Brief</a>)_</p>
<p>The transportation layer makes sure that the endpoints can communicate over different services – for example, web and email. In addition, it might make sure that the connection is reliable. </p>
<p>One example would be to acknowledge every received segment. For instance, when computer A sends a segment to computer B, computer B will send a special Acknowledgement segment, announcing that it has received the packet. </p>
<h2 id="heading-the-fifth-layer-the-application-layer">The Fifth Layer – The Application Layer</h2>
<p>Last but definitely not least, we have the fifth layer, or <strong>Application Layer.</strong> This layer provides the service to the user’s application – web service, Voice over IP (VoIP), network games, streaming, and so on. </p>
<p>According to the layers model, the fifth layer doesn’t care at all about the network. It relies on the fourth layer, as well as the lower layers, to transmit the data from one endpoint to another. The fifth layer will use this service for the various needs of the application. </p>
<p>Different protocols will be used for different applications. For instance, HTTP protocol is commonly used for serving web pages on the World Wide Web. SMTP is a protocol used for emails, FTP for exchanging files, and there are many, many more.</p>
<h1 id="heading-what-is-encapsulation">What is Encapsulation?</h1>
<p>The goal of networks is to transmit data from one host to another.</p>
<p>To achieve this goal, each layer adds its own <strong>header</strong> to the data. A header contains information specific for that layer, and it precedes the data itself. </p>
<p>Consider a case where we have a lookup service, used in order to find a person’s phone number, given the person's name. The data consists of the person’s first and last name. </p>
<p>Before the packet is sent, the fifth layer might add its own <strong>header</strong>, describing that this is a REQUEST packet. The header might also specify that this is a request to map from a person’s name to a phone number, and not vice versa.  </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-64.png" alt="Image" width="600" height="400" loading="lazy">
_Header of the 5th layer, with data (Source: <a target="_blank" href="https://www.youtube.com/watch?v=DBLtFjrTvD0&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Then, the fifth layer passes the data to the fourth layer. Note, that the fourth layer regards everything as data – ones and zeroes. It doesn’t care if the fifth layer added a header, or what is written inside that header. </p>
<p>The fourth layer then adds its own header. For instance, it might specify that the requested service is the names-and-phones service. It may also include a sequential number for the packet, so it can be identified later.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-65.png" alt="Image" width="600" height="400" loading="lazy">
_Header of the 4th layer, with data which includes the 5th layer's header (Source: <a target="_blank" href="https://www.youtube.com/watch?v=DBLtFjrTvD0&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Afterwards, the fourth layer will pass the packet to the third layer. Again, the third layer will regard everything it has received – including the data itself, the header added by the fifth layer, and the header added by the fourth layer – simply as a chunk of data. </p>
<p>Then, the third layer will add its own header. For instance, it may include the source address and destination address of the packet.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-66.png" alt="Image" width="600" height="400" loading="lazy">
_Header of the 4th layer, with data which includes the 4th layer's header and data (Source: <a target="_blank" href="https://www.youtube.com/watch?v=DBLtFjrTvD0&amp;ab_channel=Brief">Brief</a>)_</p>
<p>This process goes on. So, each layer adds its own header to the packet<em>. This process is called <em>*encapsulation</em></em>.</p>
<p>On the other end, the receiver gets the packet and needs to read and remove the headers.</p>
<ul>
<li>The second layer may also include a <em>trailer</em> – an additional chunk of bits following the data, with some information.</li>
</ul>
<h1 id="heading-putting-it-all-together">Putting it All Together</h1>
<p>Now that we have covered the five layers, let’s have one example using all of them together. </p>
<p>Let’s say we would like to send a video file to our friend who lives in France, while we are enjoying a trip in Argentina. For that, we are using an email service. </p>
<p>The fifth layer defines how the email will be transmitted. For example, it includes the email address of the sender, as well as the receiver. It contains a title, and the body of the message. It requires that we follow a specific template of an email address, that will be included in the header of this layer. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/10/image-63.png" alt="Image" width="600" height="400" loading="lazy">
_The five layers model, with an example of sending an email (Source: <a target="_blank" href="https://www.youtube.com/watch?v=LYH4DwydVAM&amp;ab_channel=Brief">Brief</a>)_</p>
<p>Then, the fifth layer uses the fourth layer in order to split the email into chunks. Of course, each chunk will also carry the fourth layer's header. It is also used in order to specify that we are currently using an email service. </p>
<p>In this case, we definitely want the connection to be reliable – so the receiver will be able to play our video file correctly. Thus, the fourth layer will also handle reliability. On the receiver’s end, it might send an acknowledgment packet for every packet it receives.</p>
<p>The third layer will define the best route for every packet to be sent. It might choose different routes for different packets. Among other things, its header will contain the source and destination addresses for the packet.</p>
<p>The second layer will be responsible for every link between two directly connected devices. Its header will include the MAC addresses for each device. </p>
<p>The first layer is responsible for encoding all the ones and zeros, and to pass them over the line. And then, decoding and reading those ones and zeroes on the other end. On this layer, we don't really have a header, as it consists of single bits only.</p>
<p>This way, every layer uses the services provided by the lower layers, and the huge problem of transmitting data over the network becomes doable. How amazing is that?</p>
<h1 id="heading-summary">Summary</h1>
<p>In this post you learned what the five layers model is and why we need layers. You should now understand what each layer is responsible for, and you can fit every topic you encounter in Computer Networks into this model.</p>
<h2 id="heading-about-the-author">About the Author</h2>
<p><a target="_blank" href="https://www.linkedin.com/in/omer-rosenbaum-034a08b9/">Omer Rosenbaum</a> is <a target="_blank" href="https://swimm.io/">Swimm</a>’s Chief Technology Officer. He's the author of the Brief <a target="_blank" href="https://youtube.com/@BriefVid">YouTube Channel</a>. He's also a cyber training expert and founder of Checkpoint Security Academy. He's the author of <a target="_blank" href="https://data.cyber.org.il/networks/networks.pdf">Computer Networks (in Hebrew)</a>. You can find him on <a target="_blank" href="https://twitter.com/Omer_Ros">Twitter</a>.</p>
<h3 id="heading-additional-references">Additional References</h3>
<ul>
<li><a target="_blank" href="https://www.youtube.com/playlist?list=PL9lx0DXCC4BMS7dB7vsrKI5wzFyVIk2Kg">Computer Networks Playlist - on my Brief channel</a>.</li>
<li><a target="_blank" href="https://www.freecodecamp.org/news/osi-model-networking-layers-explained-in-plain-english/">The Seven Layer model explained in plain English</a></li>
<li><a target="_blank" href="https://www.freecodecamp.org/news/what-is-tcp-ip-layers-and-protocols-explained/">The TCP/IP model – layers and protocol explained</a></li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ What is Localhost? Local Host IP Address Explained ]]>
                </title>
                <description>
                    <![CDATA[ If you are an experienced web developer, then you’ve likely seen the term “localhost” on many occasions. And even if you’re a beginner and just getting started in web development, you might have seen the number “127.0.0.1:” while using a live server ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/what-is-localhost/</link>
                <guid isPermaLink="false">66adf277db5636c0b30cbaa2</guid>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ computer networking ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Computer Science ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Testing ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Kolade Chris ]]>
                </dc:creator>
                <pubDate>Wed, 29 Jun 2022 16:11:00 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1743780742807/3c1b7eab-e5bb-4b3c-aae9-6183d2cf3f72.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>If you are an experienced web developer, then you’ve likely seen the term “localhost” on many occasions.</p>
<p>And even if you’re a beginner and just getting started in web development, you might have seen the number “127.0.0.1:” while using a live server plugin.</p>
<p>You might be using it to test websites and web applications locally without knowing what exactly it is. Well, “127.0.0.1” is localhost and “localhost” is “127.0.0.1”.</p>
<p>In this article, you will learn what localhost is alongside its corresponding IP address, “127.0.0.1”.</p>
<h2 id="heading-what-is-localhost">What is Localhost?</h2>
<p>In computer networking, host means a “server”. Just like you can put a website on the internet by hosting it on a server, you can make your own computer that server. This connection is called <strong>loopback</strong>. The IP address for that loopback is <code>127.0.0.1</code>.</p>
<p>If you’ve put a website on the internet before, then you’ve dealt with hosting companies like Heroku, Hostinger, Netlify, and many others. These are what I refer to as “remote hosts” or virtual servers.</p>
<p>If you’ve served a website on your computer so you can test it without connecting to the internet, what you’re dealing with is a localhost.</p>
<p>So, by definition, <strong>localhost is the computer or hostname currently making a request to itself</strong>. In this case, the computer is also the virtual server.</p>
<h2 id="heading-what-is-the-ip-address-127001">What is the IP Address <code>127.0.0.1</code>?</h2>
<p>If you want to visit a website, you type the website address to your browser’s address bar, for example, <code>https://freecodecamp.org</code>.</p>
<p>The Domain Name Server (DNS) matches the address to a numeric IP address corresponding to that name. In the case of freeCodeCamp, this IP address is <code>104.26.2.33</code>. This is how it is done for every website you visit.</p>
<p>Localhost is not an exception to this. So, if you type <code>localhost</code> to your browser’s address bar, it transforms to the IP address <code>127.0.0.1</code>.</p>
<p>This <code>127.0.0.1</code> IP address is reserved for local servers on computers, so you will never find another IP address that starts with 127.</p>
<h3 id="heading-but-localhost-what-or-127001-what">But localhost: what? Or 127.0.0.1: what?</h3>
<p>Unlike <code>HTTP</code> and <code>HTTPS</code> which are protocols, <code>localhost</code> is a hostname. Remember that the website domain name is what follows the http or https, for example, <code>https://www.google.com/</code> and <code>https://www.freecodecamp.org/</code>. So, something has to follow <code>localhost:</code> and <code>127.0.0.1:</code>. That thing is the port number.</p>
<p>For example, in an Express app, that port number is the port variable you set. Something like this:</p>
<pre><code class="lang-js"><span class="hljs-keyword">const</span> port = <span class="hljs-number">4000</span>;
</code></pre>
<p>So if you type <code>localhost:4000</code> in the browser address bar and hit <code>ENTER</code>, the web application you’re currently making will be served to you:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/06/ss1-5.png" alt="ss1-5" width="600" height="400" loading="lazy"></p>
<p>Also, if you type <code>127.0.0.1:4000</code>, you will get the same response:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/06/ss2-5.png" alt="ss2-5" width="600" height="400" loading="lazy"></p>
<p>If you use the live server extension of VS Code, it uses a port <code>5500</code> attached to <code>127.0.0.1</code>, followed by the filename:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/06/ss3-6.png" alt="ss3-6" width="600" height="400" loading="lazy"></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>I hope this article has helped you learned more about localhost, what its IP address is, and how it works to serve websites for local testing.</p>
<p>And yes! There’s no place like localhost. Properly put, “there’s no place like <code>127.0.0.1</code>” :).</p>
<p>Keep coding…</p>
<p>Thanks to <a target="_blank" href="https://www.cytrowski.com/">Bartosz Cytrowski</a> for pointing out a key error regarding what localhost is. Your feedback improved the article!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ What is FTP? File Transfer Protocol and FTP Server Meaning ]]>
                </title>
                <description>
                    <![CDATA[ FTP stands for File Transfer Protocol. This is a network/communication protocol for transferring files between computers over a TCP/IP (Transmission Control Protocol/Internet Protocol) network.  Examples of TCP/IP networks are: HTTP (Hypertext Trans... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/what-is-ftp-file-transfer-protocol-and-ftp-server-meaning/</link>
                <guid isPermaLink="false">66b0a38cd7edba94d20b3bd9</guid>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Security ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Ihechikara Abba ]]>
                </dc:creator>
                <pubDate>Thu, 21 Apr 2022 01:01:16 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/04/thisisengineering-raeng-zBLtU0zbJcU-unsplash--1-.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>FTP stands for File Transfer Protocol. This is a network/communication protocol for transferring files between computers over a TCP/IP (Transmission Control Protocol/Internet Protocol) network. </p>
<p>Examples of TCP/IP networks are:</p>
<ul>
<li>HTTP (Hypertext Transfer Protocol).</li>
<li>HTTPS (Hypertext Transfer Protocol Secure).</li>
<li>FTP (File Transfer Protocol).</li>
</ul>
<h2 id="heading-how-does-file-transfer-protocol-work">How Does File Transfer Protocol Work?</h2>
<p>To transfer files between computers using FTP, you have to visit an FTP server (I'll explain what an FTP server is below).  </p>
<p>Depending on the type of server you visit, you may be required to enter a username and password in order to access the files in the server. Server connections that do not require any sort of authentication before accessing the files are referred to as anonymous FTP.</p>
<p>When the user has successfully visited/logged in to an FTP server, they can either download or upload files on the server.</p>
<p>There are two general ways of gaining access to an FTP server:</p>
<ul>
<li>Through a web browser. You can do this by typing the address of the server in your browser. This address could look this: ftp.myftpfiles.com or https://www.myftpfiles.com. Once you are on the server, you can then interact with files uploaded to the server by the owner.</li>
<li>Through an FTP client. We'll discuss FTP clients in the next section.</li>
</ul>
<h2 id="heading-what-is-an-ftp-client">What Is an FTP Client?</h2>
<p>An FTP client is software that creates a connection between the computer requesting access and the server where the files are stored.</p>
<p>There are numerous FTP client software available for use. They provide a graphical user interface (GUI) which we can interact with. </p>
<p>Below, we'll see what an FTP client looks like and how we can use it. We'll be making use of <a target="_blank" href="https://filezilla-project.org/">FileZilla</a>.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/04/Screenshot--270--1.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>In the image above, there are different text fields. The <code>Host</code> text field is where the address of the server is typed in. </p>
<p>The <code>Username</code> and <code>Password</code> text field are for servers that require authentication before granting access. </p>
<p>The <code>Port</code> text field is usually 21. This is a dedicated port for FTPs.</p>
<p>Once you've filled the necessary text fields, you can then click <code>Quickconnect</code> to connect to the server.</p>
<p>On the left side of the software is the <code>local site</code> which is my computer with a list of the existing directories. </p>
<p>On the right is the <code>Remote site</code> which is where all the information and files in a server will be shown.</p>
<h2 id="heading-what-is-an-ftp-server">What Is an FTP Server?</h2>
<p>An FTP server is basically the computer where all the files are uploaded initially. Every server has an FTP address which a user can visit over a TCP/IP through a browser or an FTP client. </p>
<p>The server allows the visitor to download and upload files.</p>
<h2 id="heading-are-ftp-servers-secure">Are FTP Servers Secure?</h2>
<p>Although a lot of FTP servers require authentication, they are not secure as the protocol lacks encryption. This makes it more likely that the files stored on an FTP server could be accessed by a third and unwanted party.</p>
<p>The most preferred and more secure protocol to FTP is the SFTP which stands for Secure File Transfer Protocol. Just like HTTP and HTTPS.</p>
<p>SFTP is more secure because the data stored on the server is encrypted. </p>
<p>Other alternatives include:</p>
<ul>
<li>FTPS (File Transfer Protocol Secure).</li>
<li>HTTPS (Hypertext Transfer Protocol Secure).</li>
<li>AS2 (Applicability Statement 2).</li>
</ul>
<h2 id="heading-advantages-of-using-ftp">Advantages of Using FTP</h2>
<p>Here are some of the advantages of using FTP:</p>
<ul>
<li>Faster transfer of files.</li>
<li>Supported by numerous hosts.</li>
<li>Supports transfer of large files.</li>
<li>Ability to schedule transfers.</li>
<li>Transfers can be resumed when interrupted.</li>
</ul>
<h2 id="heading-disadvantages-of-using-ftp">Disadvantages of Using FTP</h2>
<p>Here are some of the disadvantages of using FTP:</p>
<ul>
<li>FTP servers lack security.</li>
<li>Major browsers like Chrome and Firefox no longer support FTP.</li>
<li>User credentials and files are not encrypted.</li>
<li>Some servers may contain harmful files.</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>In this article, we talked about the File Transfer Protocol which enables us to transfer files between computers over a network.</p>
<p>We saw what an FTP client and FTP server are. We also talked about why FTP servers are insecure and other secure alternatives we can make use of.</p>
<p>Lastly, we saw the advantages and disadvantages of using FTP.</p>
<p>Thank you for reading!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Computer Networking Tutorial – How Network Applications Talk Over the Internet ]]>
                </title>
                <description>
                    <![CDATA[ By Sahil Gupta Network applications are computer applications that participate in a computer network. These applications talk to each other by plugging into the network.  For example, when you visit google.com, your browser acts as a network applicat... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/computer-networking-how-applications-talk-over-the-internet/</link>
                <guid isPermaLink="false">66d460c5264384a65d5a95d1</guid>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ computer networking ]]>
                    </category>
                
                    <category>
                        <![CDATA[ internet ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Tue, 18 Jan 2022 19:54:27 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2022/01/network-applications-article-image.jpeg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Sahil Gupta</p>
<p>Network applications are computer applications that participate in a computer network. These applications talk to each other by plugging into the network. </p>
<p>For example, when you visit google.com, your browser acts as a network application that leverages the <a target="_blank" href="https://en.wikipedia.org/wiki/Internet">Internet</a> to talk to the network application running on Google's computer. </p>
<p>Usually, the mechanics of this communication are abstracted away from an application developer.</p>
<p>On the surface, this communication might look like an <a target="_blank" href="https://en.wikipedia.org/wiki/Inter-process_communication">Inter-Process Communication</a> between <a target="_blank" href="https://en.wikipedia.org/wiki/Unix_domain_socket">two applications running on the same computer</a>. But, network communication has a different set of challenges. </p>
<p>For example, communication can take an eternity in computer time. It takes 0.1337 secs (2 <em> 3.14 </em> 6400 / 30000) for light to travel around earth. Assuming a modest CPU that runs at 1GHz, it can perform 10^9 ops in 1 sec. </p>
<p>Suppose it takes a few ops for processes (running on the same machine) to communicate, roughly 10^-7 - 10^-8 secs. That translates to ~1 million times slower communication times with a computer sitting on the other side of Earth!</p>
<p>This article will look at how network applications talk to each other, specifically over the Internet. For a high-level overview of the Internet, see <a target="_blank" href="https://blog.devgenius.io/how-does-the-internet-work-256891cdbb77">this article</a>.</p>
<h2 id="heading-introduction-to-computer-networks">Introduction to Computer Networks</h2>
<p>An additional complexity involved in network communication is the diversity of end systems out there (mobile phones, laptops, windows, mac). This complexity is managed by <a target="_blank" href="https://en.wikipedia.org/wiki/Abstraction_(computer_science)">abstracting</a> the differences and introducing a uniform set of rules called <a target="_blank" href="https://en.wikipedia.org/wiki/Communication_protocol"><strong>Protocols</strong></a>. </p>
<p>Protocols are the building blocks of communication between network applications. Some of the popular protocols include HTTP, TCP, IP, SMTP. Like how a human language (such as English) enables diverse people to communicate meaningfully, Protocols fill a similar gap in network communication.</p>
<p>Network communication is challenging due to the scale and uncertainty inherent in the network. </p>
<p>For example, links can be clogged, which results in the dropping of packets. One strategy to solve a complicated problem is to divide the problem into subproblems, solve the subproblems, and combine them to solve the original problem. </p>
<p><a target="_blank" href="https://en.wikipedia.org/wiki/Protocol_stack">The Protocol Stack</a> uses this idea to solve network communication.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/01/1-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>Protocol Stack</em></p>
<p>Imagine you are building a website to sell pizza. When the user interacts with your website, the frontend needs to communicate with your backend server. Wouldn't it be nice if you could focus on building your online pizza store without having to worry about how that data is passed from the frontend to the backend server over the Internet? </p>
<p>The protocol stack takes care of the network communication for us. An application (frontend) uses the Application Layer to communicate with another application (backend). </p>
<p>The application layer uses the "services" provided by the Transport Layer to transmit information across the network. Transport Layer also uses services provided by the Network Layer to fulfill its service agreement. </p>
<p>In this way, the higher layer uses the services provided by the lower layers to communicate with other applications over the network. The Physical Layer constitutes the wires which carry the electrical signal.</p>
<p>In essence, the protocol stack contains various layers, where each layer focuses on solving part of the bigger problem.</p>
<p>Protocols describe the solution to the sub-problems, which gives us the name protocol stack. Generally, protocols define the rules of communication between two entities such as,</p>
<ul>
<li>Types of messages, for example, request and response messages</li>
<li>Syntax of various message types such as fields in the messages</li>
<li>The semantics of fields, that is the meaning of information in fields</li>
<li>Rules for determining when and how messages are sent and responded to</li>
</ul>
<p>Let's dive deeper into the protocol stack, starting from the top.</p>
<h2 id="heading-the-application-layer">The Application Layer</h2>
<p>Business applications use the Application Layer to communicate over a network. For example, placing an order on your online pizza store is done using the Application Layer. <a target="_blank" href="https://en.wikipedia.org/wiki/POST_(HTTP)">HTTP</a> is one option to post the information on your backend server.</p>
<p>Application Layer Protocols define how applications running on different end systems pass messages to each other. In addition to the rules of communication (protocol), the applications also need a way to find each other, that is, to address each other. The address of an application is defined by:</p>
<ol>
<li><a target="_blank" href="https://en.wikipedia.org/wiki/IP_address">IP Address</a>: numerical label assigned to an end system</li>
<li><a target="_blank" href="https://en.wikipedia.org/wiki/Port_(computer_networking)">Port Number</a>: an identifier that specifies the receiving process in the destination host. Port numbers are essential to account for multiple network applications running on a host. For example, <a target="_blank" href="https://superuser.com/questions/1055281/do-web-browsers-use-different-outgoing-ports-for-different-tabs">two tabs in a web browser act as two different processes</a>.</li>
</ol>
<p>The address of an application defines its identity on the network, and the protocol defines the rules for communication. Together, these form the <a target="_blank" href="https://en.wikipedia.org/wiki/Network_socket">Socket</a> address (protocol type, IP address, port number). </p>
<p>A <strong>socket</strong> is an <a target="_blank" href="https://en.wikipedia.org/wiki/Interface_(computing)">interface</a> between the application layer and the transport layer. It acts as an entry point into the network, that is an application sends messages into and receives network messages through its Socket.</p>
<p>In summary, applications talk to each other using Application Layer protocols. The Application Layer relies on the services provided by the Transport Layer to pass data between end systems. Pair of IP address and port number identifies an application. The information flows from an application into the network through its Socket.</p>
<p>Let's look at an example of two applications communicating over the Internet using HTTP. </p>
<p>HTTP is a popular application layer protocol. The communication is between my web browser and an application server (<a target="_blank" href="http://ilovecookies.com/">ilovecookies.com</a>). When I enter this address in my web browser, it sends an HTTP request message to the application server.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/01/2-2.png" alt="Image" width="600" height="400" loading="lazy">
<em>HTTP request message sent by my web browser to ilovecookies.com server</em></p>
<p>A few things to notice about this request message:</p>
<ul>
<li>The type of request is GET</li>
<li>The host it sends the message to is ilovecookies.com (human-readable version of IP addresses called <a target="_blank" href="https://en.wikipedia.org/wiki/Hostname">hostnames</a>)</li>
<li>The source machine accepts specific response formats, languages, and so on.</li>
</ul>
<p>This structure is part of the <a target="_blank" href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#HTTP/1.1_request_messages">HTTP</a> that defines communication rules between two applications. When the host application receives this message, it responds with a response message.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/01/3-3.png" alt="Image" width="600" height="400" loading="lazy">
<em>HTTP response message received by my web browser from ilovecookies.com server that contains the HTML for generating the webpage</em></p>
<p>We can observe that the response message contains protocol-specific data such as status code (200), content type, and so on and the HTML data (truncated to fit). The request-response pair constitutes the network communication between two applications that successfully lays out the webpage (ilovecookies.com) on my screen.</p>
<h2 id="heading-the-transport-layer">The Transport Layer</h2>
<p>Next, let's go one level down the protocol stack and understand how the transport layer helps network communication.</p>
<p>The transport layer provides <a target="_blank" href="https://www.pcmag.com/encyclopedia/term/logical-vs-physical"><strong>logical</strong></a> communication between applications running on different hosts: from an applications' perspective, it's as if the two hosts are directly connected. Note that the communication provided by the transport layer is logical and not physical: there's no direct link or wire between the end hosts.</p>
<p>The transport layer converts the application messages into smaller chunks, encapsulates each piece in a transport message containing headers, and passes the chunk to the network layer.</p>
<p>The reason behind breaking down information into pieces is efficient network utilization. The Internet is so vast that several parallel paths transmit data between two end hosts. </p>
<p>For example, there are two possible paths to travel between New York and Stamford. The Internet is a slightly extreme version of this idea.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/01/4-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>Two alternative routes between New York and Stamford</em></p>
<p>The relative ordering of packets is a natural question around chunking and efficient network utilization: the chunks need to be put back in the same order at the receiving host. The transport layer in the receiving host is responsible for the stitching of pieces back in the proper order.</p>
<p>The transport layer also needs some additional data relevant to its functions. For example, relative sequence numbers are added to the chunks to stitch back the application message. </p>
<p>Another example of transport layer-specific information is the port number. On the receiving host, the destination port number is helpful to route the message to the correct application.</p>
<p>The Internet makes available two transport layer protocols:</p>
<ul>
<li>User Datagram Protocol (UDP)</li>
<li>Transmission Control Protocol (TCP)</li>
</ul>
<p>The two protocols vary slightly in the transport services they provide to the application layer.</p>
<table>
  <tbody><tr>
    <th>TCP</th>
    <th>UDP</th>
  </tr>
  <tr>
    <td>Reliable data transfer</td>
    <td>Unreliable data transfer</td>
  </tr>
  <tr>
    <td>Lost or corrupted information is recovered by retransmission</td>
    <td>No mechanisms to recover lost or corrupted data</td>
  </tr>
  <tr>
    <td>Higher latency at the cost of reliable communication</td>
    <td>Lower latency at the cost of unreliable communication</td>
  </tr>
</tbody></table>

<p>The service requirements of an application govern what protocol you choose. For example, a payment system will need reliable communication (TCP), whereas a video streaming service might be okay with losing some information for faster streaming (UDP).</p>
<p>In summary, the transport layer splits the application messages into chunks and encapsulates them in messages containing transport layer-specific information. The pieces are put back in the correct order on the receiving system to recreate the message and passed to the appropriate application using the port number.</p>
<p>Let's continue the HTTP example communication between my web browser and application server.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/01/5-2.png" alt="Image" width="600" height="400" loading="lazy">
<em>TCP packet encapsulating HTTP request message and headers</em></p>
<p>You can observe the decoded bytes in the bottom right representing the HTTP GET request my browser makes for the application server. We see the HTTP request as a TCP payload field in this packet. </p>
<p>In addition, the packet is first in relative ordering with a sequence number of 1. It also contains the port number (65012) associated with the tab on my web browser and the destination port number (<a target="_blank" href="https://en.wikipedia.org/wiki/Port_(computer_networking)#Common_port_numbers">80</a>) on the application server.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/08/sequence-1-and-1449.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>First (sequence number 1) and second (sequence number 1449 that starts at end of packet 1) TCP packets corresponding to HTTP response message received from ilovecookies.com server</em></p>
<p>The first two packets from the HTTP response (57 TCP packets)  are displayed here. In the bottom right of both images, we can see the HTTP-specific information and some HTML corresponding to the webpage ilovecookies.com. </p>
<p>You can also see the transport layer-specific information such as the port numbers and the sequence numbers. Notice that the source and destination port numbers are flipped compared to the request message packets.</p>
<h2 id="heading-the-network-layer">The Network Layer</h2>
<p>In contrast to the transport layer, the network layer provides logical communication between two end hosts. Note the subtle difference between the transport and network layer services.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/08/network-layer-hosts.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Left: logical communication provided by the transport layer, Right: logical communication provided by the network layer</em></p>
<p>The network layer takes a transport packet from the transport layer and encapsulates it in a network packet. The encapsulation is helpful to add information specific to the functioning of network layer protocol.</p>
<p>The network layer provides a <a target="_blank" href="https://en.wikipedia.org/wiki/Best-effort_delivery">best-effort service</a> (timing, relative ordering, eventual delivery are not guaranteed) to move data between two hosts. The best-effort service is the motivation behind TCP. As the network layer protocols are inherently unreliable, TCP contains additional logic to ensure reliable data transfer.</p>
<p>The network layer is responsible for moving packets from a sending host to a receiving host. In addition to the end hosts, the network layer protocols also run on <strong>Routers</strong>, part of the <a target="_blank" href="https://en.wikipedia.org/wiki/Backbone_network">network core</a>. Routers are packet switching devices that are responsible for forwarding packets.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2024/08/packet-switching-and-small-network.jpg" alt="Image" width="600" height="400" loading="lazy">
<em>Left: packet switching device, Right: a small network consisting of 3 end hosts and 1 router connecting them together</em></p>
<p>Suppose end host 1 wants to send a packet to end host 2. End host 1 passes the packet to the router. The router looks at the information in the network packet and figures out that it needs to forward the packet on link 2, to which end host 2 is connected. </p>
<p>Every router has a forwarding table stored in RAM (<a target="_blank" href="https://en.wikipedia.org/wiki/Routing_protocol">built dynamically</a>) to resolve the correct forwarding link for the packet. For example, the routing table for the above setup will look like this:</p>
<table>
  <tbody><tr>
    <th>Address</th>
    <th>Link</th>
  </tr>
  <tr>
    <td>192.168.1.1</td>
    <td>Link 1</td>
  </tr>
  <tr>
    <td>168.134.1.1</td>
    <td>Link 2</td>
  </tr>
  <tr>
    <td>172.158.1.2</td>
    <td>Link 3</td>
  </tr>
</tbody></table>

<p>Routers use the information (destination host address) from the network packet to index (<a target="_blank" href="https://en.wikipedia.org/wiki/Exclusive_or#Truth_table">bitwise XOR</a>) into this table. You can see the routing table on your computer by running the following commands:</p>
<p><code>Mac: netstat -nrf inet</code>
<code>Linux: netstat -nr</code>
<code>Windows: Get-NetRoute -AddressFamily IPv4</code></p>
<p>Notice a particular entry in your routing table, default or 0.0.0.0, called the <a target="_blank" href="https://en.wikipedia.org/wiki/Default_gateway">default gateway</a>. A packet is routed to the default gateway if none of the entries match the destination address.</p>
<p>The Internet contains tons of such devices which forward packets to enable logical communication between two end hosts. </p>
<p>As everyone shares the routers and wires carrying the data on the Internet, routers contain queues that hold incoming packets as outgoing packets are processed (/forwarded) by the router. Unreliability is introduced in the network layer protocols if the queues are full, which can get packed as the traffic increases.</p>
<p>The Internet network protocol is called Internet Protocol (IP). The major components of the Internet network layer are,</p>
<ol>
<li><a target="_blank" href="https://en.wikipedia.org/wiki/Internet_Protocol">IP</a>: defines addressing conventions (IPv4, IPv6), packet format, packet handling convention</li>
<li><a target="_blank" href="https://en.wikipedia.org/wiki/Routing_protocol">Routing protocols</a>: determine the path a packet takes from source to host</li>
<li><a target="_blank" href="https://en.wikipedia.org/wiki/Internet_Control_Message_Protocol">ICMP</a>: facility to report errors in packets and respond to requests for certain network layer information</li>
</ol>
<p>In summary, the network layer provides logical communication between two end hosts. Network layer protocols run on end hosts and network core devices such as routers. Routers forward network packets, which help form the logical communication between two end hosts.</p>
<p>Let's continue with our example of communication with ilovecookies.com. </p>
<p>We have seen that my web browser creates an HTTP request message (application layer protocol) and passes it down to the transport layer, which uses TCP protocol for end-to-end communication between my web browser application and a server application (ilovecookies.com).</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/01/12.png" alt="Image" width="600" height="400" loading="lazy">
<em>An IP packet encapsulates a TCP packet</em></p>
<p>We can see that the network packet encapsulates the TCP packet, which encapsulates the application packet. The green highlighted text represents the contents of the network packet, yellow the transport packet, and the remaining text starting at GET is the application packet. </p>
<p>The network packet fields are relevant to its functioning. For example, the source address is my machines' IP address, and the destination address is the ilovecookies.com <a target="_blank" href="https://mxtoolbox.com/SuperTool.aspx?action=a%3ailovecookies.com&amp;run=toolpage">server address</a>.</p>
<p>The encapsulation and the layer-specific information contained in the packets also relate to the idea of logical communication between hosts and applications running on them. </p>
<p>For instance, the network packet includes the IP addresses of the end machines, whereas the transport packet only contains the port numbers. The transport layer relies on the network layer to move data between the end machines. Once the data reaches the receiving device, the transport layer takes over and routes the packet to the correct application using the port numbers contained in the transport packet.</p>
<h2 id="heading-the-link-layer">The Link Layer</h2>
<p>Compared to the layers we have seen so far, the link layer has a narrower scope: it provides services to move packets over the individual links in the end-to-end path.</p>
<p>For example, links are the red dotted lines (see above illustrations). The link-layer enables the node-to-node movement of network layer packets over a single link in the path.</p>
<p>A link-layer protocol defines:</p>
<ul>
<li>format of packets exchanged between nodes at ends of the link</li>
<li>actions taken on packets by those nodes</li>
</ul>
<p><a target="_blank" href="https://en.wikipedia.org/wiki/Adapter_(computing)#Network_adapter">A network adapter</a> implements the link layer protocols. Network adapter constitutes the physical hardware that enables a computer to connect to a network and exchange information. </p>
<p>Try running this command to see the list of network adapters in your computer:</p>
<p><code>Mac: networksetup -listallhardwareports</code>
<code>Linux: lshw -class network -short</code>
<code>Windows: Get-NetAdapter -Name *</code></p>
<p>In the output, you will notice that each device has a link-layer address known as the MAC address. The adapters' <a target="_blank" href="https://en.wikipedia.org/wiki/Read-only_memory">ROM</a> contains MAC addresses assigned at the time of manufacture that are considered permanent. Each node (hosts and routers) has a link-layer address along the path.</p>
<p>Earlier we talked about IP address, which are also an identifier for the devices. The situation is similar to having multiple identifiers: home address and social security number. There are several reasons why nodes have MAC addresses and network-layer addresses.</p>
<ul>
<li>The protocols in different layers are supposed to be substitutable. For example, <a target="_blank" href="https://en.wikipedia.org/wiki/IPX/SPX">IPX</a> doesn't use a network layer address.</li>
<li>IP addresses are stored in RAM and <a target="_blank" href="https://en.wikipedia.org/wiki/IPX/SPX">reconfigured every time the adapter is moved or powered up</a>, that is, temporary.</li>
<li>Suppose the protocol omits MAC addresses. The adapter would need to pass each packet it receives up the protocol stack. The network layer would check for an IP address match. But, this can be inefficient if done too many times: <a target="_blank" href="https://en.wikipedia.org/wiki/Interrupt">Interrupts</a> help pass packets which can be <a target="_blank" href="https://en.wikipedia.org/wiki/Interrupt#Performance">expensive</a>.</li>
</ul>
<p>In summary, for the layers to be largely independent building blocks in network architecture, many layers need to have their addressing scheme. </p>
<p>As a quick recap, we have come across three types of address until now:</p>
<ul>
<li>Hostnames for the application layer (ilovecookies.com). These are converted into corresponding IP addresses using <a target="_blank" href="https://en.wikipedia.org/wiki/Domain_Name_System">DNS</a>.</li>
<li>The IP address for the network layer</li>
<li>MAC address for the link layer</li>
</ul>
<p>Like the Domain Name System, which helps resolve IP addresses from hostnames, Address Resolution Protocol (<a target="_blank" href="https://en.wikipedia.org/wiki/Address_Resolution_Protocol">ARP</a>) is useful for determining (destination) MAC addresses from an IP address. </p>
<p>ARP builds a table in RAM which contains a mapping of IP address to MAC address. The protocol includes specifications (such as <a target="_blank" href="https://en.wikipedia.org/wiki/Address_Resolution_Protocol#Packet_structure">a particular packet</a>) for creating this table automatically.</p>
<p>The network layer passes the packet and MAC address (from the ARP table) of the destination node to the link layer. The link-layer encapsulates the packet in a link-layer packet and moves it along the link to the destination node. </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/01/13-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>A network containing two hosts and one router</em></p>
<p>Suppose in the above setup the host 222.222.222.220 wants to send a packet to the other host 222.222.222.222. The network layer uses ARP to resolve the corresponding MAC address as 49-BD-D2-C7-56-A2 and passes the packet and MAC address to the link layer. The link layer moves the packet over the link between the two hosts.</p>
<p>Next, consider a more complex scenario where a host wants to send a packet to another host on a different network. For example, a packet from my computer to ilovecookies.com travels from my <a target="_blank" href="https://en.wikipedia.org/wiki/Home_network#Infrastructure_devices">home network</a> to another network.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/01/14-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>A router connecting two subnets. The router contains two adapters for linking and two IP addresses, identifying it on each subnet</em></p>
<p>There are two things to notice about this picture. First, the router has two IP addresses. As the router participates in two different networks, it requires two IP addresses to identify it in the respective network. For more details, see <a target="_blank" href="https://askleo.com/your-routers-two-ip-addresses/">this</a>.</p>
<p>Second, the two separate networks are known as <a target="_blank" href="https://en.wikipedia.org/wiki/Subnetwork">subnets</a>. A subnet is a logical grouping of network devices that makes network device management more accessible.</p>
<p>Suppose in this setup the host 222.222.222.222 wants to send a packet to the host 111.111.111.111, which involves making a cross-network trip. It will not locate the destination host (111.111.111.111) in its subnet, and it forwards the packet to the default gateway (router). </p>
<p>The network layer uses the ARP table to resolve the MAC address as 88-B2-2F-54-1A-0F. The router uses its routing table to deliver the packet to the link connecting to the other subnet. Once again, the ARP table helps resolve the MAC address of the destination host, and the packet moves along the link.</p>
<p>In summary, the adapter part of your computer hardware implements the link layer protocols. The link-layer protocol defines an addressing scheme called MAC addresses, and the ARP is used to map IP addresses to MAC addresses. The link-layer encapsulates network layer packets and moves them over a link.</p>
<p>One of the popular link layer protocols is <a target="_blank" href="https://en.wikipedia.org/wiki/Ethernet">Ethernet</a>. Let's continue our example (ilovecookies.com) to examine the Ethernet protocol in action.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/01/15-1.png" alt="Image" width="600" height="400" loading="lazy">
<em>An Ethernet packet encapsulating an IP packet</em></p>
<p>We can observe the Ethernet packet contains destination and source MAC addresses (omitted), and it encapsulates the IP packet.</p>
<h2 id="heading-recap">Recap</h2>
<p>Let's summarize what we saw in this article using the picture below.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2022/01/16.png" alt="Image" width="600" height="400" loading="lazy">
<em>End to end network communication between host A and host B</em></p>
<p>Computer applications running on two different systems (called hosts) communicate using protocols. </p>
<p>Protocols are rules which govern the communication between two hosts. The protocol stack solves multiple sub-problems to solve the problem of network communication. Each layer focuses on solving a sub-problem using the services offered by the lower layers in the abstraction hierarchy.</p>
<p>The application layer protocols work at the highest level of abstraction. An application communicates by sending messages that adhere to the rules of an application protocol (for example HTTP). </p>
<p>DNS is used to map hostname (www.ilovecookies.com) to an IP address. These messages are pushed through the socket interface to be transmitted over the network using the transport layer.</p>
<p>The transport layer exposes a logical communication between two applications running on different hosts. It breaks down application messages into smaller pieces and encapsulates them in packets containing extra information (<a target="_blank" href="https://en.wikipedia.org/wiki/Header_(computing)">headers</a>).</p>
<p>The application message is created from these packets and pushed through the socket interface using the port number on the packet. These packets are sent over the network by relying on the network layer.</p>
<p>Next, the network layer takes over, providing logical communication between two hosts. It also encapsulates the transport packet in a network packet. </p>
<p>The Internet contains packet switching devices that forward network packets, using routing tables stored in RAM and built dynamically using routing protocols. The network layer relies on the link layer to move packets.</p>
<p>Link-layer is responsible for moving packets over individual links. Hardware devices, called adapters, implement link-layer protocols and have a permanent address associated with them, called MAC address. MAC address serves as the identifier for this layer. The Address Resolution Protocol (ARP) maps IP addresses to MAC addresses.</p>
<p>Finally, the link layer passes packets to the physical layer, which constitutes the wires over which the information travels.</p>
<p>Thank you for reading! I hope you learned something new about computer networks today.</p>
<h3 id="heading-sources">Sources</h3>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.pearson.com/us/higher-education/program/Kurose-Computer-Networking-A-Top-Down-Approach-7th-Edition/PGM1101673.html">https://www.pearson.com/us/higher-education/program/Kurose-Computer-Networking-A-Top-Down-Approach-7th-Edition/PGM1101673.html</a></div>
<div class="embed-wrapper"><div class="embed-loading"><div class="loadingRow"></div><div class="loadingRow"></div></div><a class="embed-card" href="https://www.wireshark.org/">https://www.wireshark.org/</a></div>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ IPV4 vs IPV6 – What is the Difference Between IP Addressing Schemes? ]]>
                </title>
                <description>
                    <![CDATA[ The Internet is one of our greatest inventions. Millions of people use the Internet every second of the day, and it has changed many aspects of our lives – from creating new jobs and a new way of working to influencing how news is consumed and how de... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/ipv4-vs-ipv6-what-is-the-difference-between-ip-addressing-schemes/</link>
                <guid isPermaLink="false">66b1e44596a9e0a75592bbc6</guid>
                
                    <category>
                        <![CDATA[ computer network ]]>
                    </category>
                
                    <category>
                        <![CDATA[ computer networking ]]>
                    </category>
                
                    <category>
                        <![CDATA[ internet ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ipv6 ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Dionysia Lemonaki ]]>
                </dc:creator>
                <pubDate>Fri, 15 Oct 2021 16:30:13 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2021/10/nasa-1lfI7wkGWZ4-unsplash.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>The Internet is one of our greatest inventions.</p>
<p>Millions of people use the Internet every second of the day, and it has changed many aspects of our lives – from creating new jobs and a new way of working to influencing how news is consumed and how decisions are made.</p>
<p>Although it's been around for quite a while now, the underlying technologies that power it have not changed that much since its invention.</p>
<p>In this article you'll learn about the Internet Protocol, or IP - what it is, how it works, and the differences between its different versions. </p>
<h2 id="heading-how-computers-communicate-over-the-internet">How computers communicate over the Internet</h2>
<p>Computers, and devices in general, connect and communicate with one another on the Internet in a couple different ways: either with the help of a large number of undersea cables or wirelessly.</p>
<p>Information gets broken down into packets, or smaller pieces of data, that get transferred by routers to the correct destination and back.</p>
<p>However, for computers to communicate in the first place, there needs to be a set and universally agreed upon common language of communication that all devices understand.</p>
<p>This need for a standardized method of communication during data exchange led to the creation of protocols.</p>
<p>One of the key protocols is the <em>Internet Protocol</em>, or IP.</p>
<p>The Internet Protocol has a particular syntax that defines a set of rules and a specified format for how communication will take place between devices over various networks. It essentially makes communication between computers possible.</p>
<p>Those rules cover a large number of things, like:</p>
<ul>
<li>identifying and locating each device on a network</li>
<li>having devices then talk to each other</li>
<li>dictating how the format and transfer of packets of data will look like</li>
<li>determining how each packet will reach the desired destination</li>
<li>choosing the fastest and most efficient path possible for the router to take, and</li>
<li>deciding how to handle errors when they occur.</li>
</ul>
<p>Each and every device connected to a network needs a way to identify itself across various networks.</p>
<p>When you want to send a letter to someone, you need a way of identifying that person's home so the postal service knows where to deliver the letter. You don't want the letter to be delivered to the wrong person! </p>
<p>This is why, when sending a letter, you include the recipient's unique home address as the destination address and also your unique home address, which is the return address. </p>
<p>Each house has a unique address that sets it apart and identifies it.</p>
<p>Similarly, the way to identify computers and devices on the Internet so we can transmit and exchange data, is by knowing their IP address. </p>
<p>To send an e-mail to someone, you need to know their computer's IP address. The e-mail gets broken down into smaller chunks, or packets. The way they  reach the correct destination is because each packet also includes IP information. </p>
<p>When sending something over the Internet there needs to be a destination address and a return address on each packet. IP addresses are how computers find one another and know their respective locations.</p>
<p>The Internet Protocol is in charge of defining the format of IP addressing.</p>
<h2 id="heading-what-is-an-ip-address">What is an IP address?</h2>
<p>An IP address is a network address, and every device that connects to a computer network gets one.</p>
<p>An IP address is a unique sequence of numbers assigned to a device that's written in a certain format. It globally identifies every device in the interconnected network.</p>
<p>As mentioned earlier, packets get routed to the correct and intended destination and devices are able to send and receive information over the Internet because each device is assigned a unique IP address.</p>
<p>You'll likely not ever have to deal directly with IP addresses or know any by heart in order to send information over the Internet - it's all happening behind the scenes.</p>
<p>If you're curious and want to know your IP address, head to Google.com and type in "What's my IP" and you'll see your unique address in the first result.</p>
<p>That being said, there are are few different types of IP addresses, which you'll see in the following sections.</p>
<h3 id="heading-private-vs-public-ip-addresses">Private vs Public IP addresses</h3>
<p>Everyone has two kinds of IP addresses: public and private.</p>
<p>The public one is given to your home router by your Internet Service Provider (ISP) and it's the primary address for your whole local network.</p>
<p>In your home you may have more than one laptop, smartphone, or tablet. Each device has its own IP address, but they are all also under the same main, public IP address. </p>
<p>This is how all devices in your home get connected to the Internet – via the main public IP address. </p>
<p>A public IP address is unique, meaning there are no two identical IP addresses used at a given moment.</p>
<p>As mentioned above, if you have many devices in your home, then each has its own IP address. This address is a private IP address, and it cannot access the Internet directly.</p>
<p>As these devices connect to the Internet via the router (which has a public IP address), the router needs a way to identify and recognise each device separately, before it connects it to the Internet.</p>
<p>The way the router does this is by assigning an individual private IP address to each device. Then it remembers that address each time the device wants to get connected to the Internet.</p>
<h3 id="heading-dynamic-vs-static-ip-addresses">Dynamic VS Static IP Addresses</h3>
<p>Public IP addresses are split into two categories: dynamic and static.</p>
<p>Once a device gets connected to the Internet, your Internet Service Provider gives you one of their available IP addreses for the duration of the time you stay connected. This is how the device will be able to send and receive data.</p>
<p>The next time you connect to the Internet, your ISP will provide you with a <em>different</em> IP address. This means that each time you connect to the Internet, you have a different IP address. This is why this type of IP address is called dynamic - it's ever changing.</p>
<p>On the other hand, a static IP address never changes. It's a permanent address. The address is provided once and you can expect it to stay the same.</p>
<p>Static IP addresses are often used by DNS Servers. A DNS server is a large computer that stores files that make up a website. Their job is to send those files each time they are requested by a user who wants to view the website.</p>
<h2 id="heading-ipv4-vs-ipv6-whats-the-difference">IPv4 vs IPv6 – What's the Difference?</h2>
<h3 id="heading-what-is-an-ipv4-address">What is an IPv4 address?</h3>
<p>IPv4 is the first, and most widely used, version of the Internet Protocol.</p>
<p>It was first launched in  1980 and is used to this day.</p>
<p>It's a 32-bit address and it's made up of 4 blocks – with each block being separated by a dot. </p>
<p>It looks something like this:</p>
<pre><code>XXX.XXX.XXX.XXX
</code></pre><p>Each block can fit up to 3 digits, and the numbers in the block range from 0 to 255, in <em>decimal</em> values.</p>
<p>An example of an IP address is:</p>
<pre><code><span class="hljs-number">142.250</span><span class="hljs-number">.185</span><span class="hljs-number">.206</span>
</code></pre><p>Here's another example:</p>
<pre><code><span class="hljs-number">69.171</span><span class="hljs-number">.250</span><span class="hljs-number">.35</span>
</code></pre><p>These decimal numbers are converted to binary, a machine language, which is the only language computers can directly understand. </p>
<p>These decimal numbers, in binary, are actually 4 blocks of 8 binary digits (or bits).</p>
<p>This is why it is called a 32-bit address – it's an address made up of a sequence of 32 binary digits. </p>
<p>For example, the address you saw earlier,<code>142.250.185.206</code> is:</p>
<pre><code><span class="hljs-number">10001110.11111010</span><span class="hljs-number">.10111001</span><span class="hljs-number">.11001110</span>
</code></pre><p>in binary, under the hood.</p>
<p>So, <code>2^32</code> is a total of 4,294,967,296 unique addresses. That is the limit  of IP addresses IPv4 can provide for each device to connect to the Internet.</p>
<p>You would think that this large number is more than enough. But, as the population continues to grow and each person owns more and more devices (and each device needs its own IP address) we have been running out of addresses for quite some time now.</p>
<h3 id="heading-what-is-ipv6">What is IPv6?</h3>
<p>IPv6 is the latest version of the Internet Protocol which was first deployed in 1998.</p>
<p>It's the successor of IPv4 and there will be a slow shift towards it in the future.</p>
<p>Whereas IPv4 is a numeric address, IPv6 uses hexadecimal, alphanumeric characters - meaning it contains numbers <em>and</em> letters.</p>
<p>In the way IPv4 uses 4 blocks that each contain up to 3 digits, IPv6 uses 8 blocks that contain 4 hexadecimal characters each.</p>
<p>In IPv4, each block is separated by a do t(<code>.</code>). In IPv6 each block is separated by a colon (<code>:</code>).</p>
<p>So, an IPv6 address looks something like this:</p>
<pre><code>XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX
</code></pre><p>For example:</p>
<pre><code><span class="hljs-number">2001</span>:<span class="hljs-number">0</span>db8:<span class="hljs-number">85</span>a3:<span class="hljs-number">0000</span>:<span class="hljs-number">0000</span>:<span class="hljs-number">8</span>a2e:<span class="hljs-number">0370</span>:<span class="hljs-number">7334</span>
</code></pre><p>It's a 128-bit address, meaning that there are <code>2^128</code> addresses available.</p>
<p>That means there are 340,282,366,920,938,463,463,374,607,431,768,211,456 addresses we can use on the Internet. </p>
<p>That is 340 <em>undecillion</em> addresses, which we hope will be more than enough for everyone!</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>And there you have it! You now know the basics of the Internet Protocol. It's the underlying technology all computers and devices use to be able to connect with one another and receive and exchange information.</p>
<p>You also learned the basic differences between IPv4 and IPv6. And in a nutshell, IPv6 provides far more IP addresses than IPv4 does.</p>
<p>If you are interested in learning more about how the Internet works, check out this <a target="_blank" href="https://www.youtube.com/watch?v=zN8YNNHcaZc&amp;t=1s">video on freeCodeCamp's YouTube channel</a> that explains the fundamentals of computer networking.</p>
<p>Thanks for reading and happy learning 😊</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
