RFC 1180
TCP/IP tutorial
Network Working Group π
RFC: 1180 π Authors: T. Socolofsky and C. Kale, from Spider Systems Limited π§ Date: January 1991 π Category: This one is a tutorial, not a standard. It doesn't specify an Internet standard πΈ Obsoletes/Updates: Nothing is listed in the title block, because there's no obsoletes or updates line on this one β¨
A TCP/IP Tutorial β¨
Status of this Memo π
This RFC is a tutorial on the TCP/IP protocol suite. It's especially focused on the steps for forwarding an IP datagram from a source host to a destination host through a router π¦ It does not specify an Internet standard. Distribution of this memo is unlimited π«Ά
Table of Contents ποΈ
1. Introduction................................................ 1
2. TCP/IP Overview............................................. 2
3. Ethernet.................................................... 8
4. ARP......................................................... 9
5. Internet Protocol........................................... 12
6. User Datagram Protocol...................................... 22
7. Transmission Control Protocol............................... 24
8. Network Applications........................................ 25
9. Other Information........................................... 27
10. References.................................................. 27
11. Relation to other RFCs...................................... 27
12. Security Considerations..................................... 27
13. Authors' Addresses.......................................... 28
1. Introduction π
Okay so this tutorial is the "bare bones" version of TCP/IP, which means it only shows one view of the salient points π It skips the history and funding, the business case for using it, and how it stacks up against ISO OSI in the future π It also leaves out a whole lot of technical info, but what's left is the minimum that anyone working in a TCP/IP environment needs to know β¨ The people this is for are the systems administrator, the systems programmer, and the network manager π«Ά
This tutorial uses examples from the UNIX TCP/IP environment, but the main points work across all implementations of TCP/IP π₯
Note that the purpose of this memo is explanation, not definition π If you ever have a question about the correct specification of a protocol, go check the actual standards that define the RFC, bestie π
Next up is an overview of TCP/IP, followed by detailed descriptions of the individual components π¦
2. TCP/IP Overview πΈ
The generic term "TCP/IP" usually means anything and everything related to the specific protocols TCP and IP π It can include other protocols, applications, and even the network medium. Some examples of protocols are UDP, ARP, and ICMP. Some examples of applications are TELNET, FTP, and rcp. A more accurate term is "internet technology," and a network that uses internet technology is called an "internet" π
2.1. Basic Structure π§±
To get this technology you first have to understand the following logical structure π
----------------------------
| network applications |
| |
|... \ | / .. \ | / ...|
| ----- ----- |
| |TCP| |UDP| |
| ----- ----- |
| \ / |
| -------- |
| | IP | |
| ----- -*------ |
| |ARP| | |
| ----- | |
| \ | |
| ------ |
| |ENET| |
| ---@-- |
----------|-----------------
|
----------------------o---------
Ethernet Cable
Figure 1. Basic TCP/IP Network Node
This is the logical structure of the layered protocols inside a computer on an internet. Every computer that can talk using internet technology has one of these, and this structure is what decides how that computer behaves on the internet π The boxes stand for the processing of data as it passes through the computer, and the lines between the boxes show the path the data takes. The horizontal line at the bottom is the Ethernet cable, and the "o" is the transceiver. The "*" is the IP address and the "@" is the Ethernet address β¨ Understanding this logical structure is essential to understanding internet technology, and it comes up all throughout this tutorial π
2.2. Terminology π
The name of a unit of data that flows through an internet depends on where it is in the protocol stack, so here's the rundown π§ If it's on an Ethernet, it's called an Ethernet frame. If it's between the Ethernet driver and the IP module, it's called an IP packet. If it's between the IP module and the UDP module, it's called a UDP datagram. If it's between the IP module and the TCP module, it's called a TCP segment (more generally, a transport message). And if it's inside a network application, it's called an application message π¦
These definitions are kinda imperfect, ngl π Actual definitions vary from one publication to the next. You can find more specific definitions in RFC 1122, section 1.3.3 π₯
A driver is software that talks directly to the network interface hardware. A module is software that talks to a driver, to network applications, or to another module π
The terms driver, module, Ethernet frame, IP packet, UDP datagram, TCP message, and application message get used wherever they fit throughout this tutorial πΈ
2.3. Flow of Data π
Let's follow the data as it flows down through the protocol stack shown in Figure 1 π«Ά For an application that uses TCP (Transmission Control Protocol), data passes between the application and the TCP module. For applications that use UDP (User Datagram Protocol), data passes between the application and the UDP module. FTP (File Transfer Protocol) is a typical application that uses TCP, and in this example its protocol stack is FTP/TCP/IP/ENET. SNMP (Simple Network Management Protocol) is an application that uses UDP, and its protocol stack in this example is SNMP/UDP/IP/ENET π
The TCP module, the UDP module, and the Ethernet driver are n-to-1 multiplexers, which means they switch many inputs to one output. They're also 1-to-n de-multiplexers, so they switch one input to many outputs based on the type field in the protocol header π
1 2 3 ... n 1 2 3 ... n
\ | / | \ | | / ^
\ | | / | \ | | / |
------------- flow ---------------- flow
|multiplexer| of |de-multiplexer| of
------------- data ---------------- data
| | | |
| v | |
1 1
Figure 2. n-to-1 multiplexer and 1-to-n de-multiplexer
If an Ethernet frame comes up into the Ethernet driver from the network, the packet can be passed upward to either the ARP (Address Resolution Protocol) module or the IP (Internet Protocol) module π The value of the type field in the Ethernet frame decides which one it goes to β¨
If an IP packet comes up into IP, the unit of data gets passed upward to either TCP or UDP, depending on the value of the protocol field in the IP header π¦
If a UDP datagram comes up into UDP, the application message gets passed upward to the network application based on the value of the port field in the UDP header. If a TCP message comes up into TCP, the application message gets passed upward to the network application based on the value of the port field in the TCP header π₯
Downward multiplexing is simple, because from each starting point there's only one downward path. Each protocol module adds its header information so the packet can be de-multiplexed at the destination computer π
Data passing out from the applications through either TCP or UDP converges on the IP module and gets sent downward through the lower network interface driver πΈ
Internet technology supports lots of different network media, but Ethernet is used for all the examples in this tutorial because it's the most common physical network used under IP π«Ά The computer in Figure 1 has a single Ethernet connection. The 6-byte Ethernet address is unique for each interface on an Ethernet, and it's located at the lower interface of the Ethernet driver π
The computer also has a 4-byte IP address. This address is located at the lower interface to the IP module, and the IP address must be unique for an internet β¨
A running computer always knows its own IP address and Ethernet address π
2.4 Two Network Interfaces πβ¨
okay so picture a computer hooked up to 2 separate Ethernets at the same time. that's Figure 3 and it's giving main character energy π
----------------------------
| network applications |
| |
|... \ | / .. \ | / ...|
| ----- ----- |
| |TCP| |UDP| |
| ----- ----- |
| \ / |
| -------- |
| | IP | |
| ----- -*----*- ----- |
| |ARP| | | |ARP| |
| ----- | | ----- |
| \ | | / |
| ------ ------ |
| |ENET| |ENET| |
| ---@-- ---@-- |
----------------|-------|---------
| |
| ---o---------------------------
| Ethernet Cable 2
---------------o----------
Ethernet Cable 1
Figure 3. TCP/IP Network Node on 2 Ethernets
please note that this computer has 2 Ethernet addresses AND 2 IP addresses π₯Ήπ
now here's the tea. for a computer with more than one physical network interface, the IP module is doing two jobs at once: it's an n-to-m multiplexer AND an m-to-n de-multiplexer π§ it's literally juggling traffic in both directions π€ΉββοΈ
1 2 3 ... n 1 2 3 ... n
\ | | / | \ | | / ^
\ | | / | \ | | / |
------------- flow ---------------- flow
|multiplexer| of |de-multiplexer| of
------------- data ---------------- data
/ | | \ | / | | \ |
/ | | \ v / | | \ |
1 2 3 ... m 1 2 3 ... m
Figure 4. n-to-m multiplexer and m-to-n de-multiplexer
it does this multiplexing in either direction so it can handle incoming AND outgoing data π and an IP module with more than 1 network interface is way more complex than our original example, because it can forward data onto the next network π data can arrive on any network interface and get sent out on any other. iconic behaviour π
TCP UDP
\ /
\ /
--------------
| IP |
| |
| --- |
| / \ |
| / v |
--------------
/ \
/ \
data data
comes in goes out
here here
Figure 5. Example of IP Forwarding a IP Packet
so the process of sending an IP packet out onto another network is called "forwarding" an IP packet β¨ and a computer that's been dedicated to forwarding IP packets is called an "IP-router" π¦
and bestie, look at the figure: the forwarded IP packet never touches the TCP and UDP modules on the IP-router π some IP-router implementations don't even have a TCP or UDP module. no cap, that's so efficient it's a little bit iconic ngl π
2.5 IP Creates a Single Logical Network π
the IP module is central to the success of internet technology π every module or driver slaps its header onto the message as it goes down the protocol stack π¦ and then as the message climbs back up toward the application, each module or driver strips off its matching header π§Ή
the IP header holds the IP address, and that's what builds a single logical network out of multiple physical networks. this interconnection of physical networks is literally where the name internet comes from π«Ά a set of interconnected physical networks that limit the range of an IP packet is called an "internet".
2.6 Physical Network Independence π§ββοΈ
IP hides the underlying network hardware from the network applications π so if someone invents a brand new physical network, you can put it into service by writing a new driver that connects to the internet underneath IP. the network applications stay intact and aren't vulnerable to changes in hardware technology. the way that's so smart π
2.7 Interoperability π€
if two computers on an internet can communicate, they're said to "interoperate" π and if an implementation of internet technology is good, it's said to have "interoperability" β¨ users of general-purpose computers benefit from installing an internet because of the interoperability in computers on the market. basically, when you buy a computer, it'll interoperate ποΈ
if a computer does NOT have interoperability, and it can't be added, then it's stuck in a rare and special niche in the market π
2.8 After the Overview π
with the background set, we're going to answer these questions:
- When sending out an IP packet, how is the destination Ethernet address determined?
- How does IP know which of multiple lower network interfaces to use when sending out an IP packet?
- How does a client on one computer reach the server on another?
- Why do both TCP and UDP exist, instead of just one or the other?
- What network applications are available?
these will be explained, in turn, after an Ethernet refresher π«Ά
3. Ethernet π₯
this section is a short review of Ethernet technology, bestie π
an Ethernet frame contains the destination address, source address, type field, and data π¨
an Ethernet address is 6 bytes π’ every device has its own Ethernet address and listens for Ethernet frames with that destination address. all devices also listen for Ethernet frames with a wild-card destination address of "FF-FF-FF-FF-FF-FF" (in hexadecimal), called a "broadcast" address π’
Ethernet uses CSMA/CD (Carrier Sense and Multiple Access with Collision Detection) π CSMA/CD means all devices communicate on a single medium, only one can transmit at a time, and they can all receive simultaneously. if 2 devices try to transmit at the exact same instant, the collision is detected, and both devices wait a random (but short) period before trying to transmit again π
3.1 A Human Analogy π£οΈπ
ok this analogy is so good I'm obsessed π Ethernet technology is like a group of people talking in a small, completely dark room π―οΈ the physical network medium is sound waves in the air of the room, instead of electrical signals on a coaxial cable.
each person can hear the words when another is talking (Carrier Sense) π everyone in the room has equal capability to talk (Multiple Access), but none of them give lengthy speeches because they're polite π« if a person is impolite, he's asked to leave the room (i.e., thrown off the net) πͺ
no one talks while another is speaking. but if two people start speaking at the same instant, each of them knows it because each hears something they haven't said (Collision Detection) π₯ when they notice this, they wait for a moment, then one begins talking. the other hears the talking and waits for the first to finish before starting his own speech π€«
each person has a unique name (unique Ethernet address) to avoid confusion π·οΈ every time one of them talks, he prefaces the message with the name of the person he's talking to and his own name (Ethernet destination and source address, respectively), i.e., "Hello Jane, this is Jack, ..blah blah blah...". if the sender wants to talk to everyone, he might say "everyone" (broadcast address), i.e., "Hello Everyone, this is Jack, ..blah blah blah..." π£πΈ
4. ARP π
when sending out an IP packet, how is the destination Ethernet address determined? ARP is the answer, babe π«Ά
ARP (Address Resolution Protocol) is used to translate IP addresses to Ethernet addresses π the translation is done only for outgoing IP packets, because that's when the IP header and the Ethernet header are created β¨
4.1 ARP Table for Address Translation π
the translation is performed with a table look-up π the table, called the ARP table, is stored in memory and has a row for each computer. there's a column for IP address and a column for Ethernet address. when translating an IP address to an Ethernet address, the table gets searched for a matching IP address π here's a simplified ARP table:
------------------------------------
|IP address Ethernet address |
------------------------------------
|223.1.2.1 08-00-39-00-2F-C3|
|223.1.2.3 08-00-5A-21-A7-22|
|223.1.2.4 08-00-10-99-AC-54|
------------------------------------
TABLE 1. Example ARP Table
the human convention for writing out the 4-byte IP address is each byte in decimal, separated by a period π’ when writing out the 6-byte Ethernet address, each byte is in hexadecimal, separated by either a minus sign or a colon π
the ARP table is necessary because the IP address and Ethernet address are selected independently, so you can not use an algorithm to translate one to the other π ββοΈ the IP address is selected by the network manager based on the computer's location on the internet. when the computer is moved to a different part of an internet, its IP address must be changed. the Ethernet address is selected by the manufacturer based on the Ethernet address space the manufacturer has licensed. when the Ethernet hardware interface board changes, the Ethernet address changes too π₯Ήπ
4.2. Typical Translation Scenario
okay so picture the normal day-to-day π a network app like TELNET sends its message to TCP, and TCP hands the matching TCP message to the IP module. the destination IP address is already known to the application, the TCP module, and the IP module π«Ά by this point the IP packet is fully built and ready for the Ethernet driver, but first the destination Ethernet address has to be figured out π
the ARP table is where we look up that destination Ethernet address π§
4.3. ARP Request/Response Pair
but wait, how does the ARP table even get filled in? π€ ANSWER: it fills itself in automatically, on an "as-needed" basis β¨ no cap, it's so iconic
two things happen when the ARP table can't translate an address:
- an ARP request packet with a broadcast Ethernet address gets sent out on the network to every computer π’
- the outgoing IP packet gets queued π«§
every computer's Ethernet interface receives that broadcast Ethernet frame π each Ethernet driver checks the Type field in the frame and passes the ARP packet up to the ARP module. the ARP request basically says "hey, if your IP address matches this target IP address, then please tell me your Ethernet address" π it looks something like this:
---------------------------------------
|Sender IP Address 223.1.2.1 |
|Sender Enet Address 08-00-39-00-2F-C3|
---------------------------------------
|Target IP Address 223.1.2.2 |
|Target Enet Address <blank> |
---------------------------------------
TABLE 2. Example ARP Request
each ARP module looks at the IP address, and if the Target IP address matches its own, it sends a response directly to the source Ethernet address π¦ the ARP response is basically "yes, that target IP address is mine, here's my Ethernet address" π the sender and target fields are swapped compared to the request, so it looks like this:
---------------------------------------
|Sender IP Address 223.1.2.2 |
|Sender Enet Address 08-00-28-00-38-A9|
---------------------------------------
|Target IP Address 223.1.2.1 |
|Target Enet Address 08-00-39-00-2F-C3|
---------------------------------------
TABLE 3. Example ARP Response
the original sender gets that response π its Ethernet driver checks the Type field and passes the ARP packet to the ARP module, and the ARP module reads the packet and adds the sender's IP and Ethernet addresses to its ARP table π«Ά the updated table now looks like this:
----------------------------------
|IP address Ethernet address |
----------------------------------
|223.1.2.1 08-00-39-00-2F-C3|
|223.1.2.2 08-00-28-00-38-A9|
|223.1.2.3 08-00-5A-21-A7-22|
|223.1.2.4 08-00-10-99-AC-54|
----------------------------------
TABLE 4. ARP Table after Response
4.4. Scenario Continued
the new translation is installed automatically in the table, just milli-seconds after it was needed πβ‘ remember step 2 from above? the outgoing IP packet got queued. next, the IP-to-Ethernet address translation happens by looking things up in the ARP table, and then the Ethernet frame is sent out on the Ethernet π so with the new steps 3, 4, and 5 added in, the sender computer's full scenario looks like this:
- an ARP request packet with a broadcast Ethernet address gets sent out on the network to every computer π’
- the outgoing IP packet gets queued π«§
- the ARP response arrives with the IP-to-Ethernet address translation for the ARP table π
- for the queued IP packet, the ARP table gets used to translate the IP address to the Ethernet address π
- the Ethernet frame gets transmitted on the Ethernet π«
the TL;DR π : when the translation is missing from the ARP table, one IP packet gets queued, the translation data is quickly filled in with ARP request/response, and then the queued IP packet is transmitted π
each computer has a separate ARP table for each of its Ethernet interfaces π§© if the target computer doesn't exist, there's no ARP response and no entry in the ARP table, and IP discards outgoing IP packets sent to that address π the upper layer protocols can't tell the difference between a broken Ethernet and the absence of a computer with the target IP address π
some implementations of IP and ARP don't queue the IP packet while they wait for the ARP response π¬ instead, the IP packet gets discarded, and recovering from that loss is left to the TCP module or the UDP network application. this recovery is done by time-out and retransmission π the retransmitted message goes out successfully because the first copy already filled the ARP table π₯Ήβ¨
5. Internet Protocol
the IP module is central to internet technology, and the essence of IP is its route table π IP uses this in-memory table to make all of its decisions about routing an IP packet. the content of the route table is defined by the network administrator, and mistakes block communication π§
to understand how a route table is used is to understand internetworking π§ this understanding is necessary for successfully administering and maintaining an IP network.
the route table is easiest to understand by first getting an overview of routing, then learning about IP network addresses, and then looking at the details π
5.1. Direct Routing
the figure below is of a tiny internet with 3 computers: A, B, and C π¦ each computer has the same TCP/IP protocol stack as in Figure 1. each computer's Ethernet interface has its own Ethernet address. each computer has an IP address assigned to its IP interface by the network manager, who has also assigned an IP network number to the Ethernet πΈ
A B C
| | |
--o------o------o--
Ethernet 1
IP network "development"
Figure 6. One IP Network
when A sends an IP packet to B, the IP header contains A's IP address as the source IP address, and the Ethernet header contains A's Ethernet address as the source Ethernet address π the IP header also contains B's IP address as the destination IP address, and the Ethernet header contains B's Ethernet address as the destination Ethernet address β¨
--------------------------------------
|address source destination|
(the table, for real this time π )
----------------------------------------
|address source destination|
----------------------------------------
|IP header A B |
|Ethernet header A B |
----------------------------------------
TABLE 5. Addresses in an Ethernet frame for an IP packet
from A to B
for this simple case, IP is kind of overhead π because IP adds very little to the service Ethernet already offers. but IP does come with a cost: the extra CPU processing and network bandwidth needed to generate, transmit, and parse the IP header π«
when B's IP module receives the IP packet from A, it checks the destination IP address against its own, looking for a match, and then passes the datagram up to the upper-level protocol π
this communication between A and B uses direct routing. π
5.2. Indirect Routing β¨
okay so this next figure is the more realistic picture of an internet π it's got 3 Ethernets and 3 IP networks, all tied together by an IP-router called computer D. each IP network has 4 computers, and every single one has its own IP address AND Ethernet address π
A B C ----D---- E F G
| | | | | | | | |
--o------o------o------o- | -o------o------o------o--
Ethernet 1 | Ethernet 2
IP network "development" | IP network "accounting"
|
|
| H I J
| | | |
--o-----o------o------o--
Ethernet 3
IP network "factory"
Figure 7. Three IP Networks; One internet
so everyone except computer D has a TCP/IP protocol stack like the one in Figure 1 π computer D is the main character here, bc it's connected to all 3 networks, which means it has 3 IP addresses and 3 Ethernet addresses π its stack is kinda like Figure 3, except it has 3 ARP modules and 3 Ethernet drivers instead of 2. but β¨ computer D only has ONE IP module. that's the detail that matters.
the network manager gave each Ethernet its own unique number, called an IP network number πΈ the diagram doesn't show the numbers, just the network names.
when computer A sends an IP packet to computer B, it's literally the same process as the single network example from before. any communication between computers on the same IP network is just the direct routing example we already covered π¦
now here's where it gets good. D and A talk directly. D and E talk directly. D and H talk directly. why? bc each of those pairs is on the same IP network, so no hopping needed π«Ά
BUT when A wants to talk to a computer on the far side of the IP-router, it's not direct anymore π A HAS to use D to forward the IP packet to the next IP network. this is called "indirect" π
the routing of IP packets is handled by the IP modules, and it happens totally behind the scenes. TCP, UDP, and the network apps don't even notice π§
so if A sends an IP packet to E, the source IP address and source Ethernet address are both A's π the destination IP address is E's, but A's IP module sends the packet to D first for forwarding. so the destination Ethernet address is D's.
----------------------------------------
|address source destination|
----------------------------------------
|IP header A E |
|Ethernet header A D |
----------------------------------------
TABLE 6. Addresses in an Ethernet frame for an IP packet
from A to E (before D)
D's IP module gets the packet, checks the destination IP address, and goes "this is not my IP address" π then it sends the packet straight to E.
----------------------------------------
|address source destination|
----------------------------------------
|IP header A E |
|Ethernet header D E |
----------------------------------------
TABLE 7. Addresses in an Ethernet frame for an IP packet
from A to E (after D)
quick summary bc it's so important π for direct communication, the source IP address AND source Ethernet address are the sender's, and the destination IP address AND destination Ethernet address are the recipient's. for indirect communication, the IP and Ethernet addresses don't line up like that. that's the whole difference, periodt π
this example internet is super simple. real networks are way messier, with multiple IP-routers and lots of different physical network types π this one might exist because the network manager wanted to split up a big Ethernet so the Ethernet broadcast traffic stays more localized. iykyk π
5.3. IP Module Routing Rules
okay so everything we've looked at so far shows WHAT happens, but not HOW π§ now let's look at the actual rules (aka the algorithm) the IP module follows.
- for an outgoing IP packet, coming down from an upper layer, IP MUST decide whether to send it directly or indirectly, and IP MUST choose a lower network interface. these choices are made by checking the route table πΊοΈ
- for an incoming IP packet, coming up from a lower interface, IP MUST decide whether to forward it or pass it to an upper layer. if it's being forwarded, it gets treated like an outgoing IP packet β¨
- when an incoming IP packet arrives, it is NEVER forwarded back out through the same network interface it came in on π ββοΈ
all of these decisions get made BEFORE the IP packet is handed to the lower interface, and BEFORE the ARP table is checked π
5.4. IP Address
the network manager assigns IP addresses to computers based on which IP network each computer is attached to π‘ one part of a 4-byte IP address is the IP network number, and the other part is the IP computer number (aka the host number). for the computer in Table 1, with IP address 223.1.2.1, the network number is 223.1.2 and the host number is 1 π¦
which part is the network number and which part is the host number is decided by the upper bits in the 4-byte address. all the example IP addresses in this tutorial are class C, which means the upper 3 bits say 21 bits are the network number and 8 bits are the host number. that gives you 2,097,152 class C networks, with up to 254 hosts on each one π€―
the IP address space is administered by the NIC (Network Information Center). any internet connected to the one big worldwide Internet MUST use network numbers that the NIC assigned π and even if you're building your own internet and NOT connecting it to the Internet, you SHOULD still get your network numbers from the NIC π«Ά bc if you pick your own, you run the risk of confusion and chaos if your internet ever gets connected to another one. not a vibe π
5.5. Names
people refer to computers by names, not numbers π so a computer called alpha might have the IP address 223.1.2.1. for small networks, this name-to-address translation data is usually kept on each computer in a "hosts" file π for bigger networks, the translation file lives on a server and gets accessed across the network when it's needed. a few lines from that file might look like this:
223.1.2.1 alpha
223.1.2.2 beta
223.1.2.3 gamma
223.1.2.4 delta
223.1.3.2 epsilon
223.1.4.2 iota
the IP address is the first column, and the computer name is the second column π
in most cases you can install identical "hosts" files on every computer πΈ you might notice "delta" only has ONE entry even though it has 3 IP addresses. but delta can be reached through any of its IP addresses, and it doesn't matter which one gets used. when delta gets an IP packet and checks the destination address, it recognizes any of its own IP addresses π§
IP networks get names too! if you have 3 IP networks, your "networks" file for documenting those names might look something like this:
223.1.2 development
223.1.3 accounting
223.1.4 factory
the IP network number is in the first column, and the name is in the second column π
from this you can see that alpha is computer number 1 on the development network, beta is computer number 2 on the development network, and so on. you could also say alpha is development.1, beta is development.2, etc. π¦
the hosts file above is good enough for users, but the network manager will probably swap out the line for delta with these:
223.1.2.4 devnetrouter delta
223.1.3.1 facnetrouter
223.1.4.1 accnetrouter
now each of delta's IP addresses has a meaningful name β¨ the first address actually has 2 names: "delta" and "devnetrouter" are synonyms. in practice, "delta" is the general-purpose name for the computer, and the other 3 names only get used when administering the IP route table π οΈ
these files are used by network admin commands and network apps to give everything meaningful names. they are NOT required for an internet to work, but they make life way easier for us π«Ά
5.6. IP Route Table
okay the big question: how does IP know which lower network interface to use when it sends out an IP packet? π€ it looks it up in the route table, using a search key of the IP network number pulled out of the IP destination address π
the route table has one row per route. the main columns are: IP network number, direct/indirect flag, router IP address, and interface number. IP checks this table for every outgoing IP packet πΊοΈ
on most computers you can change the route table with the "route" command. the content of the route table is defined by the network manager, because the network manager is the one who assigns the IP addresses to the computers π
5.7. Direct Routing Details
let's zoom in and go through the routing situations we've already looked at, in detail π¬
--------- ---------
| alpha | | beta |
| 1 | | 1 |
--------- ---------
| |
--------o---------------o-
Ethernet 1
IP network "development"
Figure 8. Close-up View of One IP Network
the route table inside alpha looks like this:
--------------------------------------------------------------
|network direct/indirect flag router interface number|
--------------------------------------------------------------
|development direct <blank> 1 |
--------------------------------------------------------------
TABLE 8. Example Simple Route Table
you can see this view on some UNIX systems with the "netstat -r" command π§ in this simple network, every computer has an identical routing table π
for discussion, here's the table again, but with the network number instead of its network name:
--------------------------------------------------------------
|network direct/indirect flag router interface number|
--------------------------------------------------------------
|223.1.2 direct <blank> 1 |
--------------------------------------------------------------
TABLE 9. Example Simple Route Table with Numbers
5.8. Direct Scenario β¨
okay so picture this: alpha is sending an IP packet to beta π The packet is sitting in alpha's IP module, and the destination IP address is either beta or 223.1.2.2. IP pulls out the network portion of that address and scans the first column of the table to find a match. And we get a match right on the first entry! π―
That entry says computers on this network can be reached directly through interface number 1. So alpha does an ARP table translation on beta's IP address, and then the Ethernet frame goes straight to beta via interface number 1. no detours, just vibes π¦
now, if an application tries to send data to an IP address that isn't on the development network, IP won't find a match in the route table. it's giving "nope, not my problem" and IP discards the IP packet π Some computers will show a "Network not reachable" error message, so at least you know what happened π
5.9. Indirect Routing Details π§
okay, let's zoom in on the more complicated routing scenario we looked at earlier π Here's the close-up of the three IP networks, with alpha, delta, and epsilon all in the mix:
--------- --------- ---------
| alpha | | delta | |epsilon|
| 1 | |1 2 3| | 1 |
--------- --------- ---------
| | | | |
--------o---------------o- | -o----------------o--------
Ethernet 1 | Ethernet 2
IP network "Development" | IP network "accounting"
|
| --------
| | iota |
| | 1 |
| --------
| |
--o--------o--------
Ethernet 3
IP network "factory"
Figure 9. Close-up View of Three IP Networks
alpha's route table looks like this π
---------------------------------------------------------------------
|network direct/indirect flag router interface number|
---------------------------------------------------------------------
|development direct <blank> 1 |
|accounting indirect devnetrouter 1 |
|factory indirect devnetrouter 1 |
---------------------------------------------------------------------
TABLE 10. Alpha Route Table
and for discussion, here's the same table printed again with numbers instead of names, because numbers are iconic π’β¨
--------------------------------------------------------------------
|network direct/indirect flag router interface number|
--------------------------------------------------------------------
|223.1.2 direct <blank> 1 |
|223.1.3 indirect 223.1.2.4 1 |
|223.1.4 indirect 223.1.2.4 1 |
--------------------------------------------------------------------
TABLE 11. Alpha Route Table with Numbers
quick tea: the router in alpha's route table is the IP address of delta's connection to the development network π«Ά
5.10. Indirect Scenario πΈ
so alpha is sending an IP packet to epsilon π The packet is in alpha's IP module, and the destination IP address is epsilon (223.1.3.2). IP pulls out the network portion (223.1.3) and scans the first column looking for a match. A match shows up on the second entry π
that entry says computers on the 223.1.3 network can be reached through the IP-router devnetrouter. So alpha's IP module does an ARP table translation for devnetrouter's IP address and sends the IP packet straight to devnetrouter through alpha's interface number 1. The IP packet still has epsilon as its destination address, so it's not forgetting where it's going π§
the IP packet arrives at delta's development network interface and gets passed up to delta's IP module. delta checks the destination IP address, and since it doesn't match any of delta's own IP addresses, delta decides to forward the packet π
delta's IP module pulls out the network portion of the destination IP address (223.1.3) and checks its route table for a matching network field. delta's route table looks like this:
----------------------------------------------------------------------
|network direct/indirect flag router interface number|
----------------------------------------------------------------------
|development direct <blank> 1 |
|factory direct <blank> 3 |
|accounting direct <blank> 2 |
----------------------------------------------------------------------
TABLE 12. Delta's Route Table
and here's delta's table again without the names translated π’
----------------------------------------------------------------------
|network direct/indirect flag router interface number|
----------------------------------------------------------------------
|223.1.2 direct <blank> 1 |
|223.1.3 direct <blank> 3 |
|223.1.4 direct <blank> 2 |
----------------------------------------------------------------------
TABLE 13. Delta's Route Table with Numbers
the match is on the second entry π― IP then sends the packet directly to epsilon through interface number 3. The IP packet carries epsilon's IP destination address and epsilon's Ethernet destination address, so everything's addressed correctly π
finally, the IP packet arrives at epsilon and gets passed up to epsilon's IP module. the destination IP address matches epsilon's own IP address, so the packet is passed up to the upper protocol layer. β we made it, bestie! π₯³
5.11. Routing Summary π¦
when an IP packet travels through a large internet, it may hop through lots of IP-routers before it reaches its destination π The path isn't decided by one central boss. Instead, it's the result of each router consulting its own routing table along the way. Every computer only knows the next hop in the journey, and then it trusts that computer to send the packet on its way π«Ά
5.12. Managing the Routes π
ngl, keeping correct routing tables on every computer in a large internet is a whole task π Network configuration keeps changing because network managers are always updating things to meet new needs. And mistakes in routing tables can block communication in ways that are excruciatingly tedious to diagnose. (so painful, I'm sorry π)
the good news is that keeping a simple network configuration goes a long way toward a reliable internet β¨ For example, the most straightforward way to assign IP networks to Ethernet is to give each Ethernet its own single IP network number π
help is also available from certain protocols and network applications π§ ICMP (Internet Control Message Protocol) can report some routing problems. For small networks, the network administrator fills the route table manually on each computer. For bigger networks, the administrator automates that manual work with a routing protocol that distributes routes throughout the network π₯
also, when a computer moves from one IP network to another, its IP address has to change. And when a computer is removed from an IP network, its old address becomes invalid. These changes mean frequent updates to the "hosts" file π© That flat file can get really hard to maintain, even for medium-size networks. The Domain Name System helps solve these problems π
6. User Datagram Protocol π
UDP is one of the two main protocols that sit on top of IP π It offers service to the user's network applications. Some example network applications that use UDP are Network File System (NFS) and Simple Network Management Protocol (SNMP). Honestly, the service is little more than an interface to IP π«Ά
UDP is a connectionless datagram delivery service that does not guarantee delivery π It doesn't keep an end-to-end connection with the remote UDP module. It just pushes the datagram out onto the net and accepts incoming datagrams off the net. very chill, very no-strings π¦
UDP adds two things on top of what IP gives you. One is multiplexing information between applications based on port number. The other is a checksum, which checks the integrity of the data β¨
6.1. Ports πͺ
how does a client on one computer reach the server on another? π€
the path of communication between an application and UDP goes through UDP ports πΈ These ports are numbered, starting with zero. An application that's offering service (the server) waits for messages to come in on a specific port dedicated to that service. The server waits patiently for any client to request service π§
for instance, the SNMP server, called an SNMP agent, always waits on port 161. There can be only one SNMP agent per computer, because there's only one UDP port number 161. This port number is well known. It's a fixed number, an internet assigned number π So if an SNMP client wants service, it sends its request to port number 161 of UDP on the destination computer π
when an application sends data out through UDP, it arrives at the far end as a single unit π¦ For example, if an application does 5 writes to the UDP port, the application at the far end will do 5 reads from the UDP port. Also, the size of each write matches the size of each read. so clean π
UDP preserves the message boundary defined by the application. It never joins two application messages together, and it never divides a single application message into parts π
6.2. Checksum π
an incoming IP packet with an IP header type field indicating "UDP" gets passed up to the UDP module by IP. When the UDP module receives the UDP datagram from IP, it examines the UDP checksum. If the checksum is zero, that means the checksum wasn't calculated by the sender and can be ignored. So the sending computer's UDP module may or may not generate checksums π€·ββοΈ If Ethernet is the only network between the 2 UDP modules communicating, then you may not need checksumming. However, it is recommended that checksum generation always be enabled, because at some point in the future a route table change may send the data across less reliable media πβ οΈ
the TL;DR: even if your network feels safe right now, turn checksums on, because routes can change later and suddenly your data is taking the scenic route over sketchier media π
if the checksum is valid (or zero), the destination port number gets checked. If an application is bound to that port, an application message is queued for the application to read. Otherwise, the UDP datagram is discarded ποΈ If incoming UDP datagrams arrive faster than the application can read them, and the queue fills up to a maximum value, UDP discards datagrams. UDP keeps discarding datagrams until there's space in the queue again π
7. Transmission Control Protocol π
okay so TCP is the other big player, and it's giving a totally different vibe from UDP π TCP offers a connection-oriented byte stream instead of a connectionless datagram delivery service. Basically, TCP is the one that actually guarantees delivery, whereas UDP just... doesn't π
TCP is used by network applications that need guaranteed delivery and can't be bothered doing time-outs and retransmissions π The two most typical TCP apps are File Transfer Protocol (FTP) and the TELNET. Other popular ones include X-Window System, rcp (remote copy), and the r-series commands. BUT TCP's greater capability isn't free, bestie. It requires more CPU and network bandwidth, and the internals of the TCP module are way more complicated than a UDP module π
Similar to UDP, network applications connect to TCP ports β¨ Well-defined port numbers are dedicated to specific applications. For instance, the TELNET server uses port number 23, so the TELNET client can find the server just by connecting to port 23 of TCP on the specified computer π§
When the application first starts using TCP, the TCP module on the client's computer and the TCP module on the server's computer start talking to each other π«Ά These two end-point TCP modules hold state information that defines a virtual circuit, and that virtual circuit eats up resources in both TCP end-points. The virtual circuit is full duplex, so data can go both ways at the same time π¦ The application writes data to the TCP port, the data traverses the network, and the application at the far end reads it.
TCP packetizes the byte stream at will, and it does NOT keep the boundaries between writes π For example, if an application does 5 writes to the TCP port, the application at the far end might do 10 reads to get all the data. Or it might get everything with a single read. There's no correlation between the number and size of writes on one end and the number and size of reads on the other end. iykyk π
TCP is a sliding window protocol with time-out and retransmits π₯ Outgoing data must be acknowledged by the far-end TCP. Acknowledgements can be piggybacked on data. Both receiving ends can flow control the far end, which prevents a buffer overrun. Iconic behaviour π
As with all sliding window protocols, this one has a window size. The window size determines the amount of data that can be transmitted before an acknowledgement is required. For TCP, this amount is not a number of TCP segments but a number of bytes πΈ
8. Network Applications π
Okay, real question: why do both TCP and UDP exist instead of just one? π€
They supply different services, and most applications are built to use only one or the other. You, the programmer, pick the protocol that best meets your needs. If you need a reliable stream delivery service, TCP might be best. If you need a datagram service, UDP might be best. If you need efficiency over long-haul circuits, TCP might be best. If you need efficiency over fast networks with short latency, UDP might be best. If your needs don't fall neatly into these categories, then the "best" choice is unclear. However, applications can make up for deficiencies in the choice. For instance, if you choose UDP and you need reliability, then the application must provide reliability. If you choose TCP and you need a record oriented service, then the application must insert markers in the byte stream to delimit records π
What network applications are available?
There are far too many to list, and the number is growing constantly π Some have existed since the beginning of internet technology, like TELNET and FTP. Others are relatively new, like X-Windows and SNMP. The following is a brief description of the applications mentioned in this tutorial β¨
8.1. TELNET π»
TELNET provides a remote login capability on TCP. The operation and appearance is similar to keyboard dialing through a telephone switch. On the command line, the user types "telnet delta" and receives a login prompt from the computer called "delta" π
TELNET works well. It's an old application with widespread interoperability, and implementations usually work between different operating systems. For instance, a TELNET client may be on VAX/VMS and the server on UNIX System V π«Ά
8.2. FTP π
File Transfer Protocol (FTP), as old as TELNET, also uses TCP and has widespread interoperability. The operation and appearance is as if you TELNETed to the remote computer. But instead of typing your usual commands, you have to make do with a short list of commands for directory listings and the like π₯² FTP commands let you copy files between computers.
8.3. rsh π
Remote shell (rsh or remsh) is one of an entire family of remote UNIX style commands. The UNIX copy command, cp, becomes rcp. The UNIX "who is logged in" command, who, becomes rwho. The list keeps going and is collectively referred to as the "r" series commands or the "r*" (r star) commands β
The r* commands mainly work between UNIX systems and are designed for interaction between trusted hosts. Little consideration is given to security, but they provide a convenient user environment π
To execute the "cc file.c" command on a remote computer called delta, type "rsh delta cc file.c". To copy the "file.c" file to delta, type "rcp file.c delta:". To log in to delta, type "rlogin delta", and if you administered the computers in a certain way, you won't be challenged with a password prompt π
8.4. NFS ποΈ
Network File System, first developed by Sun Microsystems Inc, uses UDP and is excellent for mounting UNIX file systems on multiple computers. A diskless workstation can access its server's hard disk as if the disk were local to the workstation. A single disk copy of a database on mainframe "alpha" can also be used by mainframe "beta" if the database's file system is NFS mounted on "beta" π
NFS adds significant load to a network and has poor utility across slow links, but the benefits are strong πͺ The NFS client is implemented in the kernel, which lets all applications and commands use the NFS mounted disk as if it were local disk.
8.5. SNMP π
Simple Network Management Protocol (SNMP) uses UDP and is designed for use by central network management stations. It's a well known fact that if given enough data, a network manager can detect and diagnose network problems π§ The central station uses SNMP to collect this data from other computers on the network. SNMP defines the format for the data, and it's left to the central station or network manager to interpret it.
8.6. X-Window πͺ
The X Window System uses the X Window protocol on TCP to draw windows on a workstation's bitmap display. X Window is way more than a utility for drawing windows. It's an entire philosophy for designing a user interface π
9. Other Information π§
Much information about internet technology wasn't included in this tutorial. This section lists information that's considered the next level of detail for the reader who wants to learn more π
- administration commands: arp, route, and netstat
- ARP: permanent entry, publish entry, time-out entry, spoofing
- IP route table: host entry, default gateway, subnets
- IP: time-to-live counter, fragmentation, ICMP
- RIP, routing loops
- Domain Name System
10. References π
[1] Comer, D., "Internetworking with TCP/IP Principles, Protocols, and Architecture", Prentice Hall, Englewood Cliffs, New Jersey, U.S.A., 1988.
[2] Feinler, E., et al, DDN Protocol Handbook, Volume 2 and 3, DDN Network Information Center, SRI International, 333 Ravenswood Avenue, Room EJ291, Menlow Park, California, U.S.A., 1985.
[3] Spider Systems, Ltd., "Packets and Protocols", Spider Systems Ltd., Stanwell Street, Edinburgh, U.K. EH6 5NG, 1990.
11. Relation to other RFCs π¦
This RFC is a tutorial and it does not UPDATE or OBSOLETE any other RFC π
12. Security Considerations π¨
There are security considerations within the TCP/IP protocol suite. To some people these considerations are serious problems, to others they are not. It depends on the user requirements π
This tutorial does not discuss these issues. But if you want to learn more, you should start with the topic of ARP-spoofing, then use the "Security Considerations" section of RFC 1122 to lead you to more information. Do not skip this, bestie π
13. Authors' Addresses π
Theodore John Socolofsky Spider Systems Limited Spider Park Stanwell Street Edinburgh EH6 5NG United Kingdom
Phone:
from UK 031-554-9424
from USA 011-44-31-554-9424
Fax:
from UK 031-554-0649
from USA 011-44-31-554-0649
EMail: TEDS@SPIDER.CO.UK
Claudia Jeanne Kale 12 Gosford Place Edinburgh EH6 4BJ United Kingdom
Phone:
from UK 031-554-7432
from USA 011-44-31-554-7432
EMail: CLAUDIAK@SPIDER.CO.UK π«Ά
π¦ where this page comes from
- ietf: rfc1180 1991-01
- π girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms