Routing is the process of deciding where to send something should go to next, based on where it is trying to reach. A router (or routing system) looks at the destination, checks a set of rules, and forwards the item along the best matching path.
A simple analogy
Think of a postal sorting office. A letter arrives with an address, and the clerk checks the rules ("anything for this postcode goes to that truck") and sends it on. No single clerk needs to know about the whole journey, only the next step. Routing in computing works the same way.
The two main kinds
1. Network routing: moving data packets between the networks.
- Each packet carries a destination IP address.
- A router checks its routing table and forwards these packet to the next hop, such as another router or the final machine.
- This is how the data crosses your home network, your ISP, and the internet to reach a server.
- If no specific rule matches, a default route sends the packet to a general gateway.
2. Application (URL) routing: moving web requests to the right code.
- The destination is a URL such as '
/orders/42'. - A routing system matches that URL pattern to a specific handler, such as a function, controller, or page.
- This is how the one web application serves many different pages and API endpoints.
Request: GET /orders/42
Rule: /orders/{id} -> OrdersController.Details(id)
Result: Details(42) runs
The core parts
| Part | What it is |
|---|---|
| Destination | The address, IP or URL, the item is heading to |
| Rules / table | The list of patterns and where each one leads |
| Matching | Picking the best rule, usually the most specific one |
| Next hop / handler | Where the item is sent, a router or a piece of code |
| Default | A fallback for anything with no matching rule |
Why we need it
- Scale: The senders don't need to know every path to every destination.
- Flexibility: you can change where the traffic goes by editing a rule, not every sender.
- Control and security: you can force traffic through a firewall or block certain paths.
- Clean design: web URLs stay readable and independent of how the code is organized.
- Efficiency: traffic takes the best available path.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.