Course contents

Unit 1: Enterprise designLesson 1.8 (5 of 5 in this unit)5 of 63 in the Advanced Cisco SD-WAN course

On-demand (dynamic) tunnels

Give spokes direct paths without a full mesh: how an on-demand tunnel is triggered and removed, the hub backup policy that makes it work, the commands that show its state, and the session count on a spoke.

Advanced · 20 min read

You'll learn to explain how on-demand tunnels give spokes direct paths without a full mesh, list the pieces a design needs, read the commands that show the state of a tunnel, and count the sessions a spoke holds.

Technical definition

On-demand tunnel is a spoke-to-spoke tunnel that is built only when traffic between the two spokes needs it and is removed after an idle period. Until then, the spokes have tunnels to the hubs only, and traffic between them takes the path through a hub.

Why not a full mesh everywhere?

The full-mesh lesson counted what a mesh costs: with two tunnels per pair of sites, each of 400 stores would hold 798 sessions, which does not fit the 500-session example limit used there. Hub-and-spoke fits easily, but every store-to-store transfer then crosses a hub. On-demand tunnels sit between the two. A spoke starts with tunnels to the hubs only, and it builds a direct tunnel to another spoke when the two start talking.

Diagram
Permanent tunnels against tunnels on demand
Permanent tunnels against tunnels on demand

With permanent tunnels, every spoke holds a tunnel to every other spoke whether or not they talk. With on-demand tunnels, a spoke holds tunnels to the hubs and builds a direct tunnel to another spoke only while traffic between them needs it.

Permanenta tunnel to everyother spoke
On demandhubs up all the time,spokes when needed
The tunnel count follows the traffic instead of the number of sites.
Diagram
Sessions on one store router, 400 stores (computed)
Sessions on one store router, 400 stores (computed)
DesignSessions on a store routerAgainst the 500-session example limit
Full mesh, 2 tunnels per pair798Over the limit
Hub-and-spoke with two hubs4Within the limit
On demand, 12 other spokes active28Within the limit
On demand, 120 other spokes active244Within the limit
Computed by script with two tunnels per pair of sites and two hubs. On demand adds two sessions for each other spoke that is active, on top of the four to the hubs. The 500-session limit is the invented example of the full-mesh lesson, and the real limit comes from the datasheet and release notes of the platform.

How an on-demand tunnel works

The Cisco documents read describe the behaviour. At first, only the BFD sessions from each spoke to the hubs are up. When traffic is sent between two spokes, the spokes build a tunnel and start BFD on it. After a period without traffic, the idle timeout, the tunnel and its BFD session are removed. A tunnel in the inactive state does not need BFD probes.

Diagram
The life of an on-demand tunnel
The life of an on-demand tunnel

Only tunnels to the hubs are up at first. Traffic between two spokes triggers a direct tunnel. BFD starts on the new tunnel and traffic uses it. When no traffic has used it for the idle timeout, the tunnel and its BFD session are removed and traffic goes through the hub again.

  1. Hub paths onlyspoke tunnels goto the hubs
  2. Interest trafficspoke A sendsto spoke B
  3. Direct tunnelbuilt, BFD starts,route becomes active
  4. Idle timeoutno traffic for thetimer value
  5. Removedtunnel and BFD go,hub path again
The default idle timeout in the documentation read is 10 minutes.

The route table shows the same story. The route to the other spoke is present all the time but is marked as inactive and unresolved until traffic arrives, and the route through the hub carries the traffic meanwhile.

Diagram
The route to the other spoke in each state
The route to the other spoke in each state
StateRoute learned through the hubRoute to the other spoke
Inactive, before trafficChosen, installed and resolvedInstalled, TLOC unresolved, on-demand inactive
Active, after trafficResolved, not chosenChosen, installed and resolved
After the idle timeoutChosen, installed and resolvedInstalled, TLOC unresolved, on-demand inactive
From the status codes in the Cisco troubleshooting document read: C, I and R for chosen, installed and resolved, U for unresolved, and IA for on-demand inactive. The pages do not describe the states while the tunnel is being built.

What the design has to provide

On-demand tunnels are not one switch. The documents read show four pieces that work together: a service on the hubs, path limits on the Controller, the on-demand setting on the spokes, and a control policy that gives the spokes a backup path through the hub. Leaving out one gives a spoke that has no path to another spoke at all, and the last case in this lesson shows one such failure.

Diagram
The four pieces
The four pieces

The hubs run a TE service in the transport VPN. The Controller advertises enough paths per prefix. The spokes have on-demand enabled with an idle timer. A control policy matches the on-demand spokes and sets the hub TLOCs as a backup.

  1. HubsTE service in the transport VPNConfigured on the hubs
  2. ControllerEnough paths advertised per prefixSend path limit and ECMP limit
  3. SpokesOn-demand enabled, idle timeout setApplied to the spoke sites only
  4. PolicyMatch the spoke site listHub TLOCs as backup
Each piece is checked on a different device.
Diagram
The pieces as the Cisco documents show them
The pieces as the Cisco documents show them
PieceWhereWhat the documents show
TE serviceHub, transport VPNService of type TE, in the transport VRF
Path limitsController and OMP settingsPaths advertised per prefix and ECMP limit set to 16, called recommended
On-demand settingSpokesOn-demand enabled, idle timeout of 10 minutes by default
Control policyController, applied to the spoke sitesMatch the spoke site list, accept, set the TLOC action to backup, point it at the hub TLOCs
One document uses the Manager feature templates and the other uses the command line, and the lab releases were 20.9.3 and 17.9.3. The pages state no minimum release and no range for the idle timeout, so check both for the release in use. The send path limit default is covered in the best-path lesson.

Reading the state of a tunnel

One command on a spoke shows the on-demand state of each remote site: whether on-demand applies to it, whether the tunnel is active, and how many seconds remain before the idle timer removes it. BR-01, site 101, has the hub and BR-02 as its remote systems in the example.

Example output written for this lesson, simplified; real output has more fields and a different layout
BR-01#show sdwan system on-demand remote-system
SITE-ID  SYSTEM-IP    ON-DEMAND  STATUS    IDLE-TIMEOUT-EXPIRY(sec)
10       10.255.1.1   no         -         -
102      10.255.2.2   yes        inactive  -
The hub is not an on-demand peer, so its tunnels stay up. BR-02 is an on-demand peer in the inactive state, so no tunnel exists to it and traffic for its prefixes goes through the hub. Real output has more fields and a different layout.

After BR-01 sends traffic toward a prefix behind BR-02, the same command shows the tunnel active, with a countdown that restarts while traffic keeps using it.

Example output written for this lesson, simplified; real output has more fields and a different layout
BR-01#show sdwan system on-demand remote-system
SITE-ID  SYSTEM-IP    ON-DEMAND  STATUS    IDLE-TIMEOUT-EXPIRY(sec)
10       10.255.1.1   no         -         -
102      10.255.2.2   yes        active    541
BR-02 is now active with 541 seconds left before the idle timer would remove the tunnel. A BFD session to 10.255.2.2 now exists, and it disappears again after the tunnel goes inactive. Real output has more fields and a different layout.

What it saves and what it does not change

The saving is on the spokes. A spoke holds the sessions to the hubs and two more for each other spoke that is active within the idle timeout, so its count follows how many different peers it talks to in a window and not the number of sites. What does not change is the hub, which holds its sessions with every spoke, and the need for a policy and a timer to be right.

Diagram
What on-demand tunnels leave unchanged
What on-demand tunnels leave unchanged

The hub keeps its sessions with every spoke. The first packets of a flow still follow the hub path. The design still needs the TE service, the path limits and the backup policy. A spoke that talks to many peers at once can still reach its own session limit.

Still true
  • Hub loadsessions with everyspoke remain
  • First packetstake the hub pathuntil the tunnel is up
  • Policybackup path throughthe hub is required
  • Busy spokesmany active peersstill add sessions
On-demand tunnels move the cost from sites to traffic patterns.
Diagram
Sessions on a spoke by number of active peers (computed)
Sessions on a spoke by number of active peers (computed)
Other spokes contacted within the idle timeoutSessions on the spokeAgainst the 500-session example limit
None4Within the limit
3 spokes10Within the limit
12 spokes28Within the limit
40 spokes84Within the limit
120 spokes244Within the limit
248 spokes500At the limit
300 spokes604Over the limit
Computed by script as four sessions to two hubs plus two per active peer. The limit of 500 is an invented example, and the pages read do not say what a platform does when the limit is reached, so test it in the lab. At that limit, a spoke can hold direct tunnels to at most 248 other spokes at once.

The table also shows how to use the idle timeout. A spoke that sends a report to a hundred branches once an hour builds up to a hundred tunnels within a few minutes, and a shorter timeout releases them sooner. A longer timeout keeps tunnels for a repeat transfer and costs sessions. The number to choose is the number of distinct peers in one timeout window at the busiest time.

A worked case: the spoke with no path to its neighbour

Priya enables on-demand tunnels for BR-01 and BR-02, two stores that exchange inventory files. A ping from BR-01 to a prefix behind BR-02 fails, and no tunnel is ever built. She looks at the route for the prefix on BR-01.

Example output written for this lesson, simplified; real output has more fields and a different layout
BR-01#show sdwan omp routes vpn 10 192.168.102.0/24
FROM PEER    TLOC IP      COLOR         STATUS
10.255.0.11  10.255.2.2   biz-internet  I,U,IA
Only the route to BR-02 itself is present, installed but unresolved and on-demand inactive. There is no backup route through the hub, so the first packet has nowhere to go, and with no packet there is no trigger for the tunnel. Real output has more fields and a different layout.

The hub backup comes from the control policy, and the policy applies to the sites in its site list. The list names site 101 and not site 102, so BR-02's routes were not given the hub as a backup. After site 102 is added to the list and the policy is pushed, the same command shows the hub routes.

Example output written for this lesson, simplified; real output has more fields and a different layout
BR-01#show sdwan omp routes vpn 10 192.168.102.0/24
FROM PEER    TLOC IP      COLOR         STATUS
10.255.0.11  10.255.1.1   mpls          C,I,R
10.255.0.11  10.255.1.1   biz-internet  C,I,R
10.255.0.11  10.255.2.2   biz-internet  I,U,IA
Now the hub routes are chosen, installed and resolved, and the BR-02 route is still inactive. The first ping goes through the hub, which triggers the direct tunnel, and the status of BR-02 in the on-demand command changes to active. Real output has more fields and a different layout.
Diagram
Checks in order when a spoke cannot reach another spoke
Checks in order when a spoke cannot reach another spoke
CheckResult in the caseWhat it says
Is the route to the other spoke present?Yes, inactiveRouting knows the prefix
Is a hub backup route present?NoThe policy did not reach this site
Does the policy's site list include both spokes?No, site 102 is missingThe fix is in the site list
Is on-demand enabled on both spokes, and the TE service on the hub?Check next if the list is rightEach missing piece gives the same symptom
The case follows the kind of fault the Cisco troubleshooting document walks through, such as the hub service or the spoke setting not being enabled. The explanation of this site-list case is reasoning from the policy, so confirm it in the lab.

Learn more: Full-Mesh Economics and Tunnel ScaleBest Path and Selection FactorsHub-and-Spoke versus Mesh

Test yourself

Predict · scenario 1

A spoke has two tunnels to each of two hubs and has contacted 12 other spokes within the idle timeout, with two sessions for each. How many sessions does it hold?

Predict · scenario 2

What starts the building of an on-demand tunnel between two spokes?

Predict · scenario 3

BR-01 shows the route to BR-02 as installed, unresolved and on-demand inactive, and there is no hub route for that prefix. What is the most likely gap?

Predict · scenario 4

What is the default idle timeout in the Cisco documentation read?

Predict · scenario 5

Where is the on-demand setting applied, according to the Cisco configuration steps?

Predict · scenario 6

A design moves from permanent spoke tunnels to on-demand tunnels. What happens to the number of sessions on each hub?

Predict · scenario 7

The example limit is 500 sessions, a spoke has four sessions to the hubs and two for each active peer. How many active peers reach the limit?

Predict · scenario 8

Which command shows whether the tunnel to each remote site is active and how long remains on its idle timer?

FAQ

What problem do on-demand tunnels solve?
They give spokes a direct path to each other without every spoke holding a tunnel to every other spoke. Cisco's documentation lists better performance on less powerful platforms in a full-mesh network, and lower latency between spokes in a hub-and-spoke network, as the benefits.
What triggers an on-demand tunnel?
Traffic between the two spokes. The documentation read says the tunnel is set up only when there is traffic between the two devices, and the test in it used a ping from one spoke to a prefix behind the other.
How long does an idle tunnel stay up?
The default idle timeout in the documentation read is 10 minutes, and the timeout can be configured. The pages did not state the valid range, so check the configuration guide for the release in use.
What happens to the first packets, before the tunnel exists?
They follow the backup path through the hub, because the policy gives the spokes the hub TLOCs as a backup. The pages read do not describe the transition in detail, so measure it in the lab if the first seconds of a flow matter.
Does an on-demand tunnel reduce the load on the hub?
It does not change the number of sessions the hub holds with its spokes, which stays at the number of spokes times the tunnels per spoke. It reduces the sessions on the spokes, and it can take traffic off the hub path once a direct tunnel is up.