How do ports work with IPv6? - tcp

Conventional IPv4 dotted quad notation separates the address from the port with a colon, as in this example of a webserver on the loopback interface:
127.0.0.1:80
but with IPv6 notation the address itself can contain colons. For example, this is the short form of the loopback address:
::1
How are ports (or their functional equivalent) expressed in a textual representation of an IPv6 address/port endpoint?

They work almost the same as today. However, be sure you include [] around your IP.
For example : http://[1fff:0:a88:85a3::ac1f]:8001/index.html
Wikipedia has a pretty good article about IPv6: http://en.wikipedia.org/wiki/IPv6#Addressing

The protocols used in IPv6 are the same as the protocols in IPv4. The only thing that changed between the two versions is the addressing scheme, DHCP [DHCPv6] and ICMP [ICMPv6]. So basically, anything TCP/UDP related, including the port range (0-65535) remains unchanged.
Edit: Port 0 is a reserved port in TCP but it does exist. See RFC793

Wikipedia points out that the syntax of an IPv6 address includes colons and has a short form preventing fixed-length parsing, and therefore you have to delimit the address portion with []. This completely avoids the odd parsing errors.
(Taken from an edit Peter Wone made to the original question.)

They're the same, aren't they? Now I'm losing confidence in myself but I really thought IPv6 was just an addressing change. TCP and UDP are still addressed as they are under IPv4.

I'm pretty certain that ports only have a part in tcp and udp. So it's exactly the same even if you use a new IP protocol

I would say the best reference is Format for Literal IPv6 Addresses in URL's where usage of [] is defined.
Also, if it is for programming and code, specifically Java, I would suggest this readsClass for Inet6Address java/net/URL definition where usage of Inet4 address in Inet6 connotation and other cases are presented in details. For my case, IPv4-mapped address Of the form::ffff:w.x.y.z, for IPv6 address is used to represent an IPv4 address also solved my problem. It allows the native program to use the same address data structure and also the same socket when communicating with both IPv4 and IPv6 nodes. This is the case on Amazon cloud Linux boxes default setup.

Related

Why my ip address starts with 192.?

i am from non networking background. I suddenly wondered why the companies i worked almost always had the ip's like 192.168.x.x . Why can't they have something like 1.2.3.4
I understand that ip has and there is a concept called subneting.
Also, 192.168.0.0 to 192.168.255.255 seems to used for private use.
Question:
1) How does IP address matters thought all devices are connected to internet through roughter?
Any wisdom pls?
According to RFC 1918, addresses in the 192.168.0.0-192.168.255.255 range are private. Such addresses can be used internally by any network so they're often used inside an organization. They cannot be used on the Internet since they aren't intended to be kept globally unique.
192.168.X.X isn't the only private range defined in the RFC. You might also run into 10.0.0.0 - 10.255.255.255 or 172.16.0.0 - 172.31.255.255
Most other addresses are public, and have to be assigned to the network by a Regional Internet Registrty (RIR).
Without knowing it, you might see a kind of playing around with symmetries and numbers of 1-Bits, it it is likely not by chance that they chose these binary subnet mask prefixes and a chosen number of 1-Bits and their slightly playful positions (in brackets: number of 1-Bits for each nibble of the subnet mask prefix, just my guess what might have been thought of, since these Bit patterns were “sacrificed” for private networks):
00001010 (=02): 10/8
11001100.0001 (=221): 172.16/12
11000000.10101000 (=2021): 192.168/16
10101001.11111110 (=2243): 169.254/16
Further links:
IPv4
CIDR - Classless Inter Domain Routing.
The many 1-Bits for just the automatic IPs might also be swiftly chosen.

Using the second Ethernet Port for TCP on a NI PXI with LABVIEW

I'm using a PXI 8109 running Pharlap OS.
I'm trying to use the second ethernet interface of my PXI to send UDP and TCP packets.
Here the configuration of my two ethernet interfaces:
eth0 (primary):
IP : 10.0.0.3
subnet mask : 255.0.0.0
eth1 :
IP : 192.168.10.9
subnet mask : 255.255.255.0
For UDP, I have no problems, packets are sent to the second interface as I want. I think it work because there is a "net address" input on the "UDP Open" VI so the system can choose the right interface.
For TCP, I use the "TCP Open connection" VI but there is no this kind of input. And it is not working : I assume the system is trying to use the primary interface but it can't route packets...
For information, my two networks are physically independant.
Can you help me finding out what's going on ? Is it possible to use TCP on the second ethernet interface ?
TCP open is meant to open a connection to another computer, if you feed a valid (in one of the two subnets) TCP address it should open a connection on that specific interface.
I assume you need to use the TCP listener function and according to this KB article, you can specify on which address you want to listen. So yes, you should be able to use a specific ethernet interface.
disclaimer: I am not sure if all this info is valid on Pharlap as well.
Basically, the decision which NIC to use is up to the OS and I believe that normally it would choose based on the subnet of the address you're trying to connect to and those of the NICs - I don't know what the IP address is (maybe it's in the subnet of the wrong card?), but the subnets of the NICs certainly appear to be different from each other (10.0.0.0 and 192...).
On Windows, I believe you can set the routing tables to have some more control of this (although I don't know if you would be able to force something to go through the "wrong" NIC), but I have no idea how much control you would have over this on Phar Lap. I would suggest some searching. Here are a couple of relevant links:
http://forums.ni.com/t5/LabVIEW/RT-How-do-I-use-two-independent-Ethernet-ports/td-p/721269
http://forums.ni.com/t5/LabVIEW/Communicating-through-two-ethernet-ports-on-the-same-computer/m-p/1509450#M565374
I finally solved my problem. This was not related to the TCP connection ...
I was using a property node "Value (signaling)" to trigger the TCP connection and it seems that this is not supported on RT Targets.
This is why it was working on localhost.
Thanks for the help anyway ;)

Multicast over layer 2

Pardon my limited knowledge in networks.
I am trying to setup two small programs as client and server, which join to a particular multicast group. The servers sends some arbitrary data to the group and the client receives the data as it listens to the group.
This of course is possible with UDP programs which I have already done. However I need to work with MAC addresses instead of IPs. And I have a few questions regarding this:
Is it possible to fix a range of MAC addresses for my multicast application ? As I understand, the least significant bit of the first octet in the MAC address signifies if it is multicast or not. So the multicast MAC should look like 01:*:*:*:*:* . So I guess, there should be some way to use a wide range of MAC addresses (except for those reserved).
Many places it is written as All multicast MAC addresses begin with: 0100.5e . Is it always true? AFAIK this prefix is fixed in the MAC address which leaves space for the rest of the IP address bits to be mapped here. But what if my application doesn't care about IP addresses and listens to multicast groups based on MAC addresses (if it is possible) ?.
Can't I keep the first octet as 01 and use a wide range for my multicast addressing ?
How to send packets to a multicast group and listen to a multicast group only based on MAC addresses and irrespective of IP ? i.e. the multicast group addresses are defined based on MACs.
I hope my questions made sense.
If you are not using IP (or UDP on top of that) then the default way of mapping IP addresses to mac addresses have probably no added value for you. These mappings are specified for example in:
http://en.wikipedia.org/wiki/IP_multicast#Layer_2_delivery
rfc1112 https://www.rfc-editor.org/rfc/rfc1112 paragraph 6.4
If you insist on using layer2 and multicasting it will probably be sufficient to send out frames with the LSB of the first octet set (the multicast bit, ref: http://en.wikipedia.org/wiki/File:MAC-48_Address.svg ). And put your own mapping on top of that. But you should take into account that:
you probably need to force your NIC to pass the data, often NIC's filter out frames they are interested in hardware. And these filters are typically set when joining a group or e.g. when setting the ALLMULTI flag).
There is probably networking equipment in the middle and some pseudo-intelligent switches may refuse to forward data unless they have seen IGMP joins (ref igmp snooping).
And you code will obviously need to deal with raw layer 2 sockets to read out the data.
Considering the ease of just using UDP this may be a lot of work.

Validating IPv6 netmask

Just as we have rules governing the validity of an IPv4 netmask, does IPv6 have its own set of rules to qualify a netmask?
Thanks!
What is your use case? Normally in IPv6 your addresses will be auto-generated from a /64 prefix your router provides.
You don't usually see a netmask written out in IPv6. Usually you will see a prefix length. For example:
2001:db8:0:160::/64
would have a netmask of
ffff:ffff:ffff:ffff::
But you would only ever see the former.
Technically the better answer may be that with IPv6 you no longer have a netmask. With IPv6 you have a "prefix length" which you can interpret as the number of 1 bits in an equivalent netmask.
Taking the concept of "prefix length" you no longer have to have "netmask rules", although there pretty much is only one: the netmask should consist of only left aligned contiguous 1 bits.

IPv4 and IPv6 In a Single Network Segment

I need someone to back me up, or prove me wrong, in regard to the comments I've made some time ago. Here is the original thread:
dual-stack ipv6/ipv4 on localhost
Basically, I'd like to know if we can have 2 different kinds of IP addresses (IPv4 and IPv6) running on the same network segment WITHOUT any address translation.
Thanks in advance!
Without any problems: IPv4 and IPv6 can share a transport layer such as Ethernet without causing problems. Furthermore, there are many systems that can support both v4 and v6 protocol stacks concurrently.
Of course, to get any communications going between IPv4 and IPv6 nodes, one must go through a gateway (e.g. 4to6).

Resources