Convert IPv4 to IPv6

Company: IBM_28thjuly

Difficulty: medium

Problem Statement

Convert IPv4 to IPv6 Every device on a computer network is identified by an Internet Protocol (IP) address. Two formats are in use: IPv4 addresses are 32 bits long and IPv6 addresses are 128 bits long. Newer devices speak IPv6, so an IPv4 address sometimes has to be rewritten in IPv6 form. An IPv4 address is written as four decimal numbers called octets, each between 0 and 255 , separated by dots, for example 192.168.10.92 . Convert it to IPv6 with these rules: Loopback addresses. If the first octet is 127 (an address of the form 127.x.x.x , whatever the other three octets are), the address is a loopback address and its IPv6 equivalent is ::1 . All other addresses. Write each octet as exactly two hexadecimal digits, using uppercase letters and a leading zero when the value is below 16 (so 10 becomes 0A and 92 becomes 5C ). Join the first two octets into one group of four digits and the last two octets into a second group of four digits. The IPv6 address is ::FFFF: followed by the first