Wiki DE Start in the browser

Wiki › Basics

How routing works

Default gateway, routing table, longest prefix and administrative distance – and when to route statically, automatically or dynamically.

Layer
3 (Vermittlung)
See an example
2 demos

In my own network or not?

Before a device sends, it compares the destination address with its own network (address and mask). If the destination is in the same network, it asks directly for the destination’s MAC via ARP. If it is elsewhere, it sends the packet to its default gateway, the router in its own network.

A ping to another network goes via the default gatewayA ping to another network goes via the default gateway
Slow motion A ping to another network goes via the default gateway

The routing table

A router decides for every packet by its routing table: for every destination network it lists the neighbour (next hop) or interface to use.

DestinationviaSource
192.168.1.0/24eth0directly connected
192.168.2.0/2410.0.0.2static
0.0.0.0/0203.0.113.1default route

If several entries match, the longest prefix (the most specific network) wins. On a tie the administrative distance decides: connected 0, static 1, eBGP 20, OSPF 110, RIP 120. Every router lowers the TTL by one; when it reaches zero, the router drops the packet and reports “TTL expired” (this is how tracert works).

Networks between routers: the transit network

The small network that links two routers is called a transit network in leyoNET. It contains no end devices, only the two router ports; a /30 with two usable addresses is therefore enough. The term follows RFC 2328: a transit network carries traffic that neither originates nor ends in it. Its counterpart is the stub network, a network with end devices and a single exit.

In practice and in textbooks you will meet other words for the same thing:

TermMeaningIn leyoNET
Transit networkIP network between routers, without end devicesused throughout
Transfer network (German «Transfernetz»)the same; common in German-speaking countries, but not found in any standardno longer used
Transport networkat carriers, the transmission network that carries customer signals; not an IP network between two routersnot used
Leased linethe permanently connected line of a provider between two sites, i.e. layers 1 and 2; the IP network on it is a transit networkonly for the line, see Serial lines: HDLC, PPP and PPPoE
Point-to-point networknetwork with exactly two members (RFC 2328); every /30 between two routers is oneas an explanation

Three ways to the table

  • Automatic (leyoNET only, for beginners): one tick at the router and it knows all networks in the plan.
  • Static: enter the routes by hand. Clear, but every change must be repeated on every router (Static routing).
  • Dynamic: routers exchange their networks themselves and react to failures: OSPF, RIP and RIPng, between organisations BGP.

How to do it in leyoNET

The same text as in the app’s help (F1 key).

Automatic routing

To get started: tick Automatic routing on the router (or layer 3 switch), on the right in the properties or in the Routing tab. The router then knows every network in the plan without entering any routes.

  • For each network it takes the path through the fewest routers. Neighbours are routers whose ports are in the same network (cable or switch in between, same subnet).
  • If a path leads to the internet (provider or internet box), a default route towards it is added.
  • In the routing table these routes are marked A (automatic). In design mode the Routing tab shows a preview.
  • If you shut down a port, automatic routing looks for another path if there is one.
  • Every router needs the tick itself: a router without a matching route drops the packet, even if the others route automatically.

This is a shortcut of the simulator, not a real protocol. In real networks, static routes or protocols such as OSPF and RIP do this job.

Without the tick you choose: - Static: enter every route by hand. - Dynamic: the routers exchange their networks using OSPF, RIP or BGP; static routes apply as well.

Routes and protocols you have entered stay saved when you switch. They are only inactive while another mode is chosen.

See an example

  • Default gateway

    Two subnets connected by a router.

    PC 1 sees that the target is in another network and sends the packet to its router. The TTL drops by one.

    Watch live Project file

  • Demo “Automatic routing” in leyoNETDemo “Automatic routing” in leyoNET
    Automatic routing

    Three routers, three networks and not a single route entered: automatic routing finds the paths by itself.

    «tracert» from PC A to PC C shows every router on the way. Untick one router: the destination can no longer be reached.

    Watch live Project file

“Watch live” opens the network in leyoNET, the simulation runs in a loop. In the app you find it under File → Demo networks, with a step-by-step tour.

Practise

  • ★★☆☆☆ Two networks with a router · 4 goals · Worksheet (German)
  • ★☆☆☆☆ Three routers, routed automatically · 3 goals · Worksheet (German)
  • ★★☆☆☆ UE04 Router02 – Task 1: one router connects Sursee and Zürich · 6 goals · Worksheet (German)

In leyoNET under Tools → Exercise catalogue. Every exercise checks itself.

Read on

Found a mistake or have an idea? Source of this page on GitHub.