Файл: Embedded system development and labs for ARM (R. Muresan, 2005).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 13.06.2025
Просмотров: 2340
Скачиваний: 4
Embedded Systems Development and Labs; The English Edition
Foundation) started to support TCP/IP research and gradually played an important role. NFS aided the establishment of the global Internet network. and used TCP/IP as its communication protocol.
1) Architecture
TCP/IP is a four layers protocol. Every layer is independent and has its own specific function. The TCP/IP layer structure is shown in Figure 6-13.
Application Layer Layer 4
Transmission Layer Layer 3
Internet Layer Layer 2
Network Interface Layer Layer 1
Figure 6-13 TCP/IP Layered Protocol
●Network Interface Layer: Responsible for receiving and sending physical frames. This layer defines the rules of forming frames and the rules of transmission. Frame represents a series of data and a frame is a communication unit of the network transmission. The network layer puts frames to the network or receives frames from the networks.
●Internet Layer: Responsible for the inter-communication between two network nodes. This layer defines the format of the “information package” in the Ethernet and the information transmission mechanisms from one network node to the destination via one or more routers and routing algorithms. The main protocols used in this layer include IP, ARP, ICMP and IGMP.
●Transmission Layer: Responsible for communication of end-to-end. It creates, manages and deletes end-to-end connections for two-user processes. The main protocols used in this layer include TCP, UDP, etc.
●Application Layer: It defines the application programs that use the Internet. Application programs access the network via this layer by following BSD network application interface standard. The main protocols include SMTP, FTP, TELNET, and HTTP, etc.
2) An Introduction to the Main Protocols
(1) IP Protocol
Internet Protocol (IP) is the heart of TCP/IP and the most important protocol in the network layer.
IP layer receives data packages from the lower layer (network interface layer, Ethernet device driver for example) and sends these data packages to the higher layer – TCP or UDP layer. IP layer can also receive data from TCP or UDP layer and sends this data to the lower layer. The IP data package is not reliable because IP does not support mechanisms to check the data integrity and the transmission order of the packages. The IP data package has its sender’s IP address (source address) and its receiver’s IP address (target address).
IP protocol is a non-connection protocol and is mainly responsible for addressing between the hosts and setting the route for data packages. Before the data is exchanged, it doesn’t establish sessions because it doesn’t guarantees error free data transfers. On the other hand, when data is being received, IP doesn’t need to receive acknowledgment information. As a result the IP protocol is not a reliable protocol. If the IP address is for the current host, the IP will send the data directly to this host. If the IP address is for a remote host, the IP will check
247
Embedded Systems Development and Labs; The English Edition
the route of the remote host from the route table in the local host (like we dial 114). If a route is found, the IP will use this route to transfer data; if no route is found, the data package will be sent to a default gateway of the source host (this gate way is also called a router).
The current IP protocol includes the IPv4 version and the v6 version. IPv4 is currently being widely used; IPv6 is the basic protocol that will be used in the next generation of high speed Internet.
The header of IP protocol is shown in Figure 6-14.
0 4 8 16 32
-----------------------------------------------------------------------
|Version |Header Length |Service Type| Total Length |
----------------------------------------------------------------------
| Identification |Flags|Fragment Offset|
-----------------------------------------------------------------------
| Time to Live | Protocol | Header Checksum |
-----------------------------------------------------------------------
| Source IP Address |
-----------------------------------------------------------------------
| Destination IP Address |
-----------------------------------------------------------------------
| Options |
==================================== ===
| Data |
-----------------------------------------------------------------------
Figure 6-14 IPv4 Data Package Format
The C structure of the IP header is defined as following:
struct ip_header |
||
{ |
||
UINT |
ip_v:4; |
/* Version */ |
UINT |
ip_hl:4; |
/* Header Length */ |
UINT8 |
ip_tos; |
/* Service Type */ |
UINT16 |
ip_len; |
/* Total Length */ |
248
Embedded Systems Development and Labs; The English Edition
UINT16 |
ip_id; |
/* Identification */ |
UINT16 |
ip_off; |
/* Fragment Offset */ |
UINT8 |
ip_ttl; |
/* Time to Live */ |
UINT8 |
ip_p; |
/* Higher layer Protocol */ |
UINT16 |
ip_sum; |
/* checksum */ |
struct in_addr ip_src, ip_dst; |
/* Source and Destination IP Address */ |
|
};
The description of these parameters are as following: ip_v Ip protocol version, Ipv is 4, Ipv6 is 6
ip_hl IP Header length. Based on 4 bytes unit. The length of IP header is fixed as 20 bytes. If there are no options included, this value is 5.
ip_tos Service type, describes the priority of services. ip_len IP package length. Use byte as a unit.
ip_id Identification of this package
ip_off Fragment Offset. Used with the above IP for reunite fragments.
ip_ttl Time to live. Minus 1 when passing a route, throw away the data package until this value becomes 0.
ip_p Protocol. The higher layer protocols that create this package. TCP or UDP,for example.
ip_sum Header checksum. It is used to provide verification to the IP header. ip_src,ip_dst Sender and receiver IP address.
For more detailed information of IP protocol, please refer to RFC791.
The IP address is actually a method used to unite the network physical addresses with the higher layer software via Internet Layer. This method uses uniform address format via a uniform management. Different hosts within the Ethernet have different addresses. In IPv4, each host IP address is 32 bits that consists of 4 bytes. In order to conveniently read the address by the users, decimal with dot separation format is used. For example, 211.154.134.93 is the IP address of Embedded Development Network Website. Each IP address has two parts. The network section describes the type of different scale networks. The host section describes the address of the
249
Embedded Systems Development and Labs; The English Edition
host in the network. According to the size of the network scale, the IP address can be divided into five classes A, B C, D, E and F. Among these classes, A, B and C are used as the main address types. D class address is used as multi transmission address for multicasting. E class address is used as an extended optional address.
(2) TCP Protocol
If an IP package has a packaged TCP package, the IP layer will transmit this package to the higher TCP layer. The TCP will sort the packages and do error checking. A virtual circuit connection will also be established. TCP package has a series number and an acknowledgment. The received package will be sorted by the series number. The damaged package will be re-transmitted.
The TCP sends its package to the higher layer programs such as Telnet service program or client programs. Application programs will alternatively send the message back to the TCP layer. The TCP layer will send the message down to the lower IP layer, device driver and physical media and at last to the end receiver. The format of the TCP protocol data package header is shown in Figure 6-15.
0 4 8 10 16 24 32
-----------------------------------------------------------
| Source Port | Destination Port |
-----------------------------------------------------------
| Series number |
-----------------------------------------------------------
| Acknowledgment Number |
-----------------------------------------------------------
| |
| |
|U|A|P|S|F| |
| |
| HL |
| Reserved |R|C|S|Y|I| Window |
| |
|
| |
| |
|G|K|H|N|N| |
| |
-----------------------------------------------------------
| Checksum | Emergency Pointer |
-----------------------------------------------------------
| Options | Fills |
-----------------------------------------------------------
Figure 6-15 TCP Protocol Data Package Header Format
For detail information about the TCP protocol, please refer to the related documentations. A TCP session is established by a three times handshake initialization. The purpose of three times handshake initialization is to synchronize the data transmission, inform other hosts about the data quantity it can be received at one time and establish the virtual connection. The simplified process of three times handshake initialization is as following:
(1)Initialize the host and send a session request.
(2)The receiver host replies by sending a data segment with the following items: synchronization flag, the
250