MAP and LW4o6 Testing with CDRouter

Mapping of Address and Port (MAP) and Lightweight 4over6 (LW4o6) are IPv4-over-IPv6 transition technologies. They let a service provider run an IPv6-only access network while still giving its customers access to the IPv4 Internet, with many customers sharing each public IPv4 address. CDRouter supports all three variants:

  • MAP-E, Mapping of Address and Port with Encapsulation (RFC 7597)
  • MAP-T, Mapping of Address and Port using Translation (RFC 7599)
  • LW4o6, Lightweight 4over6 (RFC 7596)

Unlike DS-Lite, where the service provider performs NAT for all of its customers, MAP and LW4o6 keep NAT on the CPE. Each CPE translates its LAN traffic to a shared public IPv4 address and a restricted set of ports, so the service provider’s equipment needs to keep little or no per-customer state.

CDRouter simulates the service provider’s side of a MAP or LW4o6 network, so you can verify a CPE’s MAP or LW4o6 functionality and run CDRouter’s IPv4 tests through its MAP or LW4o6 connection. For an overview of all of the IPv6 WAN modes and transition technologies that CDRouter supports, see IPv6 WAN Modes and Transition Technologies.

How MAP works

A MAP network has two main elements:

  • The customer edge (CE) is the CPE. It has native IPv6 service on its WAN, and provides IPv4 service to clients on its LAN.
  • The Border Relay (BR) is in the service provider network, and connects the IPv6-only network to the IPv4 Internet.

All of the CEs and BRs that share the same configuration make up a MAP domain.

         User N
       Private IPv4
      |  Network
      |
   O--+---------------O
   |  | MAP CE        |
   | +-----+--------+ |
   | NAPT44|  MAP   | |
   | +-----+        | +-._   ,-------.                     .------.
   |       +--------+ |   ,-'         `-.                ,-'       `-.
   O------------------O  /              \   O---------O /   Public   \
                         /   IPv6-only   \  |  MAP    |/     IPv4     \
                        (    Network      --+  Border +-   Network     )
                         \  (MAP Domain) /  |  Relay  |\              /
   O------------------O  \              /   O---------O \             /
   |    MAP   CE      |   ;".         ,-'                `-.       ,-'
   | +-----+--------+ | ,"   `----+--'                      ------'
   | NAPT44|  MAP   | |,
   | +-----+        | +
   |   |   +--------+ |
   O---+--------------O
       |
         User M
       Private IPv4
         Network

When a LAN client sends an IPv4 packet to the Internet, the CE:

  1. Performs NAT (NAPT44), replacing the packet’s private source address and port with its public IPv4 address and a port from its allowed port set.
  2. Sends the packet across the IPv6-only network to the BR, either by encapsulating it in IPv6 (MAP-E) or by translating it to IPv6 (MAP-T).

The BR converts the packet back to IPv4 and forwards it to the IPv4 Internet. Traffic in the other direction follows the reverse path.

Because the CE’s public IPv4 address and port set are encoded in its IPv6 address, the BR can forward and validate MAP traffic without keeping any per-customer state.

Sharing IPv4 addresses with port sets

To share one public IPv4 address among several CEs, MAP gives each CE a different port set: a subset of the 65,536 TCP and UDP port numbers. Each port set is identified by a port set ID (PSID). The BR drops packets from a CE if their source port isn’t in that CE’s port set.

Three values define a CE’s port set (RFC 7597, Section 5.1):

  • The PSID offset (a bits) excludes the lowest port numbers from all port sets. An offset of 6, the RFC default, excludes ports 0-1023.
  • The PSID length (k bits) sets how many CEs share each IPv4 address. A PSID length of 8 lets 256 CEs share one address.
  • The PSID (k bits) identifies the CE’s port set.

In each port number, the PSID bits are fixed at a position set by the PSID offset:

                              0                   1
                              0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
                             +-----------+-----------+-------+
               Ports in      |     A     |    PSID   |   j   |
            the CE port set  |    > 0    |           |       |
                             +-----------+-----------+-------+
                             |  a bits   |  k bits   |m bits |

This gives each CE several small ranges of ports, spread across the port space, rather than one large range.

Because the PSID always sits in the same bits, the BR can check a packet’s source port with a simple bit mask, comparing it with the PSID encoded in the CE’s IPv6 address.

Mapping rules

Each CE derives its public IPv4 address and PSID from a set of mapping rules shared by every CE in the MAP domain, combined with an End-user IPv6 prefix that is unique to the CE. The End-user IPv6 prefix is usually the prefix delegated to the CE with DHCPv6 prefix delegation.

The Basic Mapping Rule (BMR) has three parts:

  • A rule IPv6 prefix, which contains the End-user IPv6 prefixes of all CEs in the domain
  • A rule IPv4 prefix, which contains the public IPv4 addresses shared by all CEs in the domain
  • An embedded address (EA) bit length, which is the number of bits in the End-user IPv6 prefix that follow the rule IPv6 prefix
   |     n bits         |  o bits   | s bits  |   128-n-o-s bits      |
   +--------------------+-----------+---------+-----------------------+
   |  Rule IPv6 prefix  |  EA bits  |subnet ID|     interface ID      |
   +--------------------+-----------+---------+-----------------------+
   |<---  End-user IPv6 prefix  --->|

The CE takes the EA bits from its End-user IPv6 prefix. It uses the first EA bits to complete its IPv4 address after the rule IPv4 prefix, and the remaining EA bits as its PSID. For example, with a /24 rule IPv4 prefix and 16 EA bits, the first 8 EA bits complete the IPv4 address and the last 8 EA bits are the PSID. See the example configuration below for a worked example.

The CE sends MAP traffic from a special IPv6 address in its End-user IPv6 prefix. The interface ID of this address contains the CE’s public IPv4 address and PSID, as defined in RFC 7597, Section 6:

                   |          128-n-o-s bits          |
                   | 16 bits|    32 bits     | 16 bits|
                   +--------+----------------+--------+
                   |   0    |  IPv4 address  |  PSID  |
                   +--------+----------------+--------+

MAP-T also uses a Default Mapping Rule (DMR), which is an IPv6 prefix used to represent IPv4 destinations outside the MAP domain (see below).

Forwarding Mapping Rules (FMRs) allow CEs in the same MAP domain to communicate directly, without going through the BR (“mesh mode”). CDRouter doesn’t currently support testing FMRs, so it expects all MAP traffic to go through the BR (“hub-and-spoke mode”).

The mapping rules can be configured on the CE manually, or provisioned with DHCPv6 options (RFC 7598).

Differences between MAP-E and MAP-T

MAP-E and MAP-T differ in how IPv4 packets cross the IPv6-only network:

MAP-E MAP-T
IPv4 packet Encapsulated: an IPv6 header is added in front of the IPv4 header Translated: the IPv4 header is replaced with an IPv6 header
IPv6 destination address The BR’s IPv6 address The IPv4 destination address, embedded in the DMR prefix
Mapping rules BMR BMR and DMR

In MAP-T, the original IPv4 header is removed, so the IPv4 destination address must be encoded in the IPv6 destination address. The CE embeds it in the DMR prefix, as defined in RFC 6052, Section 2.2:

    +--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    |PL| 0-------------32--40--48--56--64--72--80--88--96--104---------|
    +--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    |32|     prefix    |v4(32)         | u | suffix                    |
    +--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    |40|     prefix        |v4(24)     | u |(8)| suffix                |
    +--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    |48|     prefix            |v4(16) | u | (16)  | suffix            |
    +--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    |56|     prefix                |(8)| u |  v4(24)   | suffix        |
    +--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    |64|     prefix                    | u |   v4(32)      | suffix    |
    +--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
    |96|     prefix                                    |    v4(32)     |
    +--+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

For example, with a DMR of 4001::/48, a MAP-T CE sends packets for the IPv4 host 3.3.3.3 to the IPv6 address 4001::303:3:300:0:0. The service provider network recognizes these packets as MAP-T traffic because their destination is in the DMR prefix.

How LW4o6 works

From the CPE’s point of view, LW4o6 is similar to MAP-E. The CPE, called the lwB4, performs NAT using a shared public IPv4 address and a port set, then encapsulates IPv4 packets in IPv6 and sends them to the service provider’s lwAFTR.

The difference is in how the lwB4 learns its IPv4 address and port set. Instead of deriving them from mapping rules and EA bits, the lwB4 is provisioned with them directly, along with an IPv6 binding prefix that it uses to build its IPv6 source address. The lwAFTR keeps a binding for each subscriber, which maps the subscriber’s IPv4 address and port set to its IPv6 address.

In MAP terms, an LW4o6 configuration is a BMR with a full 32-bit IPv4 address and no EA bits.

How CDRouter simulates MAP and LW4o6

When MAP-E, MAP-T, or LW4o6 is enabled, CDRouter:

  • Brings up the DUT’s native IPv6 WAN connection, using the configured IPv6 WAN mode.
  • Doesn’t bring up an IPv4 connection on the WAN. All IPv4 traffic between the DUT and the WAN uses MAP or LW4o6.
  • Creates a MAP-E BR, MAP-T BR, or lwAFTR on the WAN. For MAP-E and LW4o6, the IPv6 address of the BR or lwAFTR is CDRouter’s WAN address, ipv6WanIspIp.
  • Provisions the DUT’s MAP or LW4o6 configuration using DHCPv6 options, if requested by the DUT.
  • Verifies that the DUT uses the expected IPv6 addresses, IPv4 address, and ports for its MAP or LW4o6 traffic.

CDRouter uses its MAP-E implementation to simulate LW4o6, and the same map testvars configure both. CDRouter simulates LW4o6 for a single CE, so some LW4o6-specific parameters, such as the lwB4’s IPv6 binding prefix, are less configurable than they would be in a real deployment.

CDRouter automatically skips tests that aren’t compatible with MAP or LW4o6.

Requirements

MAP and LW4o6 require the CDRouter IPv6 expansion, with IPv6 enabled.

MAP and LW4o6 run over a native IPv6 WAN connection, so ipv6WanMode must be set to one of the native IPv6 WAN modes: static, DHCP, autoconf, unnumbered, or PPPoE. The most common configuration is DHCP, with an End-user IPv6 prefix assigned by DHCPv6 prefix delegation.

CDRouter expects the DUT to get its End-user IPv6 prefix from DHCPv6 prefix delegation. Prefix delegation is enabled by default in all of the native IPv6 WAN modes except static. If the DUT uses a static IPv6 WAN address, enable prefix delegation with dhcpv6WanEnablePD, and configure the MAP or LW4o6 parameters on the DUT manually if it doesn’t request them with DHCPv6.

Configuring CDRouter

For complete configurations, see Example MAP-E and MAP-T configuration and Example LW4o6 configuration.

Enabling MAP-E, MAP-T, or LW4o6

MAP-E, MAP-T, and LW4o6 are IPv4 WAN modes. To enable one, set wanMode to MAP-E, MAP-T, or LW4o6:

testvar supportsIPv6  yes
testvar wanMode       MAP-T

End-user IPv6 prefix

Set the prefix that CDRouter delegates to the DUT with dhcpv6WanAssignPrefix and dhcpv6WanAssignPrefixLen. For MAP, this prefix must be within the BMR IPv6 prefix, and long enough to contain the EA bits. For more information, see DHCPv6 Prefix Delegation Testing with CDRouter.

MAP testvars

The following testvars configure MAP and LW4o6:

Testvar Default MAP-E MAP-T LW4o6 Description
mapBmrRuleIpv6Prefix 5002:db8:0:2ff:: ✔ ✔ ✔ BMR IPv6 prefix. For LW4o6, the lwB4’s IPv6 binding prefix.
mapBmrRuleIpv6PrefixLen 48 ✔ ✔ ✔ BMR IPv6 prefix length. For LW4o6, the binding prefix length.
mapBmrRuleIpv4Prefix 5.0.0.0 ✔ ✔ ✔ BMR IPv4 prefix. For LW4o6, the lwB4’s public IPv4 address.
mapBmrRuleIpv4PrefixLen 24 ✔ ✔ BMR IPv4 prefix length. LW4o6 always uses 32.
mapBmrRuleEABitLen 16 ✔ ✔ BMR EA bit length. LW4o6 always uses 0.
mapDmrIpv6Prefix 5001:db8:: ✔ DMR IPv6 prefix
mapDmrIpv6PrefixLen 48 ✔ DMR IPv6 prefix length: 32, 40, 48, 56, 64, or 96
mapSharingRatio 256 ✔ ✔ ✔ Number of CEs sharing each IPv4 address, which sets the PSID length
mapStartPort 4096 ✔ ✔ ✔ First port available to the CE, which sets the PSID offset
mapPsid 255 ✔ ✔ ✔ The CE’s expected PSID
mapIpv6InterfaceIdFormat rfc-7597 ✔ ✔ ✔ Format of the CE’s IPv6 interface ID
mapEnableDhcpv6Options yes ✔ ✔ ✔ Provision the DUT with DHCPv6 options
mapTunnelHopLimit 64 ✔ ✔ Expected IPv6 Hop Limit of tunneled packets
mapTunnelTrafficClass 0 ✔ ✔ Expected IPv6 Traffic Class of tunneled packets, or auto to expect it to be copied from the IPv4 Type of Service field
mapTunnelFlowLabel 0 ✔ ✔ Expected IPv6 Flow Label of tunneled packets
mapTosTranslate yes ✔ Whether the CE copies the IPv4 Type of Service field to the IPv6 Traffic Class field. Set to no if the CE sets the Traffic Class to zero.

Port set

CDRouter derives the PSID offset and PSID length from mapStartPort and mapSharingRatio:

PSID offset (a) = 16 - int(log2(mapStartPort))
PSID length (k) = log2(mapSharingRatio)

Both testvars should be powers of 2. For example, a mapStartPort of 1024 gives a PSID offset of 6, and a mapSharingRatio of 256 gives a PSID length of 8. Note that CDRouter’s default mapStartPort of 4096 gives a PSID offset of 4, rather than the RFC default of 6.

A mapStartPort of 0 gives a PSID offset of 0, so that each CE has a single contiguous range of ports.

mapPsid sets the CE’s expected PSID. It must be less than mapSharingRatio. For MAP, it must also match the PSID that the CE derives from its EA bits.

Public IPv4 address

Set wanIspAssignIp and wanNatIp to the public IPv4 address that should be assigned to the DUT’s WAN interface:

  • MAP: The address that the DUT will derive from the BMR IPv4 prefix and its EA bits.
  • LW4o6: The address set by mapBmrRuleIpv4Prefix.

Then set wanIspIp, the address of CDRouter’s WAN interface, to an address in the same IPv4 subnet.

IPv6 interface ID format

mapIpv6InterfaceIdFormat sets the format of the interface ID that the CE uses in its MAP or LW4o6 IPv6 source address:

  • rfc-7597 (default): the format defined in RFC 7597, Section 6
  • draft-03: the format defined in Section 6 of the earlier Internet-Draft draft-ietf-softwire-map-03, used by some older implementations

DHCPv6 provisioning

By default, CDRouter provisions the DUT’s MAP or LW4o6 configuration with DHCPv6 options (RFC 7598), based on the testvars above. CDRouter includes each option only if the DUT requests it in its DHCPv6 Option Request option:

WAN mode Container option Contents
MAP-E OPTION_S46_CONT_MAPE (94) OPTION_S46_BR (90), OPTION_S46_RULE (89)
MAP-T OPTION_S46_CONT_MAPT (95) OPTION_S46_DMR (91), OPTION_S46_RULE (89)
LW4o6 OPTION_S46_CONT_LW (96) OPTION_S46_BR (90), OPTION_S46_V4V6BIND (92)

The OPTION_S46_RULE and OPTION_S46_V4V6BIND options include an OPTION_S46_PORTPARAMS (93) option with the PSID offset, PSID length, and PSID. CDRouter also includes OPTION_S46_PRIORITY (111), defined in RFC 8026, to indicate which mechanism the DUT should use.

If the DUT’s MAP or LW4o6 parameters are configured manually, set mapEnableDhcpv6Options to no.

Example MAP-E and MAP-T configuration

In this example, the DUT uses DHCPv6 on the WAN, and CDRouter delegates the End-user IPv6 prefix 2001:db8:9597:8500::/56 to the DUT. The MAP domain uses:

  • A BMR with the IPv6 prefix 2001:db8:9500::/40, the IPv4 prefix 198.51.100.0/24, and 16 EA bits
  • A DMR of 4001::/48 (MAP-T only)
  • A sharing ratio of 256, with ports starting at 1024
# -- IPv6 WAN configuration
testvar supportsIPv6              yes
testvar ipv6WanMode               DHCP

# -- End-user IPv6 prefix (DHCPv6 prefix delegation)
testvar dhcpv6WanAssignPrefix     2001:db8:9597:8500::
testvar dhcpv6WanAssignPrefixLen  56

# -- IPv4 WAN configuration: MAP-E or MAP-T
testvar wanMode                   MAP-T
testvar wanIspIp                  198.51.100.1
testvar wanIspAssignIp            198.51.100.151
testvar wanNatIp                  198.51.100.151

# -- Basic Mapping Rule
testvar mapBmrRuleIpv6Prefix      2001:db8:9500::
testvar mapBmrRuleIpv6PrefixLen   40
testvar mapBmrRuleIpv4Prefix      198.51.100.0
testvar mapBmrRuleIpv4PrefixLen   24
testvar mapBmrRuleEABitLen        16

# -- Default Mapping Rule (MAP-T only)
testvar mapDmrIpv6Prefix          4001::
testvar mapDmrIpv6PrefixLen       48

# -- Port set
testvar mapSharingRatio           256
testvar mapStartPort              1024
testvar mapPsid                   133

testvar mapIpv6InterfaceIdFormat  rfc-7597

The DUT’s public IPv4 address and PSID come from the 16 EA bits in its End-user IPv6 prefix, which follow the 40-bit BMR IPv6 prefix:

End-user IPv6 prefix:  2001:0db8:95 | 97 85 | 00::/56
                       BMR prefix   | EA bits
                       (40 bits)    | (16 bits)
  • The BMR IPv4 prefix is a /24, so the first 8 EA bits (0x97, or 151) complete the DUT’s public IPv4 address: 198.51.100.151. This is the value of wanIspAssignIp and wanNatIp.
  • The remaining 8 EA bits (0x85, or 133) are the DUT’s PSID. This is the value of mapPsid.

With a start port of 1024 (PSID offset 6) and a sharing ratio of 256 (PSID length 8), each port set has 63 ranges of 4 ports. The DUT’s port set includes ports 1556-1559, 2580-2583, and so on, up to 65044-65047.

The DUT sends MAP traffic from the address 2001:db8:9597:8500:0:c633:6497:85, which is the first /64 of its End-user IPv6 prefix, followed by an interface ID containing its public IPv4 address (c633:6497) and PSID (85).

To test MAP-E instead of MAP-T, set wanMode to MAP-E. The DMR testvars aren’t used with MAP-E.

Example LW4o6 configuration

In this example, CDRouter provisions the DUT’s lwB4 with the public IPv4 address 198.51.100.151 and a binding prefix of 2001:db8:9500::/40, which contains the DUT’s delegated prefix.

# -- IPv6 WAN configuration
testvar supportsIPv6              yes
testvar ipv6WanMode               DHCP

# -- End-user IPv6 prefix (DHCPv6 prefix delegation)
testvar dhcpv6WanAssignPrefix     2001:db8:9597:8500::
testvar dhcpv6WanAssignPrefixLen  56

# -- IPv4 WAN configuration
testvar wanMode                   LW4o6
testvar wanIspIp                  198.51.100.1
testvar wanIspAssignIp            198.51.100.151
testvar wanNatIp                  198.51.100.151

# -- Binding prefix and IPv4 address
testvar mapBmrRuleIpv6Prefix      2001:db8:9500::
testvar mapBmrRuleIpv6PrefixLen   40
testvar mapBmrRuleIpv4Prefix      198.51.100.151

# -- Port set
testvar mapSharingRatio           256
testvar mapStartPort              0
testvar mapPsid                   133

testvar mapIpv6InterfaceIdFormat  rfc-7597

Since LW4o6 always uses a full 32-bit IPv4 address and no EA bits, mapBmrRuleIpv4PrefixLen and mapBmrRuleEABitLen are ignored.

This port set configuration gives the DUT a single contiguous range of 256 ports, as recommended in RFC 7596, Section 5.1. With a PSID of 133, the range is ports 34048-34303.

Address sharing is optional in LW4o6. To give the DUT its own IPv4 address with no port restrictions, set the sharing ratio to 1:

testvar mapSharingRatio           1
testvar mapStartPort              1
testvar mapPsid                   0

With a mapStartPort of 1, CDRouter omits the OPTION_S46_PORTPARAMS option from its DHCPv6 messages, which tells the DUT that it can use all ports.

MAP and LW4o6 test modules

The following test modules verify the DUT’s MAP and LW4o6 functionality:

  • mape, for MAP-E and LW4o6
  • mapt, for MAP-T

These modules verify that the DUT:

  • Encapsulates or translates outbound and inbound packets correctly
  • Uses only ports in its port set, and doesn’t send packets with an invalid source address
  • Sets the IPv6 Hop Limit, Traffic Class, Flow Label, and Next Header fields correctly
  • Handles fragmentation and the Don’t Fragment bit correctly
  • Handles ICMPv4 messages correctly

Many of CDRouter’s IPv4 test modules also run with MAP or LW4o6 enabled. Running them is a good way to check for problems caused by address sharing, restricted port sets, and fragmentation.

The following RFCs define MAP and LW4o6:

  • RFC 7596: Lightweight 4over6 (LW4o6)
  • RFC 7597: Mapping of Address and Port with Encapsulation (MAP-E)
  • RFC 7598: DHCPv6 Options for Configuration of Softwire Address and Port-Mapped Clients
  • RFC 7599: Mapping of Address and Port using Translation (MAP-T)
  • RFC 6052: IPv6 Addressing of IPv4/IPv6 Translators, which defines how IPv4 addresses are embedded in the DMR prefix
  • RFC 8026: Unified IPv4-in-IPv6 Softwire Customer Premises Equipment (CPE): A DHCPv6-Based Prioritization Mechanism