/IPv6 Client , IPv4 Server Interoperability

IPv6 Client , IPv4 Server Interoperability

Just in case you conflicted this topic with the previous one ( IPv4 Client and IPv6 Server Interopertability )…. Well guess u knew the difference 🙂 this is the opposite operation of the previous post..And it would be preferred if you read the previous article before this one 🙂
Alright Let’s get to the points..
Here we have an IPv6 Client on a dual-stack host ,  an IPv4 Server on an IPv4 only host which has a listening socket.
the IPv6 client starts and calls getaddrinfo* to get the IPv6 addresses, since the server is IPv4 only host. IPv4-mapped IPv6 address is returned to the IPv6 client..
then the IPv6 client asks to connect with the IPv4-mapped IPv6 address. so the kernel detects that IPv4-mapped IPv6 and sends and IPv4 SYN to the server.
and finally the server responds with and IPv4 SYN and ACK  to the client and the connection is established..
to illustrate the interoperability this is what happens to the server in any connection type :-

  1. TCP IPv4 Client connects using IPv4 address or a  UDP IPv4 Client sends a datagram using IPv4 address. the traditional operation happens.
  2. TCP IPv6 Client connects using IPv6 address or a  UDP IPv6 Client sends a datagram using IPv6 address. also the traditional operation happens.
  3. TCP IPv6 Client connects using IPv4-mapped IPv6 address or a UDP IPv6 Client sends a datagram using IPv4-mapped IPv6 address. the kernel detects the mapped addresses and sends IPv4 packets instead of IPv6
  4. IPv4 client cannot connect using IPv6 because the IPv4 is less long than IPv6 which means you cannot map an IPv6 into IPv4

 
————————-
getaddrinfo(hostname, serviceName, passedAddressInfo, resultAdressInfo): this is a C system call which gets info for a specific host which is looked up by host name and service name might be passed as value or NULL and PassedAdressInfo is an addrinfo structure which is passed which represent flags and info about the service like ( Protocol , family, Socket type..etc) and resultAddressInfo (addrinfo structure) is the returned with more info about the host like the canonical name..