# IP forwarding algorithm
## Obiettivi di apprendimento

* review the definition and concept of an IP network
* understand that IP routing works on the level of IP networks
* understand the concept of subnetting
* review network classes and understand classless inter domain routing.

## Trascrizione

Internet Protocol Forwarding Algorithm
Let’s assume that you are connected to the Internet. You have a computer with IP Address 67.68.50.1 and this computer is in the 67.0.0.0-network (you can identify this from the 1-st number of IP Address as it’s an A-class). There is special computer in this network – the router with IP Address 67.68.50.13. This computer has 3 other network interfaces or network cards: - 62.206.17.3 (part of 62.0.0.0) - 88.41.79.55 (part of 88.0.0.0) - 141.71.30.6 (part of 141.71.0.0) We are interested in the 141.71.0.0 – network. Because this network has another router – 141.71.30.58. But as the first router it has other network devices which are connected to other networks. The network of particular interest is 205.34.55.0 – network which is a C-class network. In this network is a destination computer you want to send data later – 205.34.55.1.
Let’s see how we can forward data from 67.68.50.1-computer to 205.34.55.1-computer. What you need for this is IP routing and routing tables.
Wherever the package arrives at the router, the router needs to decide whether this package needs to stay at this network and be delivered to some host there or it has to be passed to the next network. In order to make this decision router maintains the routing table. Let’s look at 67.68.50.1-computer. It also has a routing table because each device on the Internet has to have a routing table:
| Destination network | next hop | interface |
| 67.0.0.0 | 67.68.50.1 | eth0 |
| 0.0.0.0 | 67.68.50.13 | eth0 |
The first entry says that the destination network is 67.0.0.0 and the entry for the next hop is device’s IP address and interface is Ethernet eth0 that is a network card for this device. The other entry has the destination network 0.0.0.0 that means that this is the default rout and the destination for the next hop will be 67.68.50.13. It means that whatever package is sent that is not for 67.0.0.0 network and what the computer will do is it will assemble an Ethernet frame that goes to 67.68.50.13-computer. These computers are in the same network so it’s obligatory to know the MAC Address of that computer (67.68.50.1). But there is another protocol – the Address resolution protocol that resolves this problem. But then computer can assemble an Ethernet frame and use the MAC Address of 67.68.50.13-computer and put it in the IP-package for other network that is supposed to be sent. All this will happen as the Internet protocol package inside the Ethernet package. Lets’ have a look at another routing table. We have a 67.68.50.13-computer and it has several network interfaces.
| Destination network | next hop | interface |
| 67.0.0.0 | 67.68.50.1 | eth0 |
| 62.0.0.0 | 62.209.17.3 | eth1 |
| 88.0.0.0 | 88.41.79.55 | eth2 |
| 141.71.0.0 | 141.71.30.6 | eth3 |
| 205.44.55.0 | 141.71.30.58 | eth3 |
| 26.0.0.0 | 141.71.30.58 | eth3 |
Here we have the entrance for the next hop to each network and the interface to send out data (for the first 4 entries). But what we also have is the address of some other networks. So if we have a package and it comes from the anywhere to the 26.0.0.0 – network, the routing table will say that the next stop will be 141.71.30.58 IP Address. We can see that computer can maintain the table for almost all networks that exist that’s why we need hierarchical classfull network addresses and can make routing decisions to forward packages. Let’s see an example.
67.68.50.1-computer’s routing table:
| Destination network | next hop | interface |
| 67.0.0.0 | 67.68.50.1 | eth0 |
| 0.0.0.0 | 67.68.50.13 | eth0 |
You have to send your package to 67.68.50.13-computer. So you do ARP request (Address Resolution Protocol) and the computer answers with it’s MAC Address. We assemble Ethernet frame and send it to that computer (67.68.50.13). Inside this frame you put an IP package and there is the source IP Address and the destination IP Address inside and of course the data. The computer starts to read the IP header and sees that this package is supposed to be send to 205.34.55.1-computer.
| Destination network | next hop | interface |
| 67.0.0.0 | 67.68.50.1 | eth0 |
| 62.0.0.0 | 62.209.17.3 | eth1 |
| 88.0.0.0 | 88.41.79.55 | eth2 |
| 141.71.0.0 | 141.71.30.6 | eth3 |
| 205.44.55.0 | 141.71.30.58 | eth3 |
| 26.0.0.0 | 141.71.30.58 | eth3 |
The computer looks inside his routing table and sees the entrance for 205.44.55.0. So it forwards package to the next stop - 141.71.30.58. The new Ethernet frame is assembled. The IP package doesn’t change but you exchange the Ethernet header. Again you forward package to the next computer. The next computer device receives the package and the network device with the 205.34.55.0 – network. So it already knows where to forward the package. It does the ARP request and the computer-destination can finally read the data. --Jane Kruch (discuss • contribs) 21:51, 2 November 2013 (UTC)

## Ulteriori letture

* IP Forwarding algorithm
* Address resolution protocol
* Routing Table
* Internet Protocol v4

## Discussioni

* Ethernet
** Communication over a shared Medium
** Ethernet header
** Minimum package length vs maximum cable length
** Collision detection
** Summary, further reading, homework
* Internet Protocol
** Motivation for IP
** Classful IPv4 networks
** IP forwarding algorithm
** IP header
** Summary, further reading, homework
* Transmission Control Protocol
** End to end principle and connection oriented communication
** Three way handshake
** Port numbers
** Sliding window and flow control
** Summary, further reading, homework
* Domain Name System
** Tree structure
** Terminology
** Zones
** Review some facts about DNS
** Delegating DNS queries
** DNS address resolution
** Summary, further reading, homework
* Internet vs World Wide Web
** Summary of the internet architecture
** Motivation and requirements for the World Wide Web
** Design principles of the web
** Uniform Resource Identifier
** Summary, further reading, homework
* Hypertext Transfer Protocol
** Making HTTP requests
** A simple web client
** A simple web server
** HTTP header
** Content negotiation
** Summary, further reading, homework
* Web content
** Problem setting for web content formats
** Working with XML
** HTML for web document structures
** Layout elements in HTML
** Motivating separation of content and layout
** Cascading Style Sheets
** Media content
** Metadata
** Summary, further reading, homework
* Dynamic Web Content
** Basics of server side web programming
** Forms and HTTP post request
** Handling a post request in a Java Servlet
** Client side JavaScript
** Ajax and the XMLHttpRequest class
** Summary, further reading, homework