Like address labels for your physical mail, the labels for your digital packets follow a predetermined format as well. Currently, there are two standards in use: IPv4 and IPv6. In this article, we will briefly cover where these standards come from and why there are two. We’ll also look at what this means for you as you create and build using NetBurner.
What is the Internet Protocol (IP)?
Before we begin, let’s define some terms so that we can make sure we’re all on the same page.
First, a protocol is simply a set of rules that governs how things should happen. For the purposes of this article, we care about what’s called the Internet Protocol (IP). This defines how connected devices “talk” to one another. It covers things like how data packets should be addressed (and therefore identified), how packets should be routed to get from Point A to Point B, and so on.
Sometimes you’ll see the term TCP/IP or similar bandied about on the internet. IP determines how packets are addressed and transported. However, they can be handled in many different ways once they reach their destination. One of the protocols that governs this is TCP (hence TCP/IP), and less commonly UDP (UDP/IP).
What are IP Addresses?
Any device that connects to a network using the Internet Protocol (IP) for communication gets a unique identifier. This identifier is called the IP address. Ideally, each device gets a unique address so that you can tell one device from another. The IP address, as you can imagine, is used to make sure that data “addressed” to you gets delivered to you and data that is “addressed” to your neighbor goes to your neighbor (and not you).
The IP address also provides information about the device’s location in the network. This helps determine the right path for data packets to take when being routed from Point A to Point B.
IPv4 vs. IPv6
There are two types of IP addresses:
- IPv4 (whose name comes from the fact that its format was defined in the Internet Protocol version 4 document…very creative, we know)
- IPv6 (which was defined in *drumroll* Internet Protocol version 6), created to handle the problem of IPv4 not allowing a sufficient number of unique IP addresses
When looking at IP addresses, you’re most likely familiar with IPv4. These are 32-bit numbers that look something like 188.8.131.52. IPv4 addresses feature four individual values and each value only allows eight bits. This means that such addresses can only range from 0.0.0.0 to 255.255.255.255. However, as the internet has exploded, the need for unique IP addresses now exceeds the number of addresses available.
And that’s why we have IPv6.
Since the mid-2000s, the deployment of IPv6 addresses has been ongoing. These addresses are 128-bit numbers that are slightly less readable to end-users: 2001:db8:0:1234:0:567:8:1. To take a look at how this impacts the packet structure, checkout the headers for IPv4 and IPv6.
Reserved IP Addresses
Not all of the IP addresses possible are available. There are a select few set aside for special purposes which you should be aware of. Its poor form to step on toes by attempting to assign and use an unavailable IPv4 or IPv6 address. Also, it just doesn’t work.
You’ll notice that a lot of the reserved addresses are “private” addresses. This means that they are used internally behind a router and aren’t a part of the public sphere. For example, the IPv4 addresses from 10.0.0.0 to 10.255.255.255 and from 192.168.0.0 to 192.168.255.255 are used only for local communications. In IPv6, the analogous address block is fc00::/7 (which begins with fc00:: and ends with fdff:ffff:ffff:ffff:ffff:ffff:ffff:ffff).
What does all of this mean for you?
As you can imagine, there are some compatibility issues when it comes to working with devices that expect IPv4 addresses and devices that expect IPv6 addresses. How does something expecting one type “talk” to one that expects the other type?
First, you should know that there are two ways to “store” an IPv4 address so that it features an IPv6 structure (the latter of which is “seen” by the networking devices):
Mapped addresses allow the utilization of IPv6 services across IPv4 infrastructure and rely on stateless address mappings between IPv4 and IPv6 to transmit IPv4 packets. In short, everybody involved knows that the packets are IPv4, but they have a corresponding (or “mapped” address) that allows the incompatible technologies to work together.
In other words, IPv4 addresses are stored as mapped addresses. You can think of mapped addresses as a way to store an IPv4 address in an IPv6 object. Such addresses are never meant to be seen in its original IPv6 format when being translated over a network.
This method creates what you could call a “dual-mode stack.” The devices in question should send IPv4 packets when communicating with an IPv4 device and send IPv6 packets when communicating with an IPv6 device.
IPv4-formatted addresses (e.g., a.b.c.d) are translated to :ffff:0:a.b.c.d, which refers to an IPv6-enabled node.
Translated addresses are useful if you are working with an IPv6 host that does not have an IPv4 stack. These allow you to facilitate communication between the host and an IPv4 device by translating IPv4 addresses and packets to their IPv6 analogues.
Reserved Address Blocks for Mapped and Translated Addresses
Note that IPv6 features specific address blocks reserved to indicate both mapped and translated addresses.
IPv4 Mapped Addresses
IPv6 Translated Addresses
How NetBurner Handles IPv4 and IPv6 Interoperability
NetBurner uses mapped addresses to make sure that it can handle both IPv4 and IPv6 addresses. This ensures that devices for either type can communicate with one another seamlessly.
NetBurner, set to IPv6 mode, will operate identically to the NetBurner that’s been set to IPv4 mode when handling IPv4 traffic. That is, if all of the addresses you provide to NetBurner are formatted as IPv4 addresses, it will issue and send IPv4 packets. If any manipulations of the IP addresses are needed, NetBurner handles this with the included IPADDR class.
For Users Migrating from an Older Version of the NetBurner Network Development Kit (NNDK)
If you are using an older version of the NetBurner Network Development Kit (NNDK) and you plan to migrate to a more recent version, there are several considerations that you should be aware of:
- The internal storage of IPADDR has been expanded from 32 bits to 128 bits. If you have designed your own binary-formatted structures that contain IP addresses, you must change their declaration to be IPADDR4 for these structures to be backward compatible.
- NetBurner handles all standard IPv6 link and prefix discovery in the background.
- If you receive IPv6-formatted packets (UDP, TCP, and so on), the printout of the associated addresses may be larger than you expect. Be sure to account for this if your application interfaces and the like are expecting addresses to be of a certain size. Otherwise, you may find that the addresses aren’t displayed correctly.
- You can choose to send both TCP and UDP traffic to devices that have IPv6 addresses. Regardless of whether the IPv6 address comes from DNS or input text, NetBurner knows how to handle these packets.
The TL;DR? Here are the code changes you will need to make:
- IPADDR is now a C++ object instead of typdefed (a basic type), so to check for a null IP address use ip.IsNull() and ip.NotNull() (and not ip == 0).
- In your structure definitions, change your use of IPADDR to IPADDR4 for full backward compatibility with regard to binary structures.
- You don’t have to configure ANYTHING in IPv6 land to use IPv6 or IPv4. It will just happen (this is the magic of NetBurner at it’s finest! 🎉).
- Update any areas where you expect to input or output IP addresses to the user. This is so that it is capable of handling longer text strings.
IPv4 addresses are a familiar breed to most people, but there aren’t enough of these to go around. That’s why we have IPv6 addresses, a system that allows for a larger number of unique values. However, the adoption of IPv6 addresses hasn’t gone seamlessly. As a result, we have an environment where we use both IPv4 and IPv6 addresses.
The two types can’t be used interchangeably, so if you are expecting to work with packets with both types of addresses, there are extra design concerns you need to think about. However, NetBurner has done some of the heavy lifting on your behalf when it comes to writing applications that can utilize both IPv4 and IPv6 addresses.
As always, we’d love to hear any questions and comments you have on IPv4 vs IPv6. Please feel free to say something in the comments below or email us directly at firstname.lastname@example.org.