<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Atakan Demircioğlu</title>
    <description>The latest articles on DEV Community by Atakan Demircioğlu (@atakde).</description>
    <link>https://dev.to/atakde</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F818551%2Fd42a739c-2c91-416f-988f-85180e27ed05.jpeg</url>
      <title>DEV Community: Atakan Demircioğlu</title>
      <link>https://dev.to/atakde</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/atakde"/>
    <language>en</language>
    <item>
      <title>Twitter snowflake approach is cool</title>
      <dc:creator>Atakan Demircioğlu</dc:creator>
      <pubDate>Sun, 25 Dec 2022 12:55:32 +0000</pubDate>
      <link>https://dev.to/atakde/twitter-snowflake-approach-is-cool-16n3</link>
      <guid>https://dev.to/atakde/twitter-snowflake-approach-is-cool-16n3</guid>
      <description>&lt;h1&gt;
  
  
  Twitter snowflake approach is cool
&lt;/h1&gt;

&lt;p&gt;I was researching a solution to generate unique IDs and I liked the Twitter snowflake approach. These are my notes about this approach.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Twitter’s snowflake approach?
&lt;/h2&gt;

&lt;p&gt;It is a solution to generate unique IDs in distributed systems. Twitter uses this approach in Tweets, DM’s, Lists and etc.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  IDs are unique and sortable&lt;/li&gt;
&lt;li&gt;  IDs include time. (ordered by date)&lt;/li&gt;
&lt;li&gt;  IDs fit 64-bit unsigned integers.&lt;/li&gt;
&lt;li&gt;  Only numerical values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Sign bit (1 bit):&lt;/strong&gt; Reserved bit (It is always 0). This can be reserver for future requests. It can be potentially used to make the overall number positive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Timestamp(41 bit):&lt;/strong&gt; Epoch timestamp in a millisecond (Snowflake’s default epoch is equal to Nov 04, 2010, 01:42:54 UTC)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Machine ID(10-bit):&lt;/strong&gt; accommodates 1024 machines&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sequence number(12-bit):&lt;/strong&gt; It is a local counter per each machine and increments by 1. The number reset to 0 in every millisecond. Theoretically, a machine can support a max of 4096 (2¹²) new IDs per second.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advantages &amp;amp; Disadvantages of the Twitter Snowflake Approach
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  It is 64-bit long, it is half the size of UUIDs&lt;/li&gt;
&lt;li&gt;  Scalable (it can accommodate 1024 machines)&lt;/li&gt;
&lt;li&gt;  Highly available (Each machine can generate 4096 unique IDs each millisecond)&lt;/li&gt;
&lt;li&gt;  Some of the UUID versions do not include a timestamp. In this case, Twitter Snowflake has a sortable advantage.&lt;/li&gt;
&lt;li&gt;  Design requires Zookeeper (disadvantage)&lt;/li&gt;
&lt;li&gt;  The generated IDs are not random like UUIDs. Future IDs can predictable.&lt;/li&gt;
&lt;li&gt;  The maximum timestamp that can be represented in 41 bits is (~ 69 years). Need a solution after this :)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Usage Notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  Discord uses snowflakes, with their epoch set to the first second of the year 2015.&lt;/li&gt;
&lt;li&gt;  Instagram uses a modified version of the format, with 41 bits for a timestamp, 13 bits for a shard ID, and 10 bits for a sequence number.&lt;/li&gt;
&lt;li&gt;  Mastodon’s modified format has 48 bits for a millisecond-level timestamp, it uses the UNIX epoch. The remaining 16 bits are for sequence data.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://en.wikipedia.org/wiki/Snowflake_ID#cite_note-8" rel="noopener noreferrer"&gt;https://en.wikipedia.org/wiki/Snowflake_ID#cite_note-8&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://dev.to/double-pointer/system-design-interview-scalable-unique-id-generator-twitter-snowflake-or-a-similar-service-18af22d74343"&gt;https://medium.com/double-pointer/system-design-interview-scalable-unique-id-generator-twitter-snowflake-or-a-similar-service-18af22d74343&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;  &lt;a href="https://blog.devgenius.io/7-famous-approaches-to-generate-distributed-id-with-comparison-table-af89afe4601f" rel="noopener noreferrer"&gt;https://blog.devgenius.io/7-famous-approaches-to-generate-distributed-id-with-comparison-table-af89afe4601f&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Medium To Markdown Converter</title>
      <dc:creator>Atakan Demircioğlu</dc:creator>
      <pubDate>Sun, 03 Jul 2022 15:24:40 +0000</pubDate>
      <link>https://dev.to/atakde/medium-to-markdown-converter-2jdn</link>
      <guid>https://dev.to/atakde/medium-to-markdown-converter-2jdn</guid>
      <description>&lt;p&gt;I create a basic nodejs application for converting medium posts to markdown. This provides an easy way to publish my articles with different platforms like dev.to.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Git:&lt;/strong&gt; &lt;a href="https://github.com/atakde/nodejs-medium-to-markdown"&gt;https://github.com/atakde/nodejs-medium-to-markdown&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Url:&lt;/strong&gt; &lt;a href="https://nodejs-medium-to-markdown.vercel.app/"&gt;https://nodejs-medium-to-markdown.vercel.app/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nodej</category>
      <category>markdown</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>package.json &amp; package.lock.json Explained</title>
      <dc:creator>Atakan Demircioğlu</dc:creator>
      <pubDate>Mon, 27 Jun 2022 19:38:37 +0000</pubDate>
      <link>https://dev.to/atakde/packagejson-packagelockjson-explained-1j08</link>
      <guid>https://dev.to/atakde/packagejson-packagelockjson-explained-1j08</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U4DT01iQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/1%2AeS_S4iOGJS_frF4d6n8L6w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U4DT01iQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://miro.medium.com/max/1400/1%2AeS_S4iOGJS_frF4d6n8L6w.png" alt="package.json" width="800" height="311"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The first question is “Should I commit package-lock.json files?”.&lt;/p&gt;

&lt;p&gt;Let us talk about this and then answer this question.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is package.json?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Basically, we can say that is the heart of any node project. This file stores the metadata about the project and manages the project’s dependencies, version, scripts, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is package-lock.json?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you install some packages this file is created automatically. It stores the exact versioned dependency tree and this guarantees the dependencies for other developers. Actually, it is a very important feature of npm but some people don’t understand this.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What about semantic versioning?&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"dependencies": {
"my_dep": "^1.0.0",
"another_dep": "~2.2.0"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Patch releases: &lt;code&gt;1.0&lt;/code&gt; or &lt;code&gt;1.0.x&lt;/code&gt; or &lt;code&gt;~1.0.4&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Minor releases: &lt;code&gt;1&lt;/code&gt; or &lt;code&gt;1.x&lt;/code&gt; or &lt;code&gt;^1.0.4&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Major releases: &lt;code&gt;*&lt;/code&gt; or &lt;code&gt;x&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;What’s the difference between tilde(~) and caret(^)?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In our first example, you can see we started with the ^ symbol and this means something different.&lt;/p&gt;

&lt;p&gt;This &lt;strong&gt;caret(^)&lt;/strong&gt; symbol basically says, the program can upgrade the patch releases and also minor releases but it can’t get the major releases.&lt;/p&gt;

&lt;p&gt;If my_dep has new patch releases and minor releases when we run npm install it will automatically upgrade to the last version. But it will not upgrade to major releases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;tilde(~)&lt;/strong&gt; means the program can upgrade for patch releases but it will not upgrade to minor or major releases.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the npm ci command?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you use &lt;strong&gt;tilde(~) or a caret(^)&lt;/strong&gt; in your dependencies, if you run the npm install command it will automatically override your package-lock.json. If you just want to use exact dependencies without upgrading them, you can easily run this command. And basically, that’s why you need to commit the package-lock.json file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Resources&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;a href="https://docs.npmjs.com/about-semantic-versioning"&gt;https://docs.npmjs.com/about-semantic-versioning&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;This article orginally published at &lt;a href="https://medium.com/@atakde/package-json-package-lock-json-explained-2f9342a50e69"&gt;medium&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>npm</category>
      <category>webdev</category>
      <category>programming</category>
      <category>node</category>
    </item>
    <item>
      <title>Avatar Design With Notification Dot</title>
      <dc:creator>Atakan Demircioğlu</dc:creator>
      <pubDate>Thu, 23 Jun 2022 20:45:20 +0000</pubDate>
      <link>https://dev.to/atakde/avatar-design-with-notification-dot-2gpk</link>
      <guid>https://dev.to/atakde/avatar-design-with-notification-dot-2gpk</guid>
      <description>&lt;p&gt;Avatar Desing With Notification&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/atakde/embed/ExQXJRX?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Feel free to share your feedbacks with me :)&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>webdev</category>
      <category>css</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Fetching Medium Posts And Showing In GitHub Profile</title>
      <dc:creator>Atakan Demircioğlu</dc:creator>
      <pubDate>Sun, 19 Jun 2022 11:11:47 +0000</pubDate>
      <link>https://dev.to/atakde/fetching-medium-posts-and-showing-in-github-profile-1ccb</link>
      <guid>https://dev.to/atakde/fetching-medium-posts-and-showing-in-github-profile-1ccb</guid>
      <description>&lt;p&gt;I created a nodeJS app that fetches medium posts from medium rss and converts to svg, json or html.&lt;/p&gt;

&lt;p&gt;With svg version you can easily add to your github profile.&lt;/p&gt;

&lt;p&gt;For adding GitHub profile just add this to your README.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;![Alt text here](https://nodejs-medium-fetcher.vercel.app/?username=atakde&amp;amp;limit=5&amp;amp;responseType=svg)(https://medium.com/@atakde)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Do not forget to replace username.&lt;/p&gt;

&lt;p&gt;For other usage you can get response in json type with replacing &amp;amp;responseType=svg part with &amp;amp;responseType=json.&lt;/p&gt;

&lt;p&gt;For detailed information you can check git repository.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Git:&lt;/strong&gt; &lt;a href="https://github.com/atakde/nodejs-medium-fetcher"&gt;https://github.com/atakde/nodejs-medium-fetcher&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>node</category>
      <category>github</category>
    </item>
    <item>
      <title>HTML &amp; CSS &amp; Pure Javascript Carousel</title>
      <dc:creator>Atakan Demircioğlu</dc:creator>
      <pubDate>Sat, 18 Jun 2022 14:07:11 +0000</pubDate>
      <link>https://dev.to/atakde/html-css-pure-javascript-carousel-13ch</link>
      <guid>https://dev.to/atakde/html-css-pure-javascript-carousel-13ch</guid>
      <description>&lt;p&gt;&lt;strong&gt;Animated carousel with pure javascript&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/atakde/embed/poaZpeJ?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;Feel free to write your suggestions and comments :)&lt;/p&gt;

</description>
      <category>codepen</category>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Interface And Abstract Class</title>
      <dc:creator>Atakan Demircioğlu</dc:creator>
      <pubDate>Sat, 18 Jun 2022 13:38:05 +0000</pubDate>
      <link>https://dev.to/atakde/interface-and-abstract-class-42c2</link>
      <guid>https://dev.to/atakde/interface-and-abstract-class-42c2</guid>
      <description>&lt;p&gt;My notes about interfaces and abstract classes with PHP examples.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is an interface?
&lt;/h2&gt;

&lt;p&gt;In very basic words, it is a contact or signature. Any class that implements an interface must be expected to have the same behavior. That means if you define a method contact that takes two params and returns a string, the class that implemented this interface must take the same behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let us discuss with an example;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

interface FlyingCreature
{
    public function fly();
}

interface FeatheredCreature
{
    public function molt();
}

interface SwimmingCreature
{
    public function swim();
}

class Eagle implements FeatheredCreature, FlyingCreature
{
    public function fly()
    {
        // ...
    }

    public function molt()
    {
        // ...
    }
}

class Penguin implements FeatheredCreature, SwimmingCreature
{
    public function molt()
    {
        // ...
    }

    public function swim()
    {
        // ...
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Firstly it is a good example of the interface segregation principle (ISP) and we can discuss this principle in another article.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the example, you can see we use interface keywords to define an interface.&lt;/li&gt;
&lt;li&gt;All methods must be public in an interface&lt;/li&gt;
&lt;li&gt;For implementing an interface you need to use the implements keyword.&lt;/li&gt;
&lt;li&gt;In PHP and in many programming languages you can just extend one class. For interfaces, you can implement &lt;strong&gt;more than one interface&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;An interface can extend another interface with extends keywords.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is Concrete Class?
&lt;/h2&gt;

&lt;p&gt;A concrete class is a class that we can create an instance of, using the new keyword.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are the advantages of using Interfaces?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The ability to define behavior that can be implemented by a group of unrelated classes without forcing them to share a common class hierarchy&lt;/li&gt;
&lt;li&gt;As a class is not limited to the number of interfaces that it can implement, it can therefore participate in a wide variety of roles&lt;/li&gt;
&lt;li&gt;You can modify existing systems to provide new functionality within their current class hierarchy&lt;/li&gt;
&lt;li&gt;The class hierarchy can be simplified when developing with interfaces, which typically reduces overloading&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is Abstract Class?
&lt;/h2&gt;

&lt;p&gt;It basically defines an interface for other classes to extend but has some differences.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You should add abstract keywords for defining an abstract class&lt;/li&gt;
&lt;li&gt;An abstract class can have props and methods like a regular class.&lt;/li&gt;
&lt;li&gt;Abstract class can't be instantiated.&lt;/li&gt;
&lt;li&gt;If a class contains at least one abstract method, it must be an abstract class.&lt;/li&gt;
&lt;li&gt;A class that extends an abstract class must implement all abstract methods, not regular methods. This part is different from an interface.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is a basic example of usage;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;?php

abstract class Debugger
{
    abstract public function debug($message);
}

class BrowserDebugger extends Debugger
{
    public function debug($message)
    {
        echo "&amp;lt;pre&amp;gt;";
        print_r($message);
        echo "&amp;lt;/pre&amp;gt;";
    }
}

class CLIDebugger extends Debugger
{
    public function debug($message)
    {
        print_r($message);
    }
}

$debugger = new CLIDebugger();
$debugger-&amp;gt;debug(array('foo' =&amp;gt; 'bar'));

$debugger = new BrowserDebugger();
$debugger-&amp;gt;debug(array('foo' =&amp;gt; 'bar'));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Differences with Abstract Class and Interface&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One class can extends just one abstract class but more than one interface.&lt;/li&gt;
&lt;li&gt;In abstract classes, you can define filled methods but in the interface is not possible.&lt;/li&gt;
&lt;li&gt;The interface supports multiple inheritances but abstract classes do not support them.&lt;/li&gt;
&lt;li&gt;In interfaces, all methods must be public but in abstract class is not a must.&lt;/li&gt;
&lt;li&gt;Abstract classes can have a constructor but interfaces can't.&lt;/li&gt;
&lt;li&gt;In interfaces, you can't define static methods.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This article orginally published in &lt;a href="https://medium.com/@atakde/interface-and-abstract-class-6f5cae27fa07"&gt;medium&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>php</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Network Notes — OSI Model</title>
      <dc:creator>Atakan Demircioğlu</dc:creator>
      <pubDate>Sun, 12 Jun 2022 14:58:06 +0000</pubDate>
      <link>https://dev.to/atakde/network-notes-osi-model-pmh</link>
      <guid>https://dev.to/atakde/network-notes-osi-model-pmh</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T-Z3f6bT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wnwm40vq19uto8ov6c7z.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T-Z3f6bT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wnwm40vq19uto8ov6c7z.jpeg" alt="OSI Model" width="700" height="501"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is OSI Model?
&lt;/h2&gt;

&lt;p&gt;The Open Systems Interconnection model basically provides a standard for the communication of different computers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why do we need a communication model?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;The application must have a knowledge of the underlying network medium.&lt;/li&gt;
&lt;li&gt;The application does not matter about is a fiber or a radio signal and etc.&lt;/li&gt;
&lt;li&gt;If we don’t have a standard, you always need to upgrade your network equipment.&lt;/li&gt;
&lt;li&gt;The model provides a decoupled innovation and this means you are free to make any innovation without affecting the rest of the model.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What are layers in OSI Model?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Layer 1: Physical Layer&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each frame becomes a string of bits. (wifi, ethernet, fiber)&lt;/li&gt;
&lt;li&gt;It is the hardware part of the OSI model&lt;/li&gt;
&lt;li&gt;Hub, cables, and ethernet work in this layer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Layer 2: Data Link Layer&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It consist of two main parts. (LLC, MAC)&lt;/li&gt;
&lt;li&gt;LLC (Logical Link Control) and MAC (Media Access Control) basically responsible for the control of whether the sent data is transmitted without error.&lt;/li&gt;
&lt;li&gt;Data is sent from the network layer to the physical layer. In this stage, the data is divided into certain parts, which we call frames. Basically frames are packets that allow sending data within a certain control.&lt;/li&gt;
&lt;li&gt;Data Frame has 3 main parts (Data, Header, Trailer)&lt;/li&gt;
&lt;li&gt;This parts includes CRC, data and there are constructs such as special sign bits that indicate the start and end&lt;/li&gt;
&lt;li&gt;Most operations take place inside the network card.&lt;/li&gt;
&lt;li&gt;LLC provides the connection with Layer 3 and Layer 2.&lt;/li&gt;
&lt;li&gt;LCC is responsible from Flow Control
*Adds the MAC address of the destination and source devices to data frame&lt;/li&gt;
&lt;li&gt;Switch work at this layer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Layer 3: Network Layer&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Information is added to the data packet when it needs to be sent to a different network and that the routers will use.&lt;/li&gt;
&lt;li&gt;The aim is to exchange data with the shortest routes (via routers).&lt;/li&gt;
&lt;li&gt;Encapsulation (Adding Layer 3 Header) (IPV4 or IPV6) (Sender)&lt;/li&gt;
&lt;li&gt;Decapsulation (Removing Layer 3 Header) (Receiver)&lt;/li&gt;
&lt;li&gt;Includes time to live, protocol, fragment offset, flag, version and etc.&lt;/li&gt;
&lt;li&gt;Source Address : IP Of the source&lt;/li&gt;
&lt;li&gt;Destination Address : Destination IP address&lt;/li&gt;
&lt;li&gt;Time to live: It is the lifetime of a package. It has an 8-bit value. This value is reduced by 1 for each router pass and if it is 0 the packet is discarded.&lt;/li&gt;
&lt;li&gt;Flag: It is to check whether the processed packet is the last packet of the data. If the More Fragment value is 1, it is indicated that there are other parts to be processed. If MF equals to zero and Fragment Offset equals to 0, this data is unfragmented.&lt;/li&gt;
&lt;li&gt;Version: IP&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Layer 4: Transport Layer&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Transport Layer is responsible for end-to-end communication between the two devices. This includes taking data from the layer 5 (session layer) and breaking it up into chunks called as segments before sending it to layer 3 (network layer).&lt;/li&gt;
&lt;li&gt;The transport layer on the receiving device is responsible for reassembling the segments into data the session layer can consume.&lt;/li&gt;
&lt;li&gt;Increases the Quality of Service (QoS) of the network.&lt;/li&gt;
&lt;li&gt;Responsible for flow control and error control.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Layer 5 : Session Layer&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Responsible for opening and closing communication between the two devices.&lt;/li&gt;
&lt;li&gt;The session layer also synchronizes data transfer with checkpoints. We can set a checkpoint that controls the data transfer in every 5 MB. This provides if your connection lost you can continue where you lost the connection.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Layer 6 : Presentation Layer&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The presentation layer is responsible for translation, encryption, and compression of data.&lt;/li&gt;
&lt;li&gt;Prepares the data presentable for applications to consume&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Layer 7: Application Layer&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The application layer is the layer closest to the user.&lt;/li&gt;
&lt;li&gt;Meets end user’s services&lt;/li&gt;
&lt;li&gt;This layer is responsible for application services for file transfers, e-mail, and other network software services.&lt;/li&gt;
&lt;li&gt;Only layer that directly interacts with data from the end user&lt;/li&gt;
&lt;li&gt;FTP, HTTP, Telnet&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sender Example
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Layer 7 — Application Layer&lt;/strong&gt;&lt;br&gt;
POST requests with JSON data to HTTPS server (Axios, fetch or etc.)&lt;br&gt;
&lt;strong&gt;Layer 6 — Presentation&lt;/strong&gt;&lt;br&gt;
Serialize JSON to flat byte strings&lt;br&gt;
&lt;strong&gt;Layer 5 — Session&lt;/strong&gt;&lt;br&gt;
Request to establish TCP connection/TLS&lt;br&gt;
&lt;strong&gt;Layer 4 — Transport&lt;/strong&gt;&lt;br&gt;
Sends SYN request target port 443&lt;br&gt;
&lt;strong&gt;Layer 3 — Network&lt;/strong&gt;&lt;br&gt;
SYN is placed an IP packet(s) and adds the source/dest IPs&lt;br&gt;
&lt;strong&gt;Layer 2 — Data link&lt;/strong&gt;&lt;br&gt;
Each packet goes into a single frame and adds the source/dest MAC addresses&lt;br&gt;
&lt;strong&gt;Layer 1 — Physical&lt;/strong&gt;&lt;br&gt;
Each frame becomes string of bits which converted into either a radio signal (wifi), electric signal (ethernet), or light (fiber)&lt;/p&gt;

&lt;h2&gt;
  
  
  Receiver Example
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Layer 1 — Physical&lt;/strong&gt;&lt;br&gt;
Radio, electric or light is received and coverted into digital bits&lt;br&gt;
&lt;strong&gt;Layer 2 — Data link&lt;/strong&gt;&lt;br&gt;
The bits from Layer 1 is assembled into frames&lt;br&gt;
&lt;strong&gt;Layer 3 — Network&lt;/strong&gt;&lt;br&gt;
The frames from layer 2 are assmbled into IP packet&lt;br&gt;
&lt;strong&gt;Layer 4 — Transport&lt;/strong&gt;&lt;br&gt;
The IP packets from layer 3 are assembled into TCP segments&lt;br&gt;
Deals with congestion control/flow control/retransmission in case of TCP&lt;br&gt;
&lt;strong&gt;Layer 3 — Session&lt;/strong&gt;&lt;br&gt;
The connection session is established or identified&lt;br&gt;
We only arrive at this layer when necessarry (three way handsake is done)&lt;br&gt;
&lt;strong&gt;Layer 2 — Presentation&lt;/strong&gt;&lt;br&gt;
Deserialize flat byte strings back to JSON for the app to consume&lt;br&gt;
&lt;strong&gt;Layer 1 — Application&lt;/strong&gt;&lt;br&gt;
Application understands the JSON POST rquest and your apache request receive event is triggered&lt;/p&gt;

&lt;h2&gt;
  
  
  References:
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.cloudflare.com/learning/ddos/glossary/open-systems-interconnection-model-osi/"&gt;https://www.cloudflare.com/learning/ddos/glossary/open-systems-interconnection-model-osi/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Originally published in &lt;a href="https://medium.com/@atakde/network-notes-osi-model-3007f06bdb65"&gt;medium&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>network</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
