<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:media="http://search.yahoo.com/mrss/"><channel><title>Sriram Ramanujam on Linuxize</title><link>https://linuxize.com/authors/sriram-ramanujam/</link><description>Recent content in Sriram Ramanujam on Linuxize</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><managingEditor>hello@linuxize.com (Linuxize)</managingEditor><webMaster>hello@linuxize.com (Linuxize)</webMaster><lastBuildDate>Fri, 17 Sep 2021 10:36:37 +0100</lastBuildDate><atom:link href="https://linuxize.com/authors/sriram-ramanujam/index.xml" rel="self" type="application/rss+xml"/><image><url>https://linuxize.com/icons/icon-512x512.png</url><title>Linuxize</title><link>https://linuxize.com/</link></image><item><title>IPv4 vs IPv6</title><link>https://linuxize.com/post/ip4-vs-ip6/</link><pubDate>Fri, 17 Sep 2021 10:36:37 +0100</pubDate><author>hello@linuxize.com (Linuxize)</author><guid>https://linuxize.com/post/ip4-vs-ip6/</guid><category>networking</category><description>The Internet Protocol (IP) is a set of rules for that specifies addressing and routing the data between computers.</description><content:encoded>&lt;p&gt;In today&amp;rsquo;s technological era, we are witnessing a massive leap in the usage of the internet and networking devices. Every home has a laptop, smartphone, digital watch, IoT device, home automation component, and other devices that are connected to the home network or the Internet. Devices communicate with each other through various network protocols, with TCP and IP being the most frequently used protocols. Each device connected to the network must have an IP address that identifies the device on the network.&lt;/p&gt;
&lt;p&gt;This article explains the Internet Protocol and how IPv6 differs from IPv4.&lt;/p&gt;
&lt;h2 id="what-is-ip-internet-protocol"&gt;What is IP (Internet Protocol)? &lt;a class="headline-link" href="#what-is-ip-internet-protocol" aria-hidden="true"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Being humans, we identify and communicate with each other using our names. Likewise, in the computing world, devices use IP addresses to identify and interact with each other. A common language used by all computing devices to communicate with each other is known as a protocol. Akin to human languages, the protocol also has a set of rules that formats and processes the data.&lt;/p&gt;
&lt;figure class='relative w-full'&gt;&lt;div class="relative block w-full mx-auto my-0"&gt;&lt;div class="block" style="aspect-ratio: 951 / 370"&gt;&lt;/div&gt;
&lt;div class="bg-gray-100 absolute inset-0 w-full h-full m-auto overflow-hidden "&gt;&lt;picture class="absolute inset-0 w-full h-full m-auto"&gt;
&lt;source
type="image/webp"
srcset="https://linuxize.com/post/ip4-vs-ip6/names_hu_263587a11b4ded2a.webp 480w, https://linuxize.com/post/ip4-vs-ip6/names_hu_2eb733ea4a6de90a.webp 768w, https://linuxize.com/post/ip4-vs-ip6/names_hu_dbca990e099c98cb.webp 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"&gt;
&lt;img class="absolute inset-0 w-full h-full m-auto object-cover " loading="lazy"
decoding="async"
src="https://linuxize.com/post/ip4-vs-ip6/names_hu_44047dfa8c94348d.jpg"
srcset="https://linuxize.com/post/ip4-vs-ip6/names_hu_6b5f2c013e8b1f16.jpg 480w, https://linuxize.com/post/ip4-vs-ip6/names_hu_44047dfa8c94348d.jpg 768w, https://linuxize.com/post/ip4-vs-ip6/names_hu_99c64e6d00b76011.jpg 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"
width="768"
height="299"
alt="names"&gt;
&lt;/picture&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/figure&gt;
&lt;p&gt;The Internet Protocol (IP) is a set of rules that specifies addressing and routing the data between computers. It is mostly used with network transport protocols, such as TCP and UDP.&lt;/p&gt;
&lt;p&gt;The Internet exists today because of this unique addressing pattern. The IANA manages the IP address ranges for networks/sites that connect to the Internet. However, if we run an isolated local network infrastructure, we can assign numbers according to our preference. Now, let&amp;rsquo;s get into the nitty-gritty of both architecture and its comparative analysis.&lt;/p&gt;
&lt;h2 id="ipv4"&gt;IPv4 &lt;a class="headline-link" href="#ipv4" aria-hidden="true"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The first major version of Internet Protocol (IP) is version 4 (IPv4). It uses a 32-bit network addressing schema that further splits into four 8-bit numbers known as octets. For instance, google.com has an IP address of 141.251.36.46. The format is known as dotted quad notation. These IP addresses can either be configured manually or automatically obtained through a DHCP server.&lt;/p&gt;
&lt;p&gt;To check the live status of the remote device, we can do an ICMP probing to that IP using the &lt;a href="https://linuxize.com/post/linux-ping-command/"&gt;&lt;code&gt;ping&lt;/code&gt;&lt;/a&gt;
command:&lt;/p&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="bash" data-prompt="$"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;polyline points="4 17 10 11 4 5"&gt;&lt;/polyline&gt;
&lt;line x1="12" y1="19" x2="20" y2="19"&gt;&lt;/line&gt;
&lt;/svg&gt;
&lt;span class="text-sm text-gray-600 dark:text-slate-400 font-medium"&gt;Terminal&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ping -c &lt;span class="m"&gt;1&lt;/span&gt; google.com&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="output"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;output&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;pre tabindex="0"&gt;&lt;code class="language-output" data-lang="output"&gt;PING google.com (142.251.36.46) 56(84) bytes of data.
64 bytes from ams17s12-in-f14.1e100.net (142.251.36.46): icmp_seq=1 ttl=116 time=247 ms
...&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;IP addresses are broken into two parts, network, and host addresses for creating sub-networks. The subnet numbers help to decide the network and host parts of the IP. Also, the available IP space is divided into five different classes as tabulated below.&lt;/p&gt;
&lt;div class="mt-0 border-t border-b border-gray-300 dark:border-slate-800 overflow-hidden relative"&gt;
&lt;div class="overflow-y-auto scrollbar-w-2 scrollbar-track-gray-lighter scrollbar-thumb-rounded scrollbar-thumb-gray scrolling-touch"&gt;
&lt;table class="w-full text-left table-collapse"&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Address Class&lt;/th&gt;
&lt;th&gt;IP Ranges&lt;/th&gt;
&lt;th&gt;Subnet Mask&lt;/th&gt;
&lt;th&gt;No of Networks&lt;/th&gt;
&lt;th&gt;No of hosts per Network&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Class A&lt;/td&gt;
&lt;td&gt;1.0.0.0 to 126.0.0.0&lt;/td&gt;
&lt;td&gt;255.0.0.0&lt;/td&gt;
&lt;td&gt;126&lt;/td&gt;
&lt;td&gt;16,777,214&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Class B&lt;/td&gt;
&lt;td&gt;128.0.0.0 to 191.255.0.0&lt;/td&gt;
&lt;td&gt;255.255.0.0&lt;/td&gt;
&lt;td&gt;16,282&lt;/td&gt;
&lt;td&gt;65,534&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Class C&lt;/td&gt;
&lt;td&gt;192.0.0.0 to 223.255.255.0&lt;/td&gt;
&lt;td&gt;255.255.255.0&lt;/td&gt;
&lt;td&gt;2,097,150&lt;/td&gt;
&lt;td&gt;254&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Class D&lt;/td&gt;
&lt;td&gt;224.0.0.0 to 239.255.255.255&lt;/td&gt;
&lt;td&gt;Multicasting&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Class E&lt;/td&gt;
&lt;td&gt;240.0.0.0 to 255.255.255.255&lt;/td&gt;
&lt;td&gt;Research/Reserved/Experimental&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The calculation of subnet involves a few mathematical rubrics behind the screen. To ease our computation, we can use tools like &lt;code&gt;ipcalc&lt;/code&gt; or &lt;code&gt;subnetcalc&lt;/code&gt; for IPv4 subnetting. The below snippets shows how to use the tools:&lt;/p&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="bash" data-prompt="$"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;polyline points="4 17 10 11 4 5"&gt;&lt;/polyline&gt;
&lt;line x1="12" y1="19" x2="20" y2="19"&gt;&lt;/line&gt;
&lt;/svg&gt;
&lt;span class="text-sm text-gray-600 dark:text-slate-400 font-medium"&gt;Terminal&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ipcalc 110.0.20.18/24&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="output"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;output&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;pre tabindex="0"&gt;&lt;code class="language-output" data-lang="output"&gt;Address: 110.0.20.18 01101110.00000000.00010100. 00010010
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
=&amp;gt;
Network: 110.0.20.0/24 01101110.00000000.00010100. 00000000
HostMin: 110.0.20.1 01101110.00000000.00010100. 00000001
HostMax: 110.0.20.254 01101110.00000000.00010100. 11111110
Broadcast: 110.0.20.255 01101110.00000000.00010100. 11111111
Hosts/Net: 254 Class A&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="bash" data-prompt="$"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;polyline points="4 17 10 11 4 5"&gt;&lt;/polyline&gt;
&lt;line x1="12" y1="19" x2="20" y2="19"&gt;&lt;/line&gt;
&lt;/svg&gt;
&lt;span class="text-sm text-gray-600 dark:text-slate-400 font-medium"&gt;Terminal&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;subnetcalc 192.168.10.15/24&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="output"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;output&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;pre tabindex="0"&gt;&lt;code class="language-output" data-lang="output"&gt;Address = 192.168.10.15
11000000 . 10101000 . 00001010 . 00001111
Network = 192.168.10.0 / 24
Netmask = 255.255.255.0
Broadcast = 192.168.10.255
Wildcard Mask = 0.0.0.255
Hosts Bits = 8
Max. Hosts = 254 (2^8 - 2)
Host Range = { 192.168.10.1 - 192.168.10.254 }
Properties =
- 192.168.10.15 is a HOST address in 192.168.10.0/24
- Class C
- Private
GeoIP Country = Unknown (??)
DNS Hostname = (Name or service not known)&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Usually, IP addresses are given to the end host machine and router gateway interface, as illustrated below.&lt;/p&gt;
&lt;figure class='relative w-full'&gt;&lt;div class="relative block w-full mx-auto my-0"&gt;&lt;div class="block" style="aspect-ratio: 990 / 619"&gt;&lt;/div&gt;
&lt;div class="bg-gray-100 absolute inset-0 w-full h-full m-auto overflow-hidden "&gt;&lt;picture class="absolute inset-0 w-full h-full m-auto"&gt;
&lt;source
type="image/webp"
srcset="https://linuxize.com/post/ip4-vs-ip6/internet-routing_hu_e3cf97016c3a6bef.webp 480w, https://linuxize.com/post/ip4-vs-ip6/internet-routing_hu_7900d5b331e635b0.webp 768w, https://linuxize.com/post/ip4-vs-ip6/internet-routing_hu_dd02843092d60be1.webp 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"&gt;
&lt;img class="absolute inset-0 w-full h-full m-auto object-cover " loading="lazy"
decoding="async"
src="https://linuxize.com/post/ip4-vs-ip6/internet-routing_hu_802099552013d463.jpg"
srcset="https://linuxize.com/post/ip4-vs-ip6/internet-routing_hu_f45536f7b04c6892.jpg 480w, https://linuxize.com/post/ip4-vs-ip6/internet-routing_hu_802099552013d463.jpg 768w, https://linuxize.com/post/ip4-vs-ip6/internet-routing_hu_284d321050d64fc9.jpg 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"
width="768"
height="480"
alt="internet-routing"&gt;
&lt;/picture&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/figure&gt;
&lt;p&gt;Here, the traffic from Machine A (10.235.64.58) hits the router gateway interface (10.235.64.57) at the left side of the internet cloud. It reaches Google Server gateway through Internet routing and finally to the destination server.&lt;/p&gt;
&lt;p&gt;To identify the network interface IP you can use commands such &lt;a href="https://linuxize.com/post/ifconfig-command/"&gt;&lt;code&gt;ifconfig&lt;/code&gt;&lt;/a&gt;
, &lt;code&gt;hostname&lt;/code&gt; or &lt;a href="https://linuxize.com/post/linux-ip-command/"&gt;&lt;code&gt;ip&lt;/code&gt;&lt;/a&gt;
.&lt;/p&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="bash" data-prompt="$"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;polyline points="4 17 10 11 4 5"&gt;&lt;/polyline&gt;
&lt;line x1="12" y1="19" x2="20" y2="19"&gt;&lt;/line&gt;
&lt;/svg&gt;
&lt;span class="text-sm text-gray-600 dark:text-slate-400 font-medium"&gt;Terminal&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;ifconfig ens160&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="output"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;output&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;pre tabindex="0"&gt;&lt;code class="language-output" data-lang="output"&gt;ens160: flags=4163&amp;lt;UP,BROADCAST,RUNNING,MULTICAST&amp;gt; mtu 1500
inet 10.235.64.58 netmask 255.255.255.252 broadcast 10.235.64.59
inet6 fe80::fc7f:d8da:a969:1c1d prefixlen 64 scopeid 0x20&amp;lt;link&amp;gt;
ether 00:0c:29:23:6f:30 txqueuelen 1000 (Ethernet)
RX packets 35607241 bytes 34540488400 (34.5 GB)
RX errors 0 dropped 12 overruns 0 frame 0
TX packets 24701952 bytes 15008379564 (15.0 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="bash" data-prompt="$"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;polyline points="4 17 10 11 4 5"&gt;&lt;/polyline&gt;
&lt;line x1="12" y1="19" x2="20" y2="19"&gt;&lt;/line&gt;
&lt;/svg&gt;
&lt;span class="text-sm text-gray-600 dark:text-slate-400 font-medium"&gt;Terminal&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;hostname -I&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="output"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;output&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;pre tabindex="0"&gt;&lt;code class="language-output" data-lang="output"&gt;10.235.64.58&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;There are special purposes network IP addresses like &lt;code&gt;0.0.0.0&lt;/code&gt; or &lt;code&gt;127.0.0.1&lt;/code&gt;. The former is the default route or quad-zero route, whilst the latter is called the loopback address.&lt;/p&gt;
&lt;p&gt;In the below snippet, we will use &lt;a href="https://linuxize.com/post/netstat-command-in-linux/"&gt;&lt;code&gt;netstat&lt;/code&gt;&lt;/a&gt;
to see the Kernel IP routing table with the default route for that network. The flag &amp;lsquo;U&amp;rsquo; represents that the network route is UP, whilst G signifies that the network route is the network gateway.&lt;/p&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="bash" data-prompt="$"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;polyline points="4 17 10 11 4 5"&gt;&lt;/polyline&gt;
&lt;line x1="12" y1="19" x2="20" y2="19"&gt;&lt;/line&gt;
&lt;/svg&gt;
&lt;span class="text-sm text-gray-600 dark:text-slate-400 font-medium"&gt;Terminal&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;netstat -rn &lt;span class="p"&gt;|&lt;/span&gt; grep ens160&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="output"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;output&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;pre tabindex="0"&gt;&lt;code class="language-output" data-lang="output"&gt;Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.235.64.57 0.0.0.0 UG 0 0 0 ens160
10.235.64.56 0.0.0.0 255.255.255.252 U 0 0 0 ens160&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Usually, the IPv4 datagram consists of a header field with 20 bytes, options field, and data fields with a variable length. The sample packet format is shown below.&lt;/p&gt;
&lt;figure class='relative w-full'&gt;&lt;div class="relative block w-full mx-auto my-0"&gt;&lt;div class="block" style="aspect-ratio: 852 / 723"&gt;&lt;/div&gt;
&lt;div class="bg-gray-100 absolute inset-0 w-full h-full m-auto overflow-hidden "&gt;&lt;picture class="absolute inset-0 w-full h-full m-auto"&gt;
&lt;source
type="image/webp"
srcset="https://linuxize.com/post/ip4-vs-ip6/ipv4-packet_hu_fbcb9c4209d0693.webp 480w, https://linuxize.com/post/ip4-vs-ip6/ipv4-packet_hu_e5e9b5544426861b.webp 768w, https://linuxize.com/post/ip4-vs-ip6/ipv4-packet_hu_6cdbbabe761a6718.webp 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"&gt;
&lt;img class="absolute inset-0 w-full h-full m-auto object-cover " loading="lazy"
decoding="async"
src="https://linuxize.com/post/ip4-vs-ip6/ipv4-packet_hu_d4a5877b49891d45.jpg"
srcset="https://linuxize.com/post/ip4-vs-ip6/ipv4-packet_hu_b202ea9d082c21c8.jpg 480w, https://linuxize.com/post/ip4-vs-ip6/ipv4-packet_hu_d4a5877b49891d45.jpg 768w, https://linuxize.com/post/ip4-vs-ip6/ipv4-packet_hu_ee0001fe1e2231b9.jpg 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"
width="768"
height="652"
alt="ipv4-packet"&gt;
&lt;/picture&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/figure&gt;
&lt;p&gt;Below, Wireshark capture helps to decipher the packet header information from the live traffic.&lt;/p&gt;
&lt;figure class='relative w-full'&gt;&lt;div class="relative block w-full mx-auto my-0"&gt;&lt;div class="block" style="aspect-ratio: 481 / 239"&gt;&lt;/div&gt;
&lt;div class="bg-gray-100 absolute inset-0 w-full h-full m-auto overflow-hidden "&gt;&lt;picture class="absolute inset-0 w-full h-full m-auto"&gt;
&lt;source
type="image/webp"
srcset="https://linuxize.com/post/ip4-vs-ip6/wireshark_hu_5685cf4245780b0b.webp 480w, https://linuxize.com/post/ip4-vs-ip6/wireshark_hu_9d99dd51670bc9eb.webp 768w, https://linuxize.com/post/ip4-vs-ip6/wireshark_hu_610e8b4369ffc14a.webp 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"&gt;
&lt;img class="absolute inset-0 w-full h-full m-auto object-cover " loading="lazy"
decoding="async"
src="https://linuxize.com/post/ip4-vs-ip6/wireshark_hu_1bb3feac58dc7cd1.jpg"
srcset="https://linuxize.com/post/ip4-vs-ip6/wireshark_hu_f4ef9555d45e4ced.jpg 480w, https://linuxize.com/post/ip4-vs-ip6/wireshark_hu_1bb3feac58dc7cd1.jpg 768w, https://linuxize.com/post/ip4-vs-ip6/wireshark_hu_3f14a011fa20c544.jpg 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"
width="768"
height="382"
alt="wireshark"&gt;
&lt;/picture&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/figure&gt;
&lt;h2 id="ipv6"&gt;IPv6 &lt;a class="headline-link" href="#ipv6" aria-hidden="true"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Internet Protocol version 6 is the updated version of Internet Protocol (IP). Version 6 of the Internet Protocol is intended to replace the older version (IPv4), which carries 75% of total internet traffic as of 2018 (Source: Google IPv6 Stats).&lt;/p&gt;
&lt;p&gt;The IPv6 address is 128 bits (16 bytes) using 32 hexadecimal digits, whilst these digits are further divided into eight groups of four digits each for ease of management. A brief illustration is shown below.&lt;/p&gt;
&lt;figure class='relative w-full'&gt;&lt;div class="relative block w-full mx-auto my-0"&gt;&lt;div class="block" style="aspect-ratio: 857 / 561"&gt;&lt;/div&gt;
&lt;div class="bg-gray-100 absolute inset-0 w-full h-full m-auto overflow-hidden "&gt;&lt;picture class="absolute inset-0 w-full h-full m-auto"&gt;
&lt;source
type="image/webp"
srcset="https://linuxize.com/post/ip4-vs-ip6/ipv6-packet_hu_962624cd9ed8d00b.webp 480w, https://linuxize.com/post/ip4-vs-ip6/ipv6-packet_hu_72b326ffd12d92ed.webp 768w, https://linuxize.com/post/ip4-vs-ip6/ipv6-packet_hu_a128f3191a2da807.webp 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"&gt;
&lt;img class="absolute inset-0 w-full h-full m-auto object-cover " loading="lazy"
decoding="async"
src="https://linuxize.com/post/ip4-vs-ip6/ipv6-packet_hu_4aada6b7be21774d.jpg"
srcset="https://linuxize.com/post/ip4-vs-ip6/ipv6-packet_hu_9f7b01a672f1783e.jpg 480w, https://linuxize.com/post/ip4-vs-ip6/ipv6-packet_hu_4aada6b7be21774d.jpg 768w, https://linuxize.com/post/ip4-vs-ip6/ipv6-packet_hu_5e9fd75474e638c6.jpg 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"
width="768"
height="503"
alt="ipv6"&gt;
&lt;/picture&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/figure&gt;
&lt;p&gt;There are few basic steps involved in the IPv6 naming convention.&lt;/p&gt;
&lt;p&gt;Rule 1: All letters are case insensitive. For example, &amp;lsquo;ab41&amp;rsquo; equals &amp;lsquo;AB41&amp;rsquo;
Rule 2: Successive fields with &amp;lsquo;0&amp;rsquo; can be visualized as &amp;ldquo;::&amp;rdquo;, but only once in an addressing
Rule 3: Representing leading zeros in a field are optional. For instance, &amp;lsquo;001a&amp;rsquo; equals &amp;lsquo;1a&amp;rsquo;&lt;/p&gt;
&lt;p&gt;For Instance, let’s take the IPv6 address, 45ab:0000:a179:0000:0000:c1c0:abcd:0876&lt;/p&gt;
&lt;p&gt;Apply Rule 1 =&amp;gt; 45ab:0000:a179:0000:0000:c1c0:abcd:0876
Apply Rule 2 =&amp;gt; 45ab:0:a179:0:0:c1c0:abcd:876
Apply Rule 3 =&amp;gt; 45ab:0:a179::c1c0:abcd:876&lt;/p&gt;
&lt;p&gt;There are three types of IPv6 addresses: Unicast, Multicast, and Anycast. The unicast address is the single network interface and packets delivered to that specific interface. Additionally, unicast addresses have local(link-local) and global scope levels. Multicast address is the group interfaces to which the packets get delivered. Anycast address is the group interface and packet delivered to the nearest interface.&lt;/p&gt;
&lt;p&gt;Few well-known addresses are tabulated below.&lt;/p&gt;
&lt;div class="mt-0 border-t border-b border-gray-300 dark:border-slate-800 overflow-hidden relative"&gt;
&lt;div class="overflow-y-auto scrollbar-w-2 scrollbar-track-gray-lighter scrollbar-thumb-rounded scrollbar-thumb-gray scrolling-touch"&gt;
&lt;table class="w-full text-left table-collapse"&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;]::1/128&lt;/th&gt;
&lt;th&gt;Loopback address&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;ff00::/8&lt;/td&gt;
&lt;td&gt;Multicast addresses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;fe80::/10&lt;/td&gt;
&lt;td&gt;Link-local addresses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2001::/16&lt;/td&gt;
&lt;td&gt;Regular IPv6 unicast addresses&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;2002::/16&lt;/td&gt;
&lt;td&gt;6to4 Unicast addresses&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="bash" data-prompt="$"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;polyline points="4 17 10 11 4 5"&gt;&lt;/polyline&gt;
&lt;line x1="12" y1="19" x2="20" y2="19"&gt;&lt;/line&gt;
&lt;/svg&gt;
&lt;span class="text-sm text-gray-600 dark:text-slate-400 font-medium"&gt;Terminal&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;subnetcalc 2001:4860:4860::8888/64&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="output"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;output&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;pre tabindex="0"&gt;&lt;code class="language-output" data-lang="output"&gt;Address = 2001:4860:4860::8888
2001 = 00100000 00000001
4860 = 01001000 01100000
4860 = 01001000 01100000
0000 = 00000000 00000000
0000 = 00000000 00000000
0000 = 00000000 00000000
0000 = 00000000 00000000
8888 = 10001000 10001000
Network = 2001:4860:4860:: / 64
Netmask = ffff:ffff:ffff:ffff::
Wildcard Mask = ::ffff:ffff:ffff:ffff
Hosts Bits = 64
Max. Hosts = 18446744073709551616 (2^64 - 1)
Host Range = { 2001:4860:4860::1 - 2001:4860:4860:0:ffff:ffff:ffff:ffff }
Properties =
- 2001:4860:4860::8888 is a HOST address in 2001:4860:4860::/64
- Global Unicast Properties:
+ Interface ID = 0000:0000:0000:8888
+ Sol. Node MC = ff02::1:ff00:8888
GeoIP Country = United States (US)
DNS Hostname = dns.google&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;Again, the IPv6 packet has both header and payload. The header size is fixed to 40bytes, with source and destination address taking 32bytes. The sample packet format is shown below.&lt;/p&gt;
&lt;figure class='relative w-full'&gt;&lt;div class="relative block w-full mx-auto my-0"&gt;&lt;div class="block" style="aspect-ratio: 857 / 561"&gt;&lt;/div&gt;
&lt;div class="bg-gray-100 absolute inset-0 w-full h-full m-auto overflow-hidden "&gt;&lt;picture class="absolute inset-0 w-full h-full m-auto"&gt;
&lt;source
type="image/webp"
srcset="https://linuxize.com/post/ip4-vs-ip6/ipv6-packet_hu_962624cd9ed8d00b.webp 480w, https://linuxize.com/post/ip4-vs-ip6/ipv6-packet_hu_72b326ffd12d92ed.webp 768w, https://linuxize.com/post/ip4-vs-ip6/ipv6-packet_hu_a128f3191a2da807.webp 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"&gt;
&lt;img class="absolute inset-0 w-full h-full m-auto object-cover " loading="lazy"
decoding="async"
src="https://linuxize.com/post/ip4-vs-ip6/ipv6-packet_hu_4aada6b7be21774d.jpg"
srcset="https://linuxize.com/post/ip4-vs-ip6/ipv6-packet_hu_9f7b01a672f1783e.jpg 480w, https://linuxize.com/post/ip4-vs-ip6/ipv6-packet_hu_4aada6b7be21774d.jpg 768w, https://linuxize.com/post/ip4-vs-ip6/ipv6-packet_hu_5e9fd75474e638c6.jpg 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"
width="768"
height="503"
alt="ipv6-packet"&gt;
&lt;/picture&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/figure&gt;
&lt;p&gt;Though IPv6 has umpteen advantages, it cannot supplant IPv4. Both protocol versions have to co-exist for some time for seamless migration. Hence, the service providers are offering a dual-stack support system that possesses a network interface that can understand both IPv4 and IPv6 packets.&lt;/p&gt;
&lt;p&gt;There are few smart transition mechanisms, namely IPv6 Tunneling, IPv4 mapped IPv6 addresses, etc. The former encapsulates the IPv6 packet in IPv4, whilst the latter maps the IPv6 to IPv4 addresses in the dual-stack implementations.&lt;/p&gt;
&lt;h2 id="ipv4-vs-ipv6---quick-comparative-analysis"&gt;IPv4 vs IPv6 - Quick Comparative Analysis &lt;a class="headline-link" href="#ipv4-vs-ipv6---quick-comparative-analysis" aria-hidden="true"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;div class="mt-0 border-t border-b border-gray-300 dark:border-slate-800 overflow-hidden relative"&gt;
&lt;div class="overflow-y-auto scrollbar-w-2 scrollbar-track-gray-lighter scrollbar-thumb-rounded scrollbar-thumb-gray scrolling-touch"&gt;
&lt;table class="w-full text-left table-collapse"&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Features&lt;/th&gt;
&lt;th&gt;Internet Protocol - Version 4 [IPv4]&lt;/th&gt;
&lt;th&gt;Internet Protocol - Version 6 [IPv6]&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Deployment &amp;amp; allocation&lt;/td&gt;
&lt;td&gt;1981&lt;/td&gt;
&lt;td&gt;1999&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Length&lt;/td&gt;
&lt;td&gt;32-bit&lt;/td&gt;
&lt;td&gt;128-bit&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Address Space&lt;/td&gt;
&lt;td&gt;4.29 x 10^9&lt;/td&gt;
&lt;td&gt;3.4 x 10^38&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Format&lt;/td&gt;
&lt;td&gt;Dotted Decimal / [10.235.64.56]&lt;/td&gt;
&lt;td&gt;Hexadecimal / [2400::4]&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Number of Octets&lt;/td&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;16&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Header Size&lt;/td&gt;
&lt;td&gt;Varies from 20 - 60 bytes&lt;/td&gt;
&lt;td&gt;40 bytes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Classes&lt;/td&gt;
&lt;td&gt;Five classes: Class A, Class B, Class C, Class D, Class E&lt;/td&gt;
&lt;td&gt;None&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Security Features / Authentication and encryption&lt;/td&gt;
&lt;td&gt;Not available&lt;/td&gt;
&lt;td&gt;Available&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Check sum&lt;/td&gt;
&lt;td&gt;Available&lt;/td&gt;
&lt;td&gt;Not available&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IPSec&lt;/td&gt;
&lt;td&gt;External and optional&lt;/td&gt;
&lt;td&gt;Inbuilt feature&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hop Count&lt;/td&gt;
&lt;td&gt;Indicated by TTL field&lt;/td&gt;
&lt;td&gt;Indicated by Hoplimit field&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fragmentation&lt;/td&gt;
&lt;td&gt;Performed by sender and forwarding routers&lt;/td&gt;
&lt;td&gt;Done by sender only&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Option Fields&lt;/td&gt;
&lt;td&gt;Provided in the IPv4 header&lt;/td&gt;
&lt;td&gt;There are no optional fields, but IPv6 Extension headers are available&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Multicast&lt;/td&gt;
&lt;td&gt;IGMP manages the multicast group membership&lt;/td&gt;
&lt;td&gt;MLD replaces the IGMP&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Broadcast message&lt;/td&gt;
&lt;td&gt;Available&lt;/td&gt;
&lt;td&gt;Not available. Multicast is used&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IP to MAC Mapping&lt;/td&gt;
&lt;td&gt;Address Resolution Protocol&lt;/td&gt;
&lt;td&gt;Neighbour Discovery Protocol&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id="conclusion"&gt;Conclusion &lt;a class="headline-link" href="#conclusion" aria-hidden="true"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;We explored the basics of Internet Protocol and its versions. Along the way, the article elucidates the addressing schema, packet format, functioning of the IPv4 and IPv6 with comparative analysis. Though IPv4 is carrying the majority of Internet traffic today, IPv6 is the future of the networking world.&lt;/p&gt;</content:encoded><media:content url="https://linuxize.com/post/ip4-vs-ip6/featured_hu_6f716468b3bbcedf.webp" medium="image" type="image/webp" width="1200" height="675"/></item><item><title>How to Reverse a String in Python</title><link>https://linuxize.com/post/python-reverse-string/</link><pubDate>Sun, 01 Aug 2021 12:31:00 +0100</pubDate><author>hello@linuxize.com (Linuxize)</author><guid>https://linuxize.com/post/python-reverse-string/</guid><category>python</category><description>This article goes through several different ways to reverse a string in Python.</description><content:encoded>&lt;p&gt;In Python, a string is a sequence of Unicode characters. Though Python supports numerous functions for string manipulation, it doesn&amp;rsquo;t have an inbuilt function or method explicitly designed to reverse the string.&lt;/p&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="sh"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;sh&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;span class="s1"&gt;&amp;#39;Linuxize&amp;#39;&lt;/span&gt;.reverse&lt;span class="o"&gt;()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="output"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;output&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;pre tabindex="0"&gt;&lt;code class="language-output" data-lang="output"&gt;Traceback (most recent call last):
File &amp;#34;&amp;lt;input&amp;gt;&amp;#34;, line 1, in &amp;lt;module&amp;gt;
AttributeError: &amp;#39;str&amp;#39; object has no attribute &amp;#39;reverse&amp;#39;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;String reversal is not a common operation in programming and is generally used is in coding interviews.&lt;/p&gt;
&lt;p&gt;This article goes through several different ways to reverse a string in Python.&lt;/p&gt;
&lt;h2 id="using-slicing"&gt;Using Slicing &lt;a class="headline-link" href="#using-slicing" aria-hidden="true"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Understanding how indexing works in Python is crucial for performing the String Slice operation. Generally, Index numbers are used to access specific characters within a string.&lt;/p&gt;
&lt;p&gt;There are two types of indexing; positive and negative indexing.&lt;/p&gt;
&lt;figure class='relative w-full'&gt;&lt;div class="relative block w-full mx-auto my-0"&gt;&lt;div class="block" style="aspect-ratio: 646 / 178"&gt;&lt;/div&gt;
&lt;div class="bg-gray-100 absolute inset-0 w-full h-full m-auto overflow-hidden "&gt;&lt;picture class="absolute inset-0 w-full h-full m-auto"&gt;
&lt;source
type="image/webp"
srcset="https://linuxize.com/post/python-reverse-string/indexing_hu_6e71b4e4a66f927.webp 480w, https://linuxize.com/post/python-reverse-string/indexing_hu_61797bf2799b6c11.webp 768w, https://linuxize.com/post/python-reverse-string/indexing_hu_c9e9092f2e6e7825.webp 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"&gt;
&lt;img class="absolute inset-0 w-full h-full m-auto object-cover " loading="lazy"
decoding="async"
src="https://linuxize.com/post/python-reverse-string/indexing_hu_ea62b329b4c91425.png"
srcset="https://linuxize.com/post/python-reverse-string/indexing_hu_def171ae0e66bc57.png 480w, https://linuxize.com/post/python-reverse-string/indexing_hu_ea62b329b4c91425.png 768w, https://linuxize.com/post/python-reverse-string/indexing_hu_2f07ac6f1af5fc3b.png 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"
width="768"
height="212"
alt="Using Slicing"&gt;
&lt;/picture&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/figure&gt;
&lt;p&gt;You can access the character &lt;code&gt;n&lt;/code&gt;, either through a positive index number of &lt;code&gt;2&lt;/code&gt; or through a negative index number of &lt;code&gt;-6&lt;/code&gt;:&lt;/p&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="sh"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;sh&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;&amp;gt;&amp;gt; print&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Linuxize&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;2&lt;span class="o"&gt;])&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="output"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;output&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;pre tabindex="0"&gt;&lt;code class="language-output" data-lang="output"&gt;n&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="sh"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;sh&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;&amp;gt;&amp;gt; print&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Linuxize&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;-6&lt;span class="o"&gt;])&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="output"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;output&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;pre tabindex="0"&gt;&lt;code class="language-output" data-lang="output"&gt;n&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;We can call out a range of characters from a string through a slicing technique. Slicing is the operation that extracts the sequence of a substring from the given string.&lt;/p&gt;
&lt;p&gt;Slice Syntax:&lt;/p&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="py"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300"&gt;py&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-py" data-lang="py"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;stop&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;step&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;The first argument specifies the index at which the extraction begins. When a negative index is used, it indicates an offset from the end of the string. If this argument is omitted, slicing starts from index 0.&lt;/li&gt;
&lt;li&gt;The second argument specifies the index before which to end extraction; the result doesn’t include the &lt;code&gt;stop&lt;/code&gt; element. When a negative index is used, it indicates an offset from the end of the string. If this argument is omitted or greater than the length of the string, slicing goes to the end of the string.&lt;/li&gt;
&lt;li&gt;The third argument is optional and specifies the step of the slicing. When the &lt;code&gt;step&lt;/code&gt; argument is not used, it defaults to 1. When a negative value is used, the slice takes elements in reverse order.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The result of slicing a string is a new string containing the extracted elements, and the original string is not modified.&lt;/p&gt;
&lt;p&gt;To reverse a string using slicing, omit the &lt;code&gt;start&lt;/code&gt; and &lt;code&gt;stop&lt;/code&gt; arguments and use a negative step increment of &lt;code&gt;-1&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The negative step increment of &lt;code&gt;-1&lt;/code&gt; means that the slicing starts at the last element and ends at the first element, resulting in a reversed string.&lt;/p&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="sh"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;sh&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-sh" data-lang="sh"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&amp;gt;&amp;gt;&amp;gt; print&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;Linuxize&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;::-1&lt;span class="o"&gt;])&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="output"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;output&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;pre tabindex="0"&gt;&lt;code class="language-output" data-lang="output"&gt;ezixuniL&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;You can also define a custom function and use it to reverse strings:&lt;/p&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="py"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300"&gt;py&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-py" data-lang="py"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;rev_str_thru_slicing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;str_&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;str_&lt;/span&gt;&lt;span class="p"&gt;[::&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;INPUT_STRING&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;Linuxize&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vm"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;__main__&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;INPUT STRING -&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;INPUT_STRING&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;REVERSED STRING -&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rev_str_thru_slicing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;INPUT_STRING&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="output"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;output&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;pre tabindex="0"&gt;&lt;code class="language-output" data-lang="output"&gt;Input String - Linuxize
Reversed String using Slicing - ezixuniL&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="using-reversed-function"&gt;Using &lt;code&gt;reversed()&lt;/code&gt; Function &lt;a class="headline-link" href="#using-reversed-function" aria-hidden="true"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The built-in &lt;code&gt;reserved()&lt;/code&gt; function process the string items in reverse order and returns a reversed iterator.&lt;/p&gt;
&lt;p&gt;In the example below, the reversed iterator&amp;rsquo;s elements are added to an empty string using the &lt;code&gt;join()&lt;/code&gt; operator:&lt;/p&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="py"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300"&gt;py&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-py" data-lang="py"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;rev_str_thru_join_revd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;STR&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;&amp;#34;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;reversed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;STR&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;INPUT_STRING&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;Linuxize&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vm"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;__main__&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;INPUT STRING -&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;INPUT_STRING&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;RESERVED STRING THROUGH JOIN &amp;amp; REVERSED&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rev_str_thru_join_revd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;INPUT_STRING&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="output"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;output&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;pre tabindex="0"&gt;&lt;code class="language-output" data-lang="output"&gt;Input String - Linuxize
Reserved String Through Join &amp;amp; Reserved Methods - ezixuniL&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="using-list-reverse"&gt;Using List &lt;code&gt;reverse()&lt;/code&gt; &lt;a class="headline-link" href="#using-list-reverse" aria-hidden="true"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To reverse a string with the &lt;a href="https://linuxize.com/post/python-list/"&gt;list&lt;/a&gt;
&lt;code&gt;reverse()&lt;/code&gt; method, first, the string needs to be converted to a list using the &lt;code&gt;list&lt;/code&gt; constructor. Then the list items are reversed in place with the &lt;code&gt;reverse()&lt;/code&gt; method, and finally, the list items are joined into a string using the &lt;code&gt;join()&lt;/code&gt; method.&lt;/p&gt;
&lt;p&gt;Here is an example:&lt;/p&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="py"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300"&gt;py&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-py" data-lang="py"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;rev_str_thru_list_reverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;STR&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;lst&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;list&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;STR&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;reverse&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lst&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;INPUT_STRING&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;Linuxize&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vm"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;__main__&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;Input String -&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;INPUT_STRING&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;Reserved String Through List&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rev_str_thru_list_reverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;INPUT_STRING&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="output"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-gray-200 text-gray-700 dark:bg-slate-600 dark:text-slate-300"&gt;output&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;pre tabindex="0"&gt;&lt;code class="language-output" data-lang="output"&gt;Input String - Linuxize
Reserved String Through List Reverse Method - ezixuniL&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;h2 id="using-recursive-function"&gt;Using Recursive Function &lt;a class="headline-link" href="#using-recursive-function" aria-hidden="true"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In Python, a recursive function is a function that calls itself until some condition is met.&lt;/p&gt;
&lt;p&gt;In the code snippet below, the &lt;code&gt;rev_str_thru_recursion&lt;/code&gt; function calls itself until the string length is greater than zero. On each call, the string is sliced, leaving only the first character. Later on, it is concatenated with the sliced characters.&lt;/p&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="py"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300"&gt;py&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-py" data-lang="py"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;rev_str_thru_recursion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;STR&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;STR&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;STR&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;rev_str_thru_recursion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;STR&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:])&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;STR&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="n"&gt;INPUT_STRING&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;Linuxize&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vm"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;__main__&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;INPUT STRING -&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;INPUT_STRING&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;#34;RESERVED STRING THROUGH RECURSION&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;rev_str_thru_recursion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;INPUT_STRING&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h2 id="comparative-analysis"&gt;Comparative Analysis &lt;a class="headline-link" href="#comparative-analysis" aria-hidden="true"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In this section, we&amp;rsquo;ll perform a simple comparison between these four defined methods to identify their efficiency. We&amp;rsquo;ll analyze the performance using a Python module called &amp;ldquo;timeit&amp;rdquo;. It provides the time taken for the execution of the code snippets. &amp;ldquo;repeat&amp;rdquo; option of the &amp;ldquo;timeit&amp;rdquo; module helps to repeat the code execution one million times.
We can comprehend the output as an average time taken by executing the code snippet one million times.&lt;/p&gt;
&lt;div class="mt-0 border-t border-b border-gray-300 dark:border-slate-800 overflow-hidden relative"&gt;
&lt;div class="overflow-y-auto scrollbar-w-2 scrollbar-track-gray-lighter scrollbar-thumb-rounded scrollbar-thumb-gray scrolling-touch"&gt;
&lt;table class="w-full text-left table-collapse"&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Methods&lt;/th&gt;
&lt;th&gt;Execution Time&lt;/th&gt;
&lt;th&gt;Comparison Ratio Calc.&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Slicing&lt;/td&gt;
&lt;td&gt;0.23&lt;/td&gt;
&lt;td&gt;1x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;List Reverse&lt;/td&gt;
&lt;td&gt;1.63&lt;/td&gt;
&lt;td&gt;7x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Join &amp;amp; Reserved&lt;/td&gt;
&lt;td&gt;1.73&lt;/td&gt;
&lt;td&gt;7.5x&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recursion&lt;/td&gt;
&lt;td&gt;19.19&lt;/td&gt;
&lt;td&gt;83x&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The table above shows that the Slicing method is seven times faster than the List Reverse approach, 7.5 times faster than the Join &amp;amp; Reserved approach, and 83 times faster than the recursion approach. So Slicing is the quickest and best way to reverse the string.&lt;/p&gt;
&lt;figure class='relative w-full'&gt;&lt;div class="relative block w-full mx-auto my-0"&gt;&lt;div class="block" style="aspect-ratio: 542 / 396"&gt;&lt;/div&gt;
&lt;div class="bg-gray-100 absolute inset-0 w-full h-full m-auto overflow-hidden "&gt;&lt;picture class="absolute inset-0 w-full h-full m-auto"&gt;
&lt;source
type="image/webp"
srcset="https://linuxize.com/post/python-reverse-string/comparative-analysis_hu_b24a2306c79b4d5c.webp 480w, https://linuxize.com/post/python-reverse-string/comparative-analysis_hu_389f95de74d631d9.webp 768w, https://linuxize.com/post/python-reverse-string/comparative-analysis_hu_2115105610abf0d6.webp 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"&gt;
&lt;img class="absolute inset-0 w-full h-full m-auto object-cover " loading="lazy"
decoding="async"
src="https://linuxize.com/post/python-reverse-string/comparative-analysis_hu_6f952e3865f34a75.png"
srcset="https://linuxize.com/post/python-reverse-string/comparative-analysis_hu_f87f1fc86253bf23.png 480w, https://linuxize.com/post/python-reverse-string/comparative-analysis_hu_6f952e3865f34a75.png 768w, https://linuxize.com/post/python-reverse-string/comparative-analysis_hu_da19b82f75f7b61b.png 1200w"
sizes="(max-width: 480px) 480px, (max-width: 768px) 768px, 1200px"
width="768"
height="561"
alt="Comparative Analysis"&gt;
&lt;/picture&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/figure&gt;
&lt;div class="note callout callout-info"&gt;
&lt;div class="callout-header"&gt;&lt;svg role="img" aria-hidden="true" class="callout-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" &gt;
&lt;path d="M 16 3 C 8.832031 3 3 8.832031 3 16 C 3 23.167969 8.832031 29 16 29 C 23.167969 29 29 23.167969 29 16 C 29 8.832031 23.167969 3 16 3 Z M 16 5 C 22.085938 5 27 9.914063 27 16 C 27 22.085938 22.085938 27 16 27 C 9.914063 27 5 22.085938 5 16 C 5 9.914063 9.914063 5 16 5 Z M 15 10 L 15 12 L 17 12 L 17 10 Z M 15 14 L 15 22 L 17 22 L 17 14 Z "&gt;&lt;/path&gt;
&lt;/svg&gt;&lt;span class="callout-title"&gt;Info&lt;/span&gt;&lt;/div&gt;
&lt;div class="callout-body"&gt;The above results are the comparative analysis of discussed methods to reverse the string in the same environment. Numbers might vary in different computing environments, but the ratio will probably remain the same.&lt;/div&gt;
&lt;/div&gt;
&lt;div class="code-block relative my-4 rounded-lg overflow-hidden border border-gray-200 dark:border-slate-700" data-lang="py"&gt;
&lt;div class="code-header flex items-center justify-between px-4 py-2 bg-gray-50 dark:bg-slate-800/80 border-b border-gray-200 dark:border-slate-700"&gt;
&lt;div class="flex items-center gap-2"&gt;&lt;svg class="w-4 h-4 text-gray-500 dark:text-slate-400" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"&gt;
&lt;path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"&gt;&lt;/path&gt;
&lt;polyline points="14 2 14 8 20 8"&gt;&lt;/polyline&gt;
&lt;/svg&gt;&lt;span class="px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-700 dark:bg-blue-900 dark:text-blue-300"&gt;py&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="highlight"&gt;&lt;pre tabindex="0" class="chroma"&gt;&lt;code class="language-py" data-lang="py"&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="vm"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s2"&gt;&amp;#34;__main__&amp;#34;&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="c1"&gt;## Performance Calculation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;timeit&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;statistics&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;mean&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;INPUT_STRING&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;repeatCount&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;SLICING_PERF&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;timeit&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rev_str_thru_slicing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repeat&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;repeatCount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SLICING_PERF&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SLICING_PERF&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;SLICING_PERF&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;SLICING_PERF&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;J_R_PERF&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;timeit&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rev_str_thru_join_revd&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repeat&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;repeatCount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;J_R_PERF&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;J_R_PERF&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;J_R_PERF&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;J_R_PERF&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;LIST_PERF&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;timeit&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rev_str_thru_list_reverse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repeat&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;repeatCount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LIST_PERF&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LIST_PERF&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;LIST_PERF&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;LIST_PERF&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="n"&gt;RECUR_PERF&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;timeit&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rev_str_thru_recursion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;repeat&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;repeatCount&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class="line"&gt;&lt;span class="cl"&gt; &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RECUR_PERF&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RECUR_PERF&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nb"&gt;max&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;RECUR_PERF&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;RECUR_PERF&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;h2 id="conclusion"&gt;Conclusion &lt;a class="headline-link" href="#conclusion" aria-hidden="true"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Python doesn&amp;rsquo;t have any built-in functions to reverse the string, but we can use other methodsto reverse the string. The regression test analysis showed that the slicing method is the fastest way to reverse a string.&lt;/p&gt;</content:encoded><media:content url="https://linuxize.com/post/python-reverse-string/featured_hu_3bd7ac0b23a4fed1.webp" medium="image" type="image/webp" width="1200" height="675"/></item></channel></rss>