<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Pramuditha Jayasundara on Medium]]></title>
        <description><![CDATA[Stories by Pramuditha Jayasundara on Medium]]></description>
        <link>https://medium.com/@pramujomega?source=rss-70f033aa81bc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*2fd8wmbdlPYBa8ik</url>
            <title>Stories by Pramuditha Jayasundara on Medium</title>
            <link>https://medium.com/@pramujomega?source=rss-70f033aa81bc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 03:49:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pramujomega/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[SSL vs TLS — Technology behind HTTPS]]></title>
            <link>https://medium.com/@pramujomega/ssl-vs-tls-technology-behind-https-482c6bfc29d7?source=rss-70f033aa81bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/482c6bfc29d7</guid>
            <dc:creator><![CDATA[Pramuditha Jayasundara]]></dc:creator>
            <pubDate>Wed, 19 Feb 2025 16:22:28 GMT</pubDate>
            <atom:updated>2025-02-19T16:22:28.464Z</atom:updated>
            <content:encoded><![CDATA[<h3>SSL vs TLS — Technology behind HTTPS</h3><p>As you know the Hypertext Transfer Protocol (HTTP) is the foundation of the World Wide Web, and is used to load webpages using hypertext links. HTTP transmits unencrypted data, which means that information sent from a browser can be intercepted and read by third parties. The request made by the client goes through several routers and switches before it reaches the server.</p><p>We can use <strong>tracert </strong>command in cmd(windows) to check the number of hops. hop is an intermediate device, like a router, that a packet passes through to reach its destination. The number of hops a connection takes depends on the physical locations of the command and the destination. From these switches and routers, data can be read if data is unencrypted.</p><p>To avoid this HTTPS in invented. HTTPS combines HTTP requests and responses with SSL and TLS technology.</p><p>Lets understand several concepts before dive into SSL and TLS.</p><p><strong>Confidentiality</strong></p><p>confidentiality is preventing sensitive information from unauthorized access attempts. Confidentiality is stablished using <em>Encryption.</em></p><p>Encryption is a way to conceal information by altering it so that it appears to be random data. result data is also known as ciphertext. Only someone with particular decrypt method can get back the original data. Encryption has 2 main types.</p><ul><li>Symmetric encryption</li><li>Asymmetric encryption</li></ul><p>A cryptographic key is a string of characters used within an encryption algorithm for altering data so that it appears random. Like a physical key, it locks (encrypts) data so that only someone with the right key can unlock (decrypt) it.</p><p>In symmetric encryption, there is only one key. this key is used for both encryption and decryption. In asymmetric encryption, there are two keys: one key is used for encryption, and a different key is used for decryption. these are known as public and private keys. public key is available publicly and private key is always kept private. Asymmetric encryption is a foundational technology for SSL and TLS.</p><p><strong>Authentication</strong></p><p>Authentication ensures that the parties exchanging information are who they claim to be. When a TLS connection is established the server provides a certificate that the client validates before trusting the server’s identity. Certificates are a convenient and widely adopted basis for authentication since no shared secret is required prior to initiating secure communication. A TLS certificate is issued by a certificate authority to the person or business that owns a domain. The certificate contains important information about who owns the domain, along with the server’s public key and a signature which are important for validating the server’s identity.</p><p><strong>Integrity</strong></p><p>Integrity<strong> </strong>verifies that the data has not been forged or tampered with. Once data is encrypted and authenticated, it is then signed with a message authentication code (MAC) like HMAC. The recipient can then verify the MAC to ensure the integrity of the data.</p><p>These 3 components are accomplished by SSL and TLS. When properly configured, an HTTPS connection guarantees these three things. now lets explore SSL and TLS.</p><p><strong>SSL and TLS</strong></p><p>SSL, or Secure Sockets Layer, is an encryption-based Internet security protocol. It was first developed by Netscape in 1995. However, SSL is an older technology that contains some security flaws. Transport Layer Security (TLS) is the upgraded version of SSL that fixes existing SSL vulnerabilities. TLS authenticates more efficiently and continues to support encrypted communication channels.</p><p>lets see how SSL/TLS works:</p><ul><li>SSL/TLS encrypts data that is transmitted across the web using a session key. This means that anyone who tries to intercept cannot decrypt it.</li><li>SSL/TLS initiates an authentication process called a handshake between two communicating devices to ensure that both devices are really who they claim to be.</li><li>SSL/TLS also digitally signs data in order to provide data integrity, verifying that the data is not tampered with before reaching receiver.</li></ul><p>There have been several iterations of SSL, each more secure than the last. In 1999 SSL was updated to become TLS.</p><p><strong>SSL vs TLS</strong></p><p>SSL and TLS distinct in how the operate. SSL went through several version and was succeeded by TLS.</p><p>SSL handshake was complex and slow. TLS handshake has fewer steps and a faster connection.</p><p>Both SSL and TLS use MACs for verifying the authenticity and integrity of messages. SSL used the MD5 algorithm which is now outdated for MAC generation. TLS uses Hash Based MAC for more complex cryptography and security.</p><p>Nowadays TLS 1.2 and 1.3 is used widely. TLS 1.3 has a significantly shorter handshake and improved effciency with reduced latency. Several key features like Zero Round Trip Time mode and forward secrecy are also introduced in TLS 1.3.</p><p>In conclusion, understanding the importance of SSL and TLS in securing online communications is essential for ensuring data integrity and privacy, fostering trust between users and websites in today’s interconnected world.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=482c6bfc29d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DNS — Domain Name System]]></title>
            <link>https://medium.com/@pramujomega/dns-domain-name-system-d90a1469f908?source=rss-70f033aa81bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/d90a1469f908</guid>
            <dc:creator><![CDATA[Pramuditha Jayasundara]]></dc:creator>
            <pubDate>Wed, 08 Jan 2025 17:48:50 GMT</pubDate>
            <atom:updated>2025-01-08T17:48:50.821Z</atom:updated>
            <content:encoded><![CDATA[<h3>DNS — Domain Name System</h3><p>As humans we remember the website names as google.com or facebook.com. When we open a browser and type one of those URLs it loads the particular website as well. But a lot of things happen behind the scenes.</p><p>Web browsers interact through Internet Protocol (IP) addresses. Browser needs the IP address of example.com to locate the example.com webpage. DNS translates domain names to IP addresses so browsers can load webpages. DNS stands for Domain Name System. It works by querying through several DNS servers to find the corresponding IP address of the example.com and direct it to the browser so that browser can call that particular IP address and load the webpage.</p><p>DNS query begins when a user searches a domain name or URL, A series of DNS servers then communicate with each other to resolve this query. DNS servers rely on <a href="http://0.0.1.148/">DNS records</a> to connect that user with the corresponding IP address. First browser sends DNS query to the local DNS resolver, usually provided by the Internet Service Provider(ISP). then the local resolver checks its cache. If it doesn’t find the IP, it queries the DNS hierarchy starting from the root server. Root server directs the resolver to the Top Level Domain Server(TLD).</p><p>The TLD server directs the resolver to the authoritative DNS server for the domain(example.com). Authoritative Server returns the IP address for the domain to the resolver. Finally local resolver caches the IP and sends it back to the client.</p><p>Lets analyze a Wireshark capture for <a href="http://www.geethanjalee.com/">www.facebook.com:</a></p><p>first of all lets clean the local DNS cache in our system. To do that open command prompt and type <strong>ipconfig /flushdns</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*sP67mwAxVapU3wYNsNsAHQ.png" /></figure><p>then open Wireshark and start capturing. for a clean capture lets go with command prompt instead of the browser. close all other browsers and open cmd and type <strong>nslookup facebook.com</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*WE1XyfpL06acCmPmDwnuHA.png" /></figure><p>The <strong>nslookup</strong> command can find a domain name’s IP address, or find a domain name from an IP address. now stop the capture in Wireshark and analyze. in Wireshark we can add a display filter for DNS to see only DNS packets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4NCk9RWE1k7qMTnfDus66w.png" /></figure><p>The browser first sends a “Standard query” to the DNS server, requesting the A record for facebook.com. The A record provides an IPv4 address, which is the traditional IP address format. This address allows the client to connect to facebook.com. Then the response comes with the IP address for facebook.com</p><p>Immediately after, the browser sends another “Standard query” for the AAAA record, which provides an IPv6 address. IPv6 addresses are larger and structured differently to support more devices on the internet due to the growing demand for IP addresses. for DNS records in detail<a href="http://link_to_dns_record_blog/"> look here</a>.</p><p>This is a simple example for finding the corresponding IP address for a domain name. Because of DNS we don’t need to memorize IP addresses to browse websites. Only domain names would be enough.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d90a1469f908" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Address Resolution Protocol]]></title>
            <link>https://medium.com/@pramujomega/address-resolution-protocol-d5cf38482c46?source=rss-70f033aa81bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5cf38482c46</guid>
            <dc:creator><![CDATA[Pramuditha Jayasundara]]></dc:creator>
            <pubDate>Thu, 19 Dec 2024 12:38:41 GMT</pubDate>
            <atom:updated>2024-12-19T12:38:41.495Z</atom:updated>
            <content:encoded><![CDATA[<p>When computers communicate with other computers through network, they use a standardized protocol called the OSI model to talk to each other and share information. the OSI provides a standard for different computer systems to be able to communicate with each other. It uses layers to visualize how various systems employ standard protocols in their communication with each other.</p><p>When computers need to connect with another computer, it should know the Physical Address of the 2nd computer to communicate. the actual communication happens over the Physical Address (MAC Address) from layer 2 of the OSI model. Both MAC Address and IP Address are used to uniquely define a device on the internet. IP Address, or Internet Protocol Address is a unique identifier for every system that has internet connectivity. So if one computer needs to communicate with another computer through network, It should know the MAC and IP addresses of 2nd computer.</p><p>ARP (Address Resolution Protocol) is used to identify the MAC address of a device using IP address. Without ARP, devices would not be able to communicate.</p><h3>How ARP Works</h3><p>When a computer wants to send a packet to another computer, say IP address 10.5.5.1, on its local area network (LAN), it first sends out an ARP packet. This packet is broadcasted to all the computers connected to the LAN. The ARP packet contains a simple question: What is the MAC address corresponding to IP address 10.5.5.1? The computer that has been configured to use the IP address responds with an ARP packet containing its MAC address. This packet is going only to the requested computer therefore it is unicasted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/0*SGOzPW6OA9SvZnCw.gif" /><figcaption><a href="https://media.geeksforgeeks.org/wp-content/uploads/20240212121108/How-Address-Resolution-Protocol-ARP-works---gif-opt-(1).gif">https://media.geeksforgeeks.org/wp-content/uploads/20240212121108/How-Address-Resolution-Protocol-ARP-works---gif-opt-(1).gif</a></figcaption></figure><p>Lets say computer A needs to communicate with computer B. lets capture a ARP request and a ARP response using Wireshark. I have used a display filter to filter out ARP requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jAo9mad_nPaXDMAwwSpBkg.png" /><figcaption>ARP filtered in Wireshark</figcaption></figure><p>lets analyze request and response separately.</p><p><em>ARP Request:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*24-DFM4PBd1rV78zOvzs_A.jpeg" /><figcaption>Ethernet header of request</figcaption></figure><p>In the Ethernet header of the request, destination is set as broadcast.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*EgG9j8N0cHInY2ZXGDLkKQ.jpeg" /><figcaption>ARP payload of request</figcaption></figure><p>In the ARP payload the target MAC address is set to 0 because it still doesn’t know the MAC address of 2nd computer. The <strong>Opcode</strong> indicates what type of ARP packet this is. There are really only two values you will see. A value of 1 indicates this ARP packet is a <em>Request</em>, or a value of 2 would indicates this ARP packet is a <em>Response</em></p><p><em>ARP Response:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/874/1*imDyho2THxTYafifE4WWdw.jpeg" /></figure><p>The <strong>Sender MAC</strong> and <strong>Sender IP</strong> Address include the addresses for Computer B, which is expected given computer B sent the ARP Response.</p><p>The <strong>Target MAC</strong> and <strong>Target IP</strong> Address include the addresses for Computer A, as this is the target of the ARP Response.</p><p>ARP has several important types: Proxy ARP, Gratuitous ARP, Reverse ARP and Inverse ARP. All these types serve as communication protocols on the local area network.</p><p>Unfortunately, the ARP protocol is vulnerable to spoofing, DoS and Man-in-the-Middle attacks, and session hijackings — malicious cyberattacks performed by cybercriminals. Security measures should be taken to ensure ARP security.</p><h3>References</h3><p><a href="https://www.ipxo.com/blog/address-resolution-protocol/">https://www.ipxo.com/blog/address-resolution-protocol/</a></p><p><a href="https://www.geeksforgeeks.org/how-address-resolution-protocol-arp-works/?ref=header_outind">https://www.geeksforgeeks.org/how-address-resolution-protocol-arp-works/?ref=header_outind</a></p><p><a href="https://www.practicalnetworking.net/series/arp/traditional-arp/#:~:text=ARP%20Response,-The%20ARP%20Response&amp;text=The%20Ethernet%20header%20has%20the,Host%20B%20%E2%80%94%20the%20original%20target">https://www.practicalnetworking.net/series/arp/traditional-arp/#:~:text=ARP%20Response,-The%20ARP%20Response&amp;text=The%20Ethernet%20header%20has%20the,Host%20B%20%E2%80%94%20the%20original%20target</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5cf38482c46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Floating Point Problem in Computers]]></title>
            <link>https://medium.com/@pramujomega/floating-point-problem-in-computers-2d439b75dc6a?source=rss-70f033aa81bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/2d439b75dc6a</guid>
            <dc:creator><![CDATA[Pramuditha Jayasundara]]></dc:creator>
            <pubDate>Sun, 13 Oct 2024 13:48:15 GMT</pubDate>
            <atom:updated>2024-10-13T13:48:15.568Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>There are several number systems used in the world for various purposes, As humans we commonly use base-10 number system but its not the oldest one. The Babylonian numeral system is considered the oldest number system in the world, using a base-60 system. however the computers don’t use the decimal number system. They use binary number system with a base of 2. This sometimes leads to unexpected errors like floating point problem. lets first see how computers store numbers.</p><h3>How Computers Store Numbers</h3><p>Computers use binary number system to handle numbers because it allows computers to store and manipulate data using a system of switches that can be turned on or off, represented by the digits 0 and 1 which corresponds to the absence or presence of an electrical charge in a computer’s memory or storage device. In binary, each digit is referred to as a bit, which is binary digit in short. The value of each bit depends on its position within a number.</p><p>Computers use a fixed number of bits to represent a piece of data, which could be a number, a character, or others. An n-bit storage location can represent up to 2 n distinct entities. There are industrial standards to store those numbers in computer. 2 types of numbers which are integers and real numbers(floating-point numbers) are treated differently when storing. They have different representation and are processed differently. It is important to note that a computer memory location merely stores a binary pattern. The floating point problem comes when we are going to store a number with infinite decimal points in a finite amount of memory. Lets see how computers store floating-point numbers.</p><h3>How Computers Represent Floating-Point Numbers</h3><p>There are several ways to represent floating point number but modern computers and compilers adopt IEEE 754 standard. There are three representation schemes: 32-bit single-precision, 64-bit double-precision and 128 bit long double precision. All three schemes has the same architecture.</p><p>In 32-bit single-precision floating-point representation:</p><p>The most significant bit is the sign bit (S), with 0 for positive numbers and 1 for negative numbers. The following 8 bits represent exponent (E). The remaining 23 bits represents fraction (F).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/0*fYji4wschpLh2D4x.jpg" /><figcaption><a href="https://media.geeksforgeeks.org/wp-content/uploads/Single-Precision-IEEE-754-Floating-Point-Standard.jpg">https://media.geeksforgeeks.org/wp-content/uploads/Single-Precision-IEEE-754-Floating-Point-Standard.jpg</a></figcaption></figure><p>other two schemes just differ with the number of bits allocated for exponent and mantissa. If the allocated bits are higher, the precision is higher. However even the size of mantissa is large, its finite, meaning that finite number of bits can be stored. Therefore the result must often be rounded in order to fit back into its finite representation.</p><h3>The floating-point problem</h3><p>When we want to represent a number like 1/3 in In decimal form, we cannot do that precisely because the answer of 1/3 doesn’t end.</p><p>1/3 = 0.33333…..and it keeps going on. It is called repeating decimal.</p><p>This is common for any number system including binary. So the computers struggle when storing this kind of values with infinite amount of floating points in a finite memory space. Hence, not all the real numbers can be represented. The nearest approximation will be used instead, resulted in loss of accuracy. Imagine trying to measure 1/3 of a pie but only being able to cut slices in whole numbers. You’ll get close, but never the perfect 1/3 slice. This is where the floating point problem comes in. If we give computer to add 0.1 and 0.2, it will give 0.30000000000000004 instead of just 0.3 because of this error. This problem is hugely reflected in areas like currency calculating, scientific computing and in gaming etc.</p><h3>What Can we do</h3><p>There is no precise solution for this floating point problem, but at least we can mitigate the error. We should use integers for calculation every time where its possible. For critical applications use libraries and methods like Big Decimal( Java ) or .toFixed() and .toPrecision() (JS).</p><pre>pi = 3.14159265359;<br>twoPlaces = pi.toFixed(2);<br>fivePlaces = pi.toFixed(5);<br> <br>console.log(twoPlaces);<br>console.log(fivePlaces);</pre><p><em>output:</em></p><pre>3.14<br>3.14159</pre><p>Next time you see a strange result in a calculation, you’ll know what might be causing it. By understanding the quirks of floating-point numbers, we can better navigate the digital world where even tiny decimals can make a big difference!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2d439b75dc6a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>