PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0
Showing posts with label ipv6. Show all posts
Showing posts with label ipv6. Show all posts

Saturday, October 22, 2022

[FIXED] How to support both IPv4 and IPv6 connections

 October 22, 2022     c++, ipv4, ipv6, sockets, winsock     No comments   

Issue

I'm currently working on a UDP socket application and I need to build in support so that IPV4 and IPV6 connections can send packets to a server.

I was hoping that someone could help me out and point me in the right direction; the majority of the documentation that I found was not complete. It'd also be helpful if you could point out any differences between Winsock and BSD sockets.

Thanks in advance!


Solution

The best approach is to create an IPv6 server socket that can also accept IPv4 connections. To do so, create a regular IPv6 socket, turn off the socket option IPV6_V6ONLY, bind it to the "any" address, and start receiving. IPv4 addresses will be presented as IPv6 addresses, in the IPv4-mapped format.

The major difference across systems is whether IPV6_V6ONLY is a) available, and b) turned on or off by default. It is turned off by default on Linux (i.e. allowing dual-stack sockets without setsockopt), and is turned on on most other systems.

In addition, the IPv6 stack on Windows XP doesn't support that option. In these cases, you will need to create two separate server sockets, and place them into select or into multiple threads.



Answered By - Martin v. Löwis
Answer Checked By - Timothy Miller (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg

Thursday, September 29, 2022

[FIXED] How to get a remote MAC address via IPv6 in iOS programmatically

 September 29, 2022     ios, ipv6, mac-address, network-programming, tvos     No comments   

Issue

I need to find a solution how to get the MAC address from the other device in the WiFi network. There is a good method how to do this for IPv4 (How does iOS app Fing get MAC Address?), but how to do this for IPv6? Since ARP was replaced by the NDP (Neighbour Discovery Protocol), the latter method doesn't work. I would greatly appreciate if anyone could help me.


Solution

Layer and Encapsulation

The network architecture is layered, the upper layer encapsulate the different implementations of lower layer and provide higher abstraction relative to lower layer. The network layer which use IP encapsulate different link layers protocols, like Ethernet, WiFi, PPP (which may run on serial cable which not use MAC address) etc.

  • So, the first problem is what do you mean by remote?

If you mean other hosts in WAN, it is impossible unless both device implement a specific protocol: you send a request to those device, they reply with his mac address.

If you mean other host in the same LAN, you can use ARP protocol in IPv4 and NDP (which ) in IPv6.

Arp & NDP

ARP send broadcast in LAN when it knows the IP address of a host but not MAC address, then the hosts which find someone is calling for him reply its MAC address.

NDP provides two main part of functionality, the first is the same with ARP: mapping between network- and link-layer addresses. (The difference is NDP using a multicast address: prefix f02::1:f/104, combined with the low-order 24 bits of the solicited IPv6 address)

So what you need is to send ICMPv6 Neighbor Solicitation message.

Address Assignment in IPv6

Link-local IPv6 addresses (and some global IPv6 addresses) use interface identifiers (IIDs) as a basis for unicast IPv6 address assignment. ... IIDs are ordinarily 64 bits long and are formed either directly from the underlyinglink-layer MAC address of a network interface using a modified EUI-64 format. or by another process that randomizes the value in hopes of providing some degree of privacy against address tracking.

So in the most common cases, you can get the MAC address of a device directly from their IPv6 link local address.

Conclusion:

  • implement your protocol in both devices
  • send NDP message to solicited node if it is in same LAN
  • extract MAC address from link local IPv6 address

Ref

  • Wikipedia
  • TCP/IP Illustrated, volume 1


Answered By - Tony
Answer Checked By - Cary Denson (PHPFixing Admin)
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Older Posts Home

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
All Comments
Atom
All Comments

Copyright © PHPFixing