Internet protocol suite, commonly known as TCP/IP, is a set of communication protocols, where the main ones are the Transmission Control Protocol (TCP) and Internet Protocol (IP).
TCP/IP model
The classic four-layer TCP/IP model, sometimes also called the Internet Reference Model, is based on the OSI model, but is closer to practice.
| layer | name CZ | name EN | examples of applications for the layer |
|---|---|---|---|
| layer 4 | Aplikační | Application | Telnet, FTP, POP3, HTTP, DNS, SNMP |
| layer 3 | Transportní | Transport | TCP, UDP |
| layer 2 | Síťová | Network (Internetwork/Internet) | IP, ICMP, IGMP, ARP, STP |
| layer 1 | Síťové rozhranní (přístupová) | Network Interface (Access) | network card driver (Ethernet, Frame Relay) |
Sometimes the lowest layer is divided into two parts. The physical layer (Physical Layer) and the data link layer (Data link).
Encapsulation when sending data
When sending data, encapsulation (wrapping) is performed from the highest layer down. It happens like this: the application takes the data (application layer) it wants to send to another station and adds an application header. This data is sent to the lower layer (transport), which divides the data being sent into segments, wraps them, and adds a TCP (or UDP) header to create a TCP segment. The next layer (network) adds an IP header, and this creates an IP packet (sometimes referred to as an IP datagram). In the last layer (access), an Ethernet header is added to the beginning of the packet and a trailer to the end, which contains the FCS (Frame Check Sequence) - checksum (often CRC - cyclic redundancy check is used for its calculation). This is how an Ethernet frame is created in the last step, which is transmitted to the communication medium.
Note: The above description concerned the IP protocol, if it is an auxiliary protocol (like ARP, ICMP), the situation is similar.
When the destination device receives the data, the reverse process of de-encapsulation (unwrapping) is performed from the lowest layer up, and the destination application receives the sent data.
Packet vs. frame
In connection with data and its transmission over the network, two important terms are used, these are packet and frame. These terms are widely used in literature, on the internet, and in practice. Unfortunately, there are several different explanations in the literature, and the use of these terms also varies. Moreover, it depends on the technology in which they are used (similar terms are used, for example, in serial communication). I present here the explanation of these terms that seems most correct to me.
Packet means a package in translation and is a formatted block of data that is transmitted in a computer network. Packets are talked about in connection with the network layer. A packet contains an IP address, other attributes, and data. It is wrapped in a frame and then travels through the network.
Frame is what actually travels in the network. Frames are created at the physical layer of the network interface. The name suggests that it is more of a time segment than an object. There are several types of frames, the most used is Ethernet II, which can transport both TCP/IP and IPX/SPX.
The maximum size of data transmitted in a frame (i.e., the size of the packet) is determined by MTU (Maximum transmission unit) and is related to the link layer. The standard MTU size in Ethernet is 46 - 1500 bytes. At the beginning of communication, devices agree on the MTU size using ICMP. If the other side requires a smaller MTU, fragmentation - splitting the frame into several smaller ones - can be performed. Fragmentation can be prohibited by a flag in the packet header. If fragmentation is prohibited and the other side accepts only a smaller MTU, it will respond with an ICMP error.
In general terminology, the term Protocol Data Unit (PDU) is used, which is a data unit at any layer (IP packet, frame, etc.). When a PDU is passed to a lower layer, it is referred to as a Service Data Unit (SDU), where it is supplemented with Protocol Control Information (PCI), i.e., a header, and a new PDU is created.
Packet - frame format
The basic shape of a frame is header, data (payload), and trailer. The data consists of encapsulated data from higher layers. The following figure shows the four layers of the TCP/IP model along with the rough format of the data as it is encapsulated from top to bottom. The example given is for the TCP protocol, but the general model is the same.
| PDU name | layer | ||||||
| appl header | user data | message | Application | ||||
| TCP header | application data | TCP segment | Transport | ||||
| IP header | TCP header | application data | IP packet | Network | |||
| ethernet header | IP header | TCP header | application data | ethernet trailer | Ethernet frame | Data-Link | |
Ethernet header
The Ethernet header contains the source and destination MAC address (physical address from hop to hop) and type/length. The type in the header determines which protocol is used at the higher layer (IP, ARP, etc.). To distinguish individual frames, a special introduction (preamble) composed of a sequence of alternating ones and zeros and SFD - start frame delimiter is transmitted at the beginning.
| preamble | SFD | destination MAC address | source MAC address | type / length | data (payload) | CRC |
| 7B | 1B | 6B | 6B | 2B | 46-1500B | 4B |
IP header
The IP header contains the source and destination IP address (logical address of the communicating parties), as well as the protocol specification for the next layer (TCP, UDP, ICMP, etc.), header checksum, and other values. The standard size of the IP header is 20B, but it can also contain optional properties. The shape of the IP header depends on the protocol used; the following example is for IPv4.
| bits | 0-3 | 4-7 | 8-15 | 16-18 | 19-31 |
| 0 | 4 | header length | Type of Service | total length (header + data) | |
| 32 | identification | flags | fragment offset | ||
| 64 | TTL | protocol | header checksum | ||
| 96 | source IP | ||||
| 128 | destination IP | ||||
| 160 | options (if any) | ||||
| 160/192+ | DATA | ||||
TCP header
The TCP header contains the source and destination port, sequence and acknowledgment numbers (to ensure reliability), flags (which include SYN and ACK for connection establishment), window size, and more. The standard size is again 20B.
| bits | 0-3 | 4-7 | 8-15 | 16-31 |
| 0 | Source Port | Destination Port | ||
| 32 | Sequence Number | |||
| 64 | Acknowledgment Number | |||
| 96 | Data Offset | Reserved | Flags | Window |
| 128 | Checksum | Urgent Pointer | ||
| 160 | Options (optional) | |||
| 160/192+ | DATA | |||
Tak opět něco, určitě to neberte jako že si nevážím Vaší práce, spíš mi jde o vylepšení již dobrého ;)
Určitě není správné uvádět Internet Reference model jako 4 vrstvý ... IP pracuje na 3. vrstvě a tak by se to mělo uvádět vždy (sám velice často uvádím právě na "3. vrstvě" místo na "síťové vrstvě").
Zůstaňme na zdrojích cisca ;)
Ať se to vezme z hlediska IP:
http://www.cisco.com/en/US/tech/tk1330/tsd_technology_support_technical_reference_chapter09186a0080759807.html
Nebo z hlediska Ethernetu:
http://www.cisco.com/en/US/tech/tk1330/tsd_technology_support_technical_reference_chapter09186a008075974f.html
Vždy se mluví o tom že ethernet se dělí (na 2 vrstvy, celkem na 3 díly)... a ip začíná na 3. vrstvě ... zbytek vyplývá z toho prvního dokumentu...
2. příklad encapsulace jako jpeg headeru taky není správně.
respond to [1]tomfi: No já si o sobě rozhodně nemyslím, že bych byl vševědoucí a opravy či doplnění vítám. Navíc některé věci uvádím pouze pro doplnění celku (a nemám s nimi takové zkušenosti), takže čerpám z různých materiálů.
Co se týče, zda je TCP/IP model čtyř či pěti vrstvý, tak to je asi těžká otázka, i když jsem se nedíval do specifikace. Na netu jsou obě varianty popsány, tak 50 na 50, třeba i u Cisca
http://www.cisco.com/en/US/products/sw/secursw/ps743/products_user_guide_chapter09186a008007f2df.html
http://en.wikipedia.org/wiki/Tcp_ip_model
Jinak také radši používám označování vrstev číslem (a většinou doplňuji, že jde o ISO/OSI model) a pak je to dost matoucí (ten počet vrstev).
Co se týče toho JPGu, tak nevím na co jsem myslel, je to samozřejmě hloupost. Obrázek mohou být data, ta se zapouzdří do aplikačního protokolu (např. HTTP), takže na aplikační vrstvě je hlavička HTTP.
Mate pravdu... člověk se každý den něco přiučí ;)
DoD model je 4 vrstvý(rfc760 a rfc761)... přesně jak říkáte. Omlouvám se.
Ještě na tom textu na cisco.com koukněte na "Figure A-3" jak mají naznačené obalování dat.
Chtěl bych spáááát!! Spáááát!:-O
Fakt obdivuju lidi, kterým dávají tyhle řádky smysl :-) Bez takových jako vy bysme se určitě neobešli ;-)
Zdravim, píšu těď velmi zjednodušený TCP stack do embeded a zdá se mi, že v TCP hlavičce neodpovídá počet bitu dataoffset, který je 8bit a reserved + flags, které se naopak dělí o 1B, tedy 4b a 4b.
Článek pro mě jako víceméně laika zajímavý, dovolím si jen jazykovou poznámku, píše se rozhraní, nikoli rozhranní.
respond to [4]Anonym: A prečo teda vňbec čítaš tieto stránky? Či treba špehovať?
dekuji za pochopeni