TcpIp

文档信息 Document Information

版本历史 Version History

日期(Date)

作者(Author)

版本(Version)

状态(Status)

说明(Description)

2024/3/3

miao.wang

V0.1

发布(Release)

首次发布(First release)

2025/04/04

miao.wang

V1.0

发布(Release)

正式发布(Official release)

参考文档 References

编号(Number)

分类(Classification)

标题(Title)

版本(Version)

1

Autosar

AUTOSAR_CP_SRS_Ethernet.pdf

R23-11

2

Autosar

AUTOSAR_SWS_TCPIP.pdf

R23-11

术语与简写 Terms and Abbreviations

简写 Abbreviations

简写(Abbreviation)

全称(Full name)

解释(Explanation)

ARP

Address Resolution Protocol

地址解析协议

DHCP

Dynamic Host Configuration Protocol

动态主机配置协议

ICMP

Internet Control Message Protocol

以太网控制消息协议

IP

Internet Protocol

以太网协议

MTU

Maximum Transmission Unit

最大传输单元

TCP

Transmission Control Protocol

传输控制协议

UDP

User Datagram Protocol

用户数据报协议

TCP/IP

A family of communication protocols used in computer networks

TCP/IP协议簇

LwIP

A Lightweight TCP/IP stack

一种轻量级TCP/IP协议栈

简介 Introduction

在AUTOSAR架构中,TcpIp模块介于SoAd模块和EthIf模块之间,TcpIp模块软件的设计是在遵循AUTOSAR R23-11规范的情况下,基于lwip代码开发而来。

In the AUTOSAR architecture, the TcpIp module is located between the SoAd module and the EthIf module.The software design of the TcpIp module is developed based on the lwip code while complying with the AUTOSAR R23-11 specification.

由于开发需求(暂时只实现IPv4),AUTOSAR规范本身存在的一些问题,以及lwip实现的功能情况,TcpIp模块代码并未完全实现AUTOSAR规范所有功能。

Due to development requirements (only IPv4 is implemented temporarily), certain issues existing in the AUTOSAR specification itself, and the functional implementation status of lwip,the TcpIp module code does not fully implement all functions specified in the AUTOSAR specification.

TcpIp模块的主要功能为:

The main functions of the TcpIp module are as follows:

1.为上层模块提供TCP、UDP数据报的收发接口(TCP涉及链接);

1.Provide upper-layer modules with interfaces for sending and receiving TCP and UDP datagrams (TCP involves connections);

2.基于IP数据报实现TCP/UDP数据报的封装、解析;

2.Implement encapsulation and parsing of TCP/UDP datagrams based on IP datagrams;

3.实现IP数据报收发所需要的DHCP、ICMP、ARP、AUTO-IP协议功能;

3.Implement the functions of DHCP, ICMP, ARP, and AUTO-IP protocols required for sending and receiving IP datagrams;

4.基于以太网数据报实现IP/ARP数据报的封装、解析。

4.Implement encapsulation and parsing of IP/ARP datagrams based on Ethernet datagrams.

../../../_images/image13.png

TcpIp模块层次图 (TcpIp Module Layer Diagram)

功能描述 Functional Description

System Scalability功能介绍 Introduction to System Scalability Function

根据不同的应用情况,TcpIp模块的功能(对IP协议的支持情况)分为三个等级。因开发需求,目前只支持IPv4,因此只支持SC1功能。

According to different application scenarios, the functions of the TcpIp module (support for IP protocols) are divided into three levels. Due to development requirements, only IPv4 is supported currently, so only the SC1 function is supported.

../../../_images/image23.png

TcpIp模块功能等级 (TcpIp Module Function Levels)

Internet Protocol Version 4功能介绍 Introduction to Internet Protocol Version 4 Function

IP协议是整个TCP/IP协议的核心,UDP、TCP、ICMP等协议都是基于IP来传送协议数据。IP协议是一种不可靠,尽最大努力,无连接的网络层协议。除了实现最基本的IP数据报的收发外,还需要完成IP数据报(长度较大)的分片和重组功能。

The IP protocol is the core of the entire TCP/IP protocol suite. Protocols such as UDP, TCP, and ICMP all transmit protocol data based on IP. The IP protocol is an unreliable, best-effort, connectionless network-layer protocol. In addition to implementing the basic sending and receiving of IP datagrams, it is also necessary to complete the fragmentation and reassembly functions for IP datagrams (with large lengths).

ARP协议,译作地址解析协议,ARP只适用于IPv4,在以太网中ARP数据报封装在以太网帧中进行发送。ARP协议的基本功能是使用目标主机的IP地址,查询其对应的MAC地址,以保证底层链路上数据报通信的进行。为了实现在网络接口中物理地址与IP地址间的转换,ARP协议中引入了缓存表的概念(记录了一条一条的<IP地址,MAC地址>对)。

The ARP protocol, translated as Address Resolution Protocol, is only applicable to IPv4. In Ethernet, ARP datagrams are encapsulated in Ethernet frames for transmission.The basic function of the ARP protocol is to use the IP address of the target host to query its corresponding MAC address, so as to ensure the transmission of datagrams on the underlying link.To realize the conversion between physical addresses and IP addresses in network interfaces, the ARP protocol introduces the concept of a cache table (which records <IP address, MAC address> pairs one by one).

AUTOIP协议是一个不用服务器来获取IP地址方法的协议,而DHCP需要一个服务器。一个配置了AUTOIP的主机将会得到一个高16 位为0xa9fe的IP地址(即169.254.xxx.xxx)。

The AUTOIP protocol is a protocol that obtains an IP address without a server, whereas DHCP requires a server.A host configured with AUTOIP will obtain an IP address whose upper 16 bits are 0xa9fe (i.e., 169.254.xxx.xxx).

IP协议完成了数据报在各个主机之间的递交,但是它并不完美,正如前面所说,它提供的是一种无连接的不可靠的数据报交付,协议本身不提供任何错误检验与恢复机制。

The IP protocol completes the delivery of datagrams between various hosts, but it is not perfect. As mentioned earlier,it provides a connectionless and unreliable datagram delivery service, and the protocol itself does not provide any error checking and recovery mechanisms.

为了弥补IP协议的缺陷,出现了ICMP协议。ICMP协议用于在主机、路由器之间传递控制消息(如数据报错误信息、网络状况信息、主机状况信息等)。ICMP协议配合IP协议完成数据报的递交,提高数据报递交的有效性,但是ICMP协议报文有着自己的组织结构,且ICMP报文是被封装在IP数据报中发送的。此外,ping命令,其本质上就是发送一个ICMP回送请求报文。

To make up for the shortcomings of the IP protocol, the ICMP protocol was introduced. The ICMP protocol is used to transmit control messages (such as datagram error information, network status information, host status information, etc.) between hosts and routers. The ICMP protocol cooperates with the IP protocol to complete the delivery of datagrams and improve the effectiveness of datagram delivery. However, ICMP protocol messages have their own organizational structure, and ICMP messages are encapsulated in IP datagrams for transmission. In addition, the ping command essentially sends an ICMP echo request message.

IP Based Protocols功能介绍 Introduction to IP Based Protocols Function

TcpIp模块维护一个本端IP地址表,每个本端IP地址的配置参见配置TcpIpLocalAddr,主要实现IP地址由何种方式分配,每个TcpIpLocalAddr有唯一的ID号(TcpIpAddrId)表示。

The TcpIp module maintains a local IP address table. The configuration of each local IP address refers to the configuration of TcpIpLocalAddr,which mainly specifies how the IP address is assigned. Each TcpIpLocalAddr is represented by a unique ID (TcpIpAddrId).

虽然按AUTOSAR标准,可支持N个本端IP地址关联到同一个硬件Controller,但限于LwIP功能实现,我们目前只支持每个TcpIpCtrl只能被一个单播(TCPIP_UNICAST)TcpIpLocalAddr关联。

Although according to the AUTOSAR standard, N local IP addresses can be associated with the same hardware Controller, limited by the functional implementation of LwIP,currently we only support that each TcpIpCtrl can be associated with only one unicast (TCPIP_UNICAST) TcpIpLocalAddr.

UDP称为用户数据报协议,是一种无连接的、不可靠的传输协议。

UDP, known as User Datagram Protocol, is a connectionless and unreliable transport protocol.

UDP只是简单地完成数据从一个进程到另一个进程的交付,它没有提供任何流量控制机制,收到的报文也没有确认;

UDP simply completes the delivery of data from one process to another. It does not provide any flow control mechanism, and there is no acknowledgment for received messages;

在差错控制上,只提供了一种简单的差错控制方法,即校验和计算,当UDP收到的报文校验和计算不成功时,它将丢弃掉这个报文。

In terms of error control, it only provides a simple error control method, namely checksum calculation. When the checksum calculation of a received UDP message fails, the message will be discarded.

UDP使用网络层的IP协议来发送报文。

UDP uses the IP protocol at the network layer to send messages.

TCP称为传输控制协议,是一种面向连接的、可靠的、基于字节流的传输层协议。为了保证传输的可靠性、高效性,TCP提供了一系列的机制,例如握手机制、正面确认、超时重传、以及各种定时机制等。

TCP, known as Transmission Control Protocol, is a connection-oriented, reliable, byte-stream-based transport layer protocol. To ensure the reliability and efficiency of transmission, TCP provides a series of mechanisms,such as a handshake mechanism, positive acknowledgment, timeout retransmission, and various timing mechanisms.

AUTOSAR标准中涉及的机制(TCP配置 )有:超时重传;慢启动与拥塞避免;快速重传与快速恢复;NAGLE算法;保活机制;收发窗口机制;定时机制。

The mechanisms involved in the AUTOSAR standard (TCP configuration) include: timeout retransmission; slow start and congestion avoidance; fast retransmission and fast recovery; NAGLE algorithm; keep-alive mechanism; send and receive window mechanisms; timing mechanisms.

DHCP使用UDP进行报文的传输。通过同DHCP服务器的交互,设备可以获得一个有效的IP地址,使得它可以在特定网络环境下运行。目前不支持DHCPv4和DHCPv6功能。

DHCP uses UDP for message transmission. Through interaction with a DHCP server, a device can obtain a valid IP address, enabling it to operate in a specific network environment. Currently, DHCPv4 and DHCPv6 functions are not supported.

TCP/IP Stack state handling功能介绍 Introduction to TCP/IP Stack State Handling Function

TcpIp的状态指的是每个Controller的状态,分为 TCPIP_STATE_OFFLINE、 TCPIP_STATE_STARTUP、 TCPIP_STATE_OFFLINE、 TCPIP_STATE_ONHOLD、 TCPIP_STATE_SHUTDOWN五种状态, 其中TCPIP_STATE_STARTUP和TCPIP_STATE_SHUTDOWN为中间过渡状态。

The state of TcpIp refers to the state of each Controller, which is divided into five states: TCPIP_STATE_OFFLINE, TCPIP_STATE_STARTUP, TCPIP_STATE_OFFLINE, TCPIP_STATE_ONHOLD, and TCPIP_STATE_SHUTDOWN. Among them, TCPIP_STATE_STARTUP and TCPIP_STATE_SHUTDOWN are intermediate transition states.

特性 Features

支持变体功能 Support variant function

支持TcpIpLocalAddr中Type、Domain等配置变体,以及子容器TcpIpAddrAssignment和TcpIpStaticIpAddressConfig。

Support configuration variants such as Type and Domain in TcpIpLocalAddr, as well as the sub-containers TcpIpAddrAssignment and TcpIpStaticIpAddressConfig.

偏差 Deviation

None

扩展 Extension

None

集成 Integration

文件列表 File List

静态文件 Static Files

文件(File)

描述(Description)

TcpIp.h

声明TcpIp模块的全部外部接口(除了回调函数),以及配置文件中的全局变量。(Declares all external interfaces of the TcpIp module (except callback functions) and global variables in the configuration file.)

TcpIp.c

作为TcpIp模块的核心文件,实现TcpIp模块全部对外接口, 以及实现TcpIp模块功能所必须的local函数,local宏定义,local变量定义。(Serves as the core file of the TcpIp module, implementing all external interfaces of the TcpIp module, as well as local functions, local macros, and local variable definitions necessary for implementing the functions of the TcpIp module.)

TcpIp_Types.h

定义TcpIp模块外部/内部类型,包括AUTOSAR标准定义的类型。(Defines external/internal types of the TcpIp module, including types defined by the AUTOSAR standard.)

TcpIp_Internal.h

声明TcpIp模块内部功能所必须的local函数,local宏定义,local变量。(Declares local functions, local macros, and local variables necessary for the internal functions of the TcpIp module.)

TcpIp_Internal.c

实现TcpIp模块内部功能所必须的local函数,local宏定义,local变量。(Implements local functions, local macros, and local variables necessary for the internal functions of the TcpIp module.)

TcpIp_DetError.h

声明TcpIp模块DET错误检测功能的函数接口。(Declares the function interfaces for the DET error detection function of the TcpIp module.)

TcpIp_DetError.c

实现TcpIp模块DET错误检测功能的函数接口。(Implements the function interfaces for the DET error detection function of the TcpIp module.)

TcpIp_MemMap.h

声明TcpIp模块内存布局。(Declares the memory mapping of the TcpIp module.)

动态文件 Dynamic Files

文件(File)

描述(Description)

TcpIp_CfgTypes.h

定义PB/PC配置参数结构体类型,以及内部运行时结构体类型。(Defines the structure types of PB/PC configuration parameters and internal runtime structure types.)

TcpIp_Cfg.h

定义TcpIp模块PC配置的宏定义。(Defines macros for the PC configuration of the TcpIp module.)

TcpIp_Cfg.c

定义TcpIp模块PC配置的结构体参数。(Defines the structure parameters for the PC configuration of the TcpIp module)

TcpIp_PBcfg.h

定义TcpIp模块PB配置的宏定义。(Defines macros for the PB configuration of the TcpIp module.)

TcpIp_PBcfg.c

定义TcpIp模块PB配置的结构体参数。(Defines the structure parameters for the PB configuration of the TcpIp module)

TcpIp_SocketOwner.h

定义为上层SocketOwner提供的接口函数。(Defines interface functions provided for the upper-layer SocketOwner.)

lwipopts.h

lwIp协议栈配置文件。(Configuration file for the lwIP protocol stack.)

错误处理 Error Handling

开发错误 Development Errors

Error code

Value[hex]

Description

TCPIP_E_UNINIT

0x01

API service called before initializing the module

TCPIP_E_PARAM_POINTER

0x02

API service called with NULL pointer

TCPIP_E_INV_ARG

0x03

Invalid argument

TCPIP_E_NOBUFS

0x04

No buffer space available

TCPIP_E_MSGSIZE

0x07

Message too long

TCPIP_E_PROTOTYPE

0x08

Protocol wrong type for socket

TCPIP_E_ADDRINUSE

0x09

Address already in use

TCPIP_E_ADDRNOTAVAIL

0x0A

Can’t assign requested address

TCPIP_E_ISCONN

0x0B

Socket is already connected

TCPIP_E_NOTCONN

0x0C

Socket is not connected

TCPIP_E_NOPROTOOPT

0x0D

Protocol not available

TCPIP_E_AFNOSUPPORT

0x0E

Address family not supported by protocol family

TCPIP_E_INIT_FAILED

0x0F

Invalid configuration set selection

产品错误 Product Errors

None

运行时错误 Runtime Errors

Error code

Value[hex]

Description

TCPIP_E_TIMEDOUT

0x01

Operation timed out

TCPIP_E_CONNREFUSED

0x02

Connection refused

TCPIP_E_HOSTUNREACH

0x03

No route to host

TCPIP_E_PACKETTOBIG

0x04

Path does not support frame size

TCPIP_E_DADCONFLICT

0x05

Duplicate IP Address detected

接口描述 Interface Description

类型定义 Type Definitions

None

提供的服务 Services

TcpIp_Init

void TcpIp_Init(const TcpIp_ConfigType *ConfigPtr)

This service initializes the TCP/IP Stack.TcpIp_Init may not block the start-up process for an indefinite amount of time.

Sync/Async

TRUE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

ConfigPtr

Pointer to the configuration data of the TcpIp module

Return type

void

TcpIp_GetVersionInfo

void TcpIp_GetVersionInfo(Std_VersionInfoType *versioninfo)

Returns the version information.

Sync/Async

TRUE

Reentrancy

Reentrant

Parameters

Dir

Name

Description

[out]

versioninfo

Pointer to where to store the version information of this module.

Return type

void

TcpIp_Close

Std_ReturnType TcpIp_Close(TcpIp_SocketIdType SocketId, boolean Abort)

By this API service the TCP/IP stack is requested to close the socket and release all related resources.

Sync/Async

FALSE

Reentrancy

Reentrant for different SocketIds. Non reentrant for the same SocketId.

Parameters

Dir

Name

Description

[in]

SocketId

Socket handle identifying the local socket resource.

[in]

Abort

TRUE: connection will immediately be terminated by sending a RST-Segment and releasing all related resources. FALSE: connection will be terminated after performing a regular connection termination handshake and releasing all related resources.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted.

TcpIp_Bind

Std_ReturnType TcpIp_Bind(TcpIp_SocketIdType SocketId, TcpIp_LocalAddrIdType LocalAddrId, uint16 *PortPtr)

By this API service the TCP/IP stack is requested to bind a UDP or TCP socket to a local resource.

Sync/Async

TRUE

Reentrancy

Reentrant for different SocketIds. Non reentrant for the same SocketId.

Parameters

Dir

Name

Description

[in]

SocketId

Socket identifier of the related local socket resource.

[in]

LocalAddrId

IP address identifier representing the local IP address and EthIf controller to bind the socket to.

[inout]

PortPtr

Pointer to memory where the local port to which the socket shall be bound is specified. In case the parameter is specified as TCPIP_PORT_ANY, the TCP/IP stack shall choose the local port automatically from the range 49152 to 65535 and shall update the parameter to the chosen value.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted (e.g. address in use).

TcpIp_TcpConnect

Std_ReturnType TcpIp_TcpConnect(TcpIp_SocketIdType SocketId, const TcpIp_SockAddrType *RemoteAddrPtr)

By this API service the TCP/IP stack is requested to establish a TCP connection to the configured peer.

Sync/Async

FALSE

Reentrancy

Reentrant for different SocketIds. Non reentrant for the same SocketId.

Parameters

Dir

Name

Description

[in]

SocketId

Socket identifier of the related local socket resource.

[in]

RemoteAddrPtr

IP address and port of the remote host to connect to.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted, e.g. connection is already established or no route to destination specified by remoteAddrPtr found.

TcpIp_TcpListen

Std_ReturnType TcpIp_TcpListen(TcpIp_SocketIdType SocketId, uint16 MaxChannels)

By this API service the TCP/IP stack is requested to listen on the TCP socket specified by the socket identifier.

Sync/Async

FALSE

Reentrancy

Reentrant for different SocketIds. Non reentrant for the same SocketId.

Parameters

Dir

Name

Description

[in]

SocketId

Socket identifier of the related local socket resource.

[in]

MaxChannels

Maximum number of new parallel connections established on this listen connection.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted, the socket is not configured to be a server socket.

TcpIp_TcpReceived

Std_ReturnType TcpIp_TcpReceived(TcpIp_SocketIdType SocketId, uint32 Length)

By this API service the reception of socket data is confirmed to the TCP/IP stack.

Sync/Async

FALSE

Reentrancy

Reentrant for different SocketIds. Non reentrant for the same SocketId.

Parameters

Dir

Name

Description

[in]

SocketId

Socket identifier of the related local socket resource.

[in]

Length

Number of bytes finally consumed by the upper layer.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted.

TcpIp_RequestComMode

Std_ReturnType TcpIp_RequestComMode(uint8 CtrlIdx, TcpIp_StateType State)

By this API service the TCP/IP stack is requested to change the TcpIp state of the communication network identified by EthIf controller index.

Sync/Async

FALSE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

CtrlIdx

EthIf controller index to identify the communication network where the TcpIp state is requested.

[in]

State

Requested TcpIp state.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

Service accepted.

E_NOT_OK

Service denied.

TcpIp_RequestIpAddrAssignment

Std_ReturnType TcpIp_RequestIpAddrAssignment(TcpIp_LocalAddrIdType LocalAddrId, TcpIp_IpAddrAssignmentType Type, const TcpIp_SockAddrType *LocalIpAddrPtr, uint8 Netmask, const TcpIp_SockAddrType *DefaultRouterPtr)

By this API service the local IP address assignment for the IP address specified by LocalAddrId shall be initiated.

Sync/Async

FALSE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

LocalAddrId

IP address index specifying the IP address for which an assignment shall be initiated.

[in]

Type

Type of IP address assignment which shall be initiated.

[in]

LocalIpAddrPtr

Pointer to structure containing the IP address which shall be assigned to the EthIf controller indirectly specified via LocalAddr Id.

[in]

Netmask

Network mask of IPv4 address or address prefix of IPv6 address in CIDR Notation.

[in]

DefaultRouterPtr

Pointer to structure containing the IP address of the default router (gateway) which shall be assigned.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted.

TcpIp_ReleaseIpAddrAssignment

Std_ReturnType TcpIp_ReleaseIpAddrAssignment(TcpIp_LocalAddrIdType LocalAddrId)

By this API service the local IP address assignment for the IP address specified by LocalAddrId shall be released.

Sync/Async

FALSE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

LocalAddrId

IP address index specifying the IP address for which an assignment shall be released.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted.

TcpIp_ResetIpAssignment

Std_ReturnType TcpIp_ResetIpAssignment(void)

Resets all learned IP-addresses to invalid values.

Sync/Async

TRUE

Reentrancy

Non reentrant

Return type

Std_ReturnType

Return values

Name

Description

E_OK

success.

E_NOT_OK

switch port could not be initialized.

TcpIp_IcmpTransmit

Std_ReturnType TcpIp_IcmpTransmit(TcpIp_LocalAddrIdType LocalIpAddrId, const TcpIp_SockAddrType *RemoteAddrPtr, uint8 Ttl, uint8 Type, uint8 Code, uint16 DataLength, const uint8 *DataPtr)

By this API service the TCP/IP stack sends an ICMP message according to the specified parameters.

Sync/Async

TRUE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

LocalIpAddrId

IP address identifier representing the local IP address and EthIf controller which shall be used for transmission of the ICMP message.

[in]

RemoteAddrPtr

pointer to struct representing the remote address.

[in]

Ttl

Time to live value to be used for the ICMP message. If 0 is specified the default value shall be used.

[in]

Type

type field value to be used in the ICMP message.

[in]

Code

code field value to be used in the ICMP message.

[in]

DataLength

length of ICMP message.

[in]

DataPtr

Pointer to data which shall be sent as ICMP message data

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The ICMP message has been sent successfully.

E_NOT_OK

The ICMP message was not sent.

TcpIp_IcmpV6Transmit

Std_ReturnType TcpIp_IcmpV6Transmit(TcpIp_LocalAddrIdType LocalIpAddrId, const TcpIp_SockAddrType *RemoteAddrPtr, uint8 HopLimit, uint8 Type, uint8 Code, uint16 DataLength, const uint8 *DataPtr)

By this API service the TCP/IP stack sends an ICMPv6 message according to the specified parameters.

Sync/Async

TRUE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

LocalIpAddrId

IP address identifier representing the local IP address and EthIf controller which shall be used for transmission of the ICMPv6 message.

[in]

RemoteAddrPtr

pointer to struct representing the remote address.

[in]

HopLimit

Hop Limit value to be used for the ICMPv6 message. If 0 is specified the default value shall be used.

[in]

Type

type field value to be used in the ICMPv6 message.

[in]

Code

code field value to be used in the ICMPv6 message.

[in]

DataLength

length of ICMPv6 message.

[in]

DataPtr

Pointer to data which shall be sent as ICMPv6 message data.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The ICMPv6 message has been sent successfully.

E_NOT_OK

The ICMPv6 message was not sent.

TcpIp_DhcpReadOption

Std_ReturnType TcpIp_DhcpReadOption(TcpIp_LocalAddrIdType LocalIpAddrId, uint8 Option, uint8 *DataLength, uint8 *DataPtr)

By this API service the TCP/IP stack retrieves DHCP option data identified by parameter option for already received DHCP options.

Sync/Async

TRUE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

LocalIpAddrId

IP address identifier representing the local IP address and EthIf controller for which the DHCP option shall be read.

[in]

Option

DHCP option (note: according to IANA DHCP Options).

[inout]

DataLength

As input parameter, contains the length of the provided data buffer. Will be overwritten with the length of the actual data.

[out]

DataPtr

Pointer to memory containing DHCP option data.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

requested data retrieved successfully.

E_NOT_OK

requested data could not be retrieved.

TcpIp_DhcpV6ReadOption

Std_ReturnType TcpIp_DhcpV6ReadOption(TcpIp_LocalAddrIdType LocalIpAddrId, uint16 Option, uint16 *DataLength, uint8 *DataPtr)

By this API service the TCP/IP stack retrieves DHCPv6 option data identified by parameter option for already received DHCPv6 options.

Sync/Async

TRUE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

LocalIpAddrId

IP address identifier representing the local IP address and EthIf controller for which the DHCPv6 option shall be read.

[in]

Option

DHCP option (note: according to IANA DHCP[v6] Options).

[inout]

DataLength

As input parameter, contains the length of the provided data buffer. Will be overwritten with the length of the actual data.

[out]

DataPtr

Pointer to memory containing DHCPv6 option data.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

requested data retrieved successfully.

E_NOT_OK

requested data could not be retrieved.

TcpIp_DhcpWriteOption

Std_ReturnType TcpIp_DhcpWriteOption(TcpIp_LocalAddrIdType LocalIpAddrId, uint8 Option, uint8 DataLength, const uint8 *DataPtr)

By this API service the TCP/IP stack writes the DHCP option data identified by parameter option.

Sync/Async

TRUE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

LocalIpAddrId

IP address identifier representing the local IP address and EthIf controller for which the DHCP option shall be written.

[in]

Option

DHCP option (note: according to IANA DHCP Options).

[in]

DataLength

length of DHCP option data.

[in]

DataPtr

Pointer to memory containing DHCP option data

Return type

Std_ReturnType

Return values

Name

Description

E_OK

no error occured.

E_NOT_OK

DHCP option data could not be written.

TcpIp_DhcpV6WriteOption

Std_ReturnType TcpIp_DhcpV6WriteOption(TcpIp_LocalAddrIdType LocalIpAddrId, uint16 Option, uint16 DataLength, const uint8 *DataPtr)

By this API service the TCP/IP stack writes the DHCPv6 option data identified by parameter option.

Sync/Async

TRUE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

LocalIpAddrId

IP address identifier representing the local IP address and EthIf controller for which the DHCPv6 option shall be written.

[in]

Option

DHCP option (note: according to IANA DHCP[v6] Options).

[in]

DataLength

length of DHCPv6 option data.

[in]

DataPtr

Pointer to memory containing DHCPv6 option data.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

no error occured.

E_NOT_OK

DHCPv6 option data could not be written.

TcpIp_ChangeParameter

Std_ReturnType TcpIp_ChangeParameter(TcpIp_SocketIdType SocketId, TcpIp_ParamIdType ParameterId, const uint8 *ParameterValue)

By this API service the TCP/IP stack is requested to change a parameter of a socket. E.g. the Nagle algorithm may be controlled by this API.

Sync/Async

TRUE

Reentrancy

Reentrant for different SocketIds. Non reentrant for the same SocketId.

Parameters

Dir

Name

Description

[in]

SocketId

Socket identifier of the related local socket resource.

[in]

ParameterId

Identifier of the parameter to be changed.

[in]

ParameterValue

Pointer to memory containing the new parameter value.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The parameter has been changed successfully.

E_NOT_OK

The parameter could not be changed.

TcpIp_GetIpAddr

Std_ReturnType TcpIp_GetIpAddr(TcpIp_LocalAddrIdType LocalAddrId, TcpIp_SockAddrType *IpAddrPtr, uint8 *NetmaskPtr, TcpIp_SockAddrType *DefaultRouterPtr)

Obtains the local IP address actually used by LocalAddrId, the netmask and default router.

Sync/Async

TRUE

Reentrancy

Reentrant

Parameters

Dir

Name

Description

[in]

LocalAddrId

Local address identifier referring to the local IP address which shall be obtained.

[inout]

IpAddrPtr

Pointer to a struct where the IP address shall be stored. The struct member domain shall be set to the desired TcpIp_Domain Type and it shall be ensured that the struct is large enough to store an address of the selected type (INET or INET6). Struct members not related to the IP address are of arbitrary value and shall not be used.

[out]

NetmaskPtr

Pointer to memory where Network mask of IPv4 address or address prefix of IPv6 address in CIDR Notation is stored.

[inout]

DefaultRouterPtr

Pointer to struct where the IP address of the default router (gateway) is stored (struct member “port” is not used and of arbitrary value). The struct must be of the same type and size as IpAddrPtr.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request was successful.

E_NOT_OK

The request was not successful, e.g. domain in Ip AddrPtr and the local domain type do not match.

TcpIp_GetPhysAddr

Std_ReturnType TcpIp_GetPhysAddr(TcpIp_LocalAddrIdType LocalAddrId, uint8 *PhysAddrPtr)

Obtains the physical source address used by the EthIf controller implicitly specified via Local AddrId.

Sync/Async

TRUE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

LocalAddrId

Local address identifier implicitely specifing the EthIf controller for which the physical address shall be obtained.

[out]

PhysAddrPtr

Pointer to the memory where the physical source address (MAC address) in network byte order is stored.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request was successful.

E_NOT_OK

The request was not successful, e.g. no unique Ctrl specified via IpAddrId.

TcpIp_GetRemotePhysAddr

TcpIp_ReturnType TcpIp_GetRemotePhysAddr(uint8 CtrlIdx, const TcpIp_SockAddrType *IpAddrPtr, uint8 *PhysAddrPtr, boolean initRes)

TcpIp_GetRemotePhysAddr queries the IP/physical address translation table specified by Ctrl Idx and returns the physical address related to the IP address specified by IpAddrPtr. In case no physical address can be retrieved and parameter initRes is TRUE, address resolution for the specified IP address is initiated on the local network.

Sync/Async

TRUE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

CtrlIdx

EthIf controller index to identify the related ARP/NDP table.

[in]

IpAddrPtr

specifies the IP address for which the physical address shall be retrieved.

[out]

PhysAddrPtr

Pointer to the memory where the physical address (MAC address) related to the specified IP address is stored in network byte order.

[in]

initRes

specifies if the address resolution shall be initiated (TRUE) or not (FALSE) in case the physical address related to the specified IP address is currently unknown.

Return type

TcpIp_ReturnType

Return values

Name

Description

TCPIP_E_OK

specified IP address resolved, physical address provided via PhysAddrPtr.

TCPIP_E_PHYS_ADDR_MISS

physical address currently unknown (address resolution initiated if initRes set to TRUE).

TcpIp_GetCtrlIdx

Std_ReturnType TcpIp_GetCtrlIdx(TcpIp_LocalAddrIdType LocalAddrId, uint8 *CtrlIdxPtr)

TcpIp_GetCtrlIdx returns the index of the controller related to LocalAddrId.

Sync/Async

TRUE

Reentrancy

Reentrant

Parameters

Dir

Name

Description

[in]

LocalAddrId

Local address identifier implicitely specifing the EthIf controller that shall be returned.

[out]

CtrlIdxPtr

Pointer to the memory where the index of the controller related to LocalAddrId is stored.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

the request was successful.

E_NOT_OK

the request was not successful.

TcpIp_GetArpCacheEntries

Std_ReturnType TcpIp_GetArpCacheEntries(uint8 ctrlIdx, uint32 *numberOfElements, TcpIp_ArpCacheEntryType *entryListPtr)

Copies entries from the physical address cache of the IPv4 instance that is active on the EthIf controller specified by ctrlIdx into a user provided buffer. The function will copy all or numberOf Elements into the output list. If input value of numberOfElements is 0 the function will not copy any data but only return the number of valid entries in the cache. EntryListPtr may be NULL_PTR in this case.

Sync/Async

TRUE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

ctrlIdx

EthIf controller index to identify the related ARP table.

[inout]

numberOfElements

In: Maximum number of entries that can be stored in output entry ListPtr. Out: Number of entries written to output entryListPtr (Number of all entries in the cache if input value is 0).

[out]

entryListPtr

Pointer to memory where the list of cache entries shall be stored.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

physical address cache could be read.

E_NOT_OK

physical address cache could not be read (i.e. no IPv4 instance active on this controller).

TcpIp_GetNdpCacheEntries

Std_ReturnType TcpIp_GetNdpCacheEntries(uint8 ctrlIdx, uint32 *numberOfElements, TcpIp_NdpCacheEntryType *entryListPtr)

Copies entries from the physical address cache of the IPv6 instance that is active on the EthIf controller specified by ctrlIdx into a user provided buffer. The function will copy all or numberOf Elements into the output list. If input value of numberOfElements is 0 the function will not copy any data but only return the number of valid entries in the cache. EntryListPtr may be NULL_PTR in this case.

Sync/Async

TRUE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

ctrlIdx

EthIf controller index to identify the related NDP table.

[inout]

numberOfElements

In: Maximum number of entries that can be stored in output entry ListPtr. Out: Number of entries written to output entryListPtr (Number of all entries in the cache if input value is 0).

[out]

entryListPtr

Pointer to memory where the list of cache entries shall be stored.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

physical address cache could be read.

E_NOT_OK

physical address cache could not be read (i.e. no IPv6 instance active on this controller).

TcpIp_GetAndResetMeasurementData

Std_ReturnType TcpIp_GetAndResetMeasurementData(TcpIp_MeasurementIdxType MeasurementIdx, boolean MeasurementResetNeeded, uint32 *MeasurementDataPtr)

Allows to read and reset detailed measurement data for diagnostic purposes. Get all MeasurementIdx’s at once is not supported. TCPIP_MEAS_ALL shall only be used to reset all MeasurementIdx’s at once. A NULL_PTR shall be provided for MeasurementDataPtr in this case.

Sync/Async

TRUE

Reentrancy

Reentrant

Parameters

Dir

Name

Description

[in]

MeasurementIdx

Data index of measurement data

[in]

MeasurementResetNeeded

Flag to trigger a reset of the measurement data

[out]

MeasurementDataPtr

Reference to data buffer, where to copy measurement data

Return type

Std_ReturnType

Return values

Name

Description

E_OK

successful.

E_NOT_OK

failed.

TcpIp_IsConnectionReady

TcpIp_ReturnType TcpIp_IsConnectionReady(TcpIp_SocketIdType SocketId, const TcpIp_SockAddrType *RemoteAddrPtr)

API allows to check if a communication over this socket is possible for a dedicated remote address. It includes that the socket is bound, a physical address is available for the requested remote address and if a security association is configured that a secured connection is already established.

Sync/Async

TRUE

Reentrancy

Reentrant for different SocketIds. Non reentrant for the same SocketId.

Parameters

Dir

Name

Description

[in]

SocketId

Socket handle identifying the local socket resource.

[in]

RemoteAddrPtr

Pointer to the structure containing the requested remote IP address and port.

Return type

TcpIp_ReturnType

Return values

Name

Description

TCPIP_E_OK

SocketId is ready for communication.

TCPIP_E_NOT_OK

Request was rejected.

TCPIP_E_PENDING

Connection establishment in progress.

TcpIp_UdpTransmit

Std_ReturnType TcpIp_UdpTransmit(TcpIp_SocketIdType SocketId, const uint8 *DataPtr, const TcpIp_SockAddrType *RemoteAddrPtr, uint16 TotalLength)

This service transmits data via UDP to a remote node. The transmission of the data is immediately performed with this function call by forwarding it to EthIf.

Sync/Async

TRUE

Reentrancy

Reentrant for different SocketIds. Non reentrant for the same SocketId.

Parameters

Dir

Name

Description

[in]

SocketId

Socket identifier of the related local socket resource.

[in]

DataPtr

Pointer to a linear buffer of TotalLength bytes containing the data to be transmitted. In case DataPtr is a NULL_PTR, TcpIp shall retrieve data from upper layer via callback <Up>_CopyTxData().

[in]

RemoteAddrPtr

IP address and port of the remote host to transmit to.

[in]

TotalLength

indicates the payload size of the UDP datagram.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

Request to transmit the UDP message has been accepted.

E_NOT_OK

UDP message could not be sent because of a permanent error, e.g. message is too long.

TcpIp_TcpTransmit

Std_ReturnType TcpIp_TcpTransmit(TcpIp_SocketIdType SocketId, const uint8 *DataPtr, uint32 AvailableLength, boolean ForceRetrieve)

This service requests transmission of data via TCP to a remote node.The transmission of the data is decoupled.

Sync/Async

FALSE

Reentrancy

Reentrant for different SocketIds. Non reentrant for the same SocketId.

Parameters

Dir

Name

Description

[in]

SocketId

Socket identifier of the related local socket resource.

[in]

DataPtr

Pointer to a linear buffer of AvailableLength bytes containing the data to be transmitted. In case DataPtr is a NULL_PTR, TcpIp shall retrieve data from upper layer via callback <Up>_CopyTx Data().

[in]

AvailableLength

Available data for transmission in bytes.

[in]

ForceRetrieve

This parameter is only valid if DataPtr is a NULL_PTR. Indicates how the TCP/IP stack retrieves data from upper layer if DataPtr is a NULL_PTR. TRUE: the whole data indicated by availableLength shall be retrieved from the upper layer via one or multiple <Up>_ CopyTxData() calls within the context of this transmit function. FALSE: The TCP/IP stack may retrieve up to availableLength data from the upper layer. It is allowed to retrieve less than availableLength bytes.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted, e.g. due to a lack of buffer space or the socket is not connected.

TcpIp_RxIndication

void TcpIp_RxIndication(uint8 CtrlIdx, Eth_FrameType FrameType, boolean IsBroadcast, const uint8 *PhysAddrPtr, const uint8 *DataPtr, uint16 LenByte)

By this API service the TCP/IP stack gets an indication and the data of a received frame.

Sync/Async

TRUE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

CtrlIdx

Index of the EthIf controller.

[in]

FrameType

frame type of received Ethernet frame.

[in]

IsBroadcast

parameter to indicate a broadcast frame.

[in]

PhysAddrPtr

pointer to Physical source address (MAC address in network byte order) of received Ethernet frame.

[in]

DataPtr

Pointer to payload of the received Ethernet frame (i.e. Ethernet header is not provided).

[in]

LenByte

Length of received data.

Return type

void

TcpIp_MainFunction

void TcpIp_MainFunction(ApplicationType partitionIndex)

Schedules the TCP/IP stack.(Entry point for scheduling)

Sync/Async

TRUE

Reentrancy

Non reentrant

Parameters

Dir

Name

Description

[in]

partitionIndex

Index of partition.

Return type

void

TcpIp_MainFunction

void TcpIp_MainFunction(void)

Schedules the TCP/IP stack.(Entry point for scheduling)

Sync/Async

TRUE

Reentrancy

Non reentrant

Return type

void

TcpIp_GetSocket

Std_ReturnType TcpIp_GetSocket(TcpIp_DomainType Domain, TcpIp_ProtocolType Protocol, #if(1u< TCPIP_SOCKETOWNER_NUMBER) uint8 socketOwnerId, #endif TcpIp_SocketIdType *SocketIdPtr)

By this API service the TCP/IP stack is requested to allocate a new socket. Note: Each accepted incoming TCP connection also allocates a socket resource.

Sync/Async

TRUE

Reentrancy

TRUE

Parameters

Dir

Name

Description

[in]

Domain

IP address family.

[in]

Protocol

Socket protocol as sub-family of parameter type.

[in]

socketOwnerId

TcpIpSocketOwnerId

[out]

SocketIdPtr

Pointer to socket identifier representing the requested socket. This socket identifier must be provided for all further API calls which requires a SocketId. Note: SocketIdPtr is only valid if return value is E_OK.

Return type

Std_ReturnType

Return values

Name

Description

E_OK

The request has been accepted.

E_NOT_OK

The request has not been accepted: no free socket.

配置 Configuration

System Scalability功能 System Scalability Function

根据配置项TcpIpGeneral->TcpIpScalabilityClass实现TcpIp功能等级的配置,目前工具固定配置为SC1,不可改。

The configuration of the TcpIp function level is implemented according to the configuration item TcpIpGeneral->TcpIpScalabilityClass. Currently, the tool fixes the configuration to SC1, which cannot be modified.

因为SC1只支持基于IPv4协议实现的功能,所以关于IPv6的配置(配置时,忽略所有IPv6相关配置项)、API等都不支持。

Since SC1 only supports functions implemented based on the IPv4 protocol, configurations (all IPv6-related configuration items are ignored during configuration), APIs, etc., related to IPv6 are not supported.

Internet Protocol Version 4功能 Internet Protocol Version 4 Function

../../../_images/image33.png

TcpIpIpV4General

该部分的功能主要体现在TcpIpIpV4General的配置Container中,涉及的配置参数及功能如下:

The functions of this part are mainly reflected in the configuration Container of TcpIpIpV4General. The involved configuration parameters and their functions are as follows:

1.TcpIpArpEnabled:是否使能ARP功能;

1.TcpIpArpEnabled: Whether to enable the ARP function;

2.TcpIpAutoIpEnabled:是否使能AUTOIP功能(未实现);

2.TcpIpAutoIpEnabled: Whether to enable the AUTOIP function (not implemented);

3.TcpIpDhcpClientEnabled:是否使能DHCP客户端功能(未实现);

3.TcpIpDhcpClientEnabled: Whether to enable the DHCP client function (not implemented);

4.TcpIpIcmpEnabled:是否使能ICMP功能;

4.TcpIpIcmpEnabled: Whether to enable the ICMP function;

5.TcpIpIpV4Enabled:是否使能IPv4功能;

5.TcpIpIpV4Enabled: Whether to enable the IPv4 function;

6.TcpIpLocalAddrIpv4EntriesMax:限制TcpIpLocalAddr配置项(IPv4)的总数目;

6.TcpIpLocalAddrIpv4EntriesMax: Limits the total number of TcpIpLocalAddr configuration items (for IPv4);

7.TcpIpPathMtuDiscoveryEnabled:是否使能MTU发现机制(未实现)。

7.TcpIpPathMtuDiscoveryEnabled: Whether to enable the MTU discovery mechanism (not implemented).

我们根据AUTOSAR配置,转化成lwIP的配置(工具生成lwipopts.h文件),进而实现功能的可配置性。

We convert the AUTOSAR configuration into the configuration of lwIP (the tool generates the lwipopts.h file), thereby realizing the configurability of functions.

../../../_images/image41.png

TcpIpIpFragmentationConfig

IPv4:该部分的功能主要体现在IPv4接收数据报的重组功能上,TcpIpIpConfig->TcpIpIpV4Config->TcpIpIpFragmentationConfig的配置Container中,涉及的配置参数及功能如下:

IPv4: The functions of this part are mainly reflected in the reassembly function of received IPv4 datagrams, and the configuration Container of TcpIpIpConfig->TcpIpIpV4Config->TcpIpIpFragmentationConfig. The involved configuration parameters and their functions are as follows:

1.TcpIpIpFragmentationRxEnabled:是否使能接收重组功能;

1.TcpIpIpFragmentationRxEnabled: Whether to enable the receive reassembly function;

2.TcpIpIpNumFragments:每个IP数据报最多的分片数目(在TcpIpIpFragmentationRxEnabled使能的情况下);

2.TcpIpIpNumFragments: The maximum number of fragments for each IP datagram (when TcpIpIpFragmentationRxEnabled is enabled);

3.TcpIpIpFragmentationRxEnabled:并行处理多少IP数据报的接收重组(在TcpIpIpFragmentationRxEnabled使能的情况下);

3.TcpIpIpFragmentationRxEnabled: The number of IP datagrams for which receive reassembly is processed in parallel (when TcpIpIpFragmentationRxEnabled is enabled);

4.TcpIpIpReassTimeout:重组超时时间(在TcpIpIpFragmentationRxEnabled使能的情况下)。

4.TcpIpIpReassTimeout: The reassembly timeout period (when TcpIpIpFragmentationRxEnabled is enabled).

../../../_images/image51.png

TcpIpArpConfig

ARP:该部分的功能体现在TcpIpIpConfig->TcpIpIpV4Config->TcpIpArpConfig的配置Container中,涉及的配置参数及功能如下:

ARP: The functions of this part are reflected in the configuration Container of TcpIpIpConfig->TcpIpIpV4Config->TcpIpArpConfig. The involved configuration parameters and their functions are as follows:

1.TcpIpArpNumGratuitousARPonStartup:当获取到IP地址对外广播自己的<IP地址,MAC地址>,该参数为广播的次数,因基于LwIP实现(固定为1次,不可改配置);

1.TcpIpArpNumGratuitousARPonStartup: When an IP address is obtained, the <IP address, MAC address> of the host is broadcast to the outside. This parameter specifies the number of broadcasts. Due to the implementation based on LwIP (fixed to 1 time, which cannot be modified in configuration);

2.TcpIpArpPacketQueueEnabled:是否使能ARP在未获取目的MAC地址之前缓存请求发送的IP报;

2.TcpIpArpPacketQueueEnabled: Whether to enable ARP to cache IP packets that request to be sent before obtaining the destination MAC address;

3.TcpIpArpTableEntryTimeout:ARP缓存表(Entry)的生存时间(超时则从缓存表中移除该Entry);

3.TcpIpArpTableEntryTimeout: The lifetime of an entry in the ARP cache table (the entry will be removed from the cache table when it times out);

4.TcpIpArpTableSizeMax:ARP缓存表的Size(即Entry的数目)。

4.TcpIpArpTableSizeMax: The size of the ARP cache table (i.e., the number of entries).

../../../_images/image61.png

TcpIpIcmpConfig

ICMP:该部分的功能体现在TcpIpIpConfig->TcpIpIpV4Config->TcpIpIcmpConfig的配置Container中,涉及的配置参数及功能如下:

ICMP: The functions of this part are reflected in the configuration Container of TcpIpIpConfig->TcpIpIpV4Config->TcpIpIcmpConfig. The involved configuration parameters and their functions are as follows:

1.TcpIpIcmpTtl:ICMP数据报Ttl参数(该参数封装在IP报首部);

1.TcpIpIcmpTtl: The Ttl parameter of the ICMP datagram (this parameter is encapsulated in the header of the IP packet);

2.TcpIpIcmpMsgHandler(包含参数TcpIpIcmpMsgHandlerHeaderFileName和TcpIpIcmpMsgHandlerName):主要是配置ICMP报文的接收函数,TcpIp接收到ICMP报文时调用该配置API传递给上层模块。该功能未实现,在工具上对该配置Container进行了限制(无法添加)。

2.TcpIpIcmpMsgHandler (including parameters TcpIpIcmpMsgHandlerHeaderFileName and TcpIpIcmpMsgHandlerName): It is mainly used to configure the receiving function for ICMP messages. When the TcpIp module receives an ICMP message, it calls this configured API to pass the message to the upper-layer module. This function is not implemented, and restrictions have been imposed on this configuration Container in the tool (cannot be added).

3.TcpIp模块除了在lwip代码中实现部分ICMP常用功能,还为上层模块提供ICMPv4数据报发送接口TcpIp_IcmpTransmit。但未实现ICMP数据报上传上层模块的功能(参见配置TcpIpIcmpMsgHandler说明)。

3.In addition to implementing some common ICMP functions in the lwIP code, the TcpIp module also provides the upper-layer module with the ICMPv4 datagram sending interface TcpIp_IcmpTransmit. However, the function of uploading ICMP datagrams to the upper-layer module is not implemented (see the description of configuring TcpIpIcmpMsgHandler).

IP Based Protocols功能 IP Based Protocols Function

../../../_images/image71.png

TcpIpAddrAssignment

每个TcpIpLocalAddr配置Container中,主要实现了IP地址的分配机制TcpIpAddrAssignment(考虑到目前标准的不完善以及代码实现的复杂性,暂只支持配置一个IP分配机制)。其中,

In each TcpIpLocalAddr configuration Container, the main function is to implement the IP address assignment mechanism TcpIpAddrAssignment (considering the current imperfection of the standard and the complexity of code implementation, only one IP assignment mechanism can be configured temporarily). Among them,

1.TcpIpAssignmentLifetime用以实现分配永久IP的功能未实现(暂无该需求);

1.The function of TcpIpAssignmentLifetime for implementing permanent IP assignment is not implemented (no such requirement currently);

2.TcpIpAssignmentMethod项可根据需求选择何种分配方式(DHCP/AUTO-IP/STATIC等);

2.The TcpIpAssignmentMethod item allows selecting the assignment method (DHCP/AUTO-IP/STATIC, etc.) according to requirements;

3.TcpIpAssignmentPriority分配方式优先级,用于配置了多个TcpIpAddrAssignment时(目前不支持);

3.TcpIpAssignmentPriority is the priority of the assignment method, which is used when multiple TcpIpAddrAssignment configurations are set (not supported currently);

4.TcpIpAssignmentTrigger用于配置IP分配是自动还是手动方式,自动方式是当调用TcpIp_RequestComMode请求TCPIP_STATE_ONLINE时自动通过配置的IP分配机制请求IP分配,手动方式需要上层模块通过调用TcpIp_RequestIpAddrAssignment,TcpIp_ReleaseIpAddrAssignment来请求IP的分配和释放。

4.TcpIpAssignmentTrigger is used to configure whether IP assignment is automatic or manual. In the automatic mode, when TcpIp_RequestComMode is called to request TCPIP_STATE_ONLINE, IP assignment is automatically requested through the configured IP assignment mechanism. In the manual mode, the upper-layer module needs to call TcpIp_RequestIpAddrAssignment and TcpIp_ReleaseIpAddrAssignment to request IP assignment and release respectively.

当TcpIpAssignmentMethod配置为TCPIP_STATIC方式时,才可选择是否配置TcpIpStaticIpAddressConfig (当TcpIpAssignmentTrigger配置为TCPIP_AUTOMATIC时,必须配置;当配置为TCPIP_MANUAL时,可配可不配,当未配置时,调用TcpIp_RequestIpAddrAssignment请求IP分配时,IP地址参数不能为空)。当IP地址状态改变时,调用Up_LocalIpAddrAssignmentChg通知上层模块。

When TcpIpAssignmentMethod is configured as TCPIP_STATIC, you can choose whether to configure TcpIpStaticIpAddressConfig (When TcpIpAssignmentTrigger is configured as TCPIP_AUTOMATIC, configuration is mandatory; When configured as TCPIP_MANUAL, configuration is optional. If not configured, the IP address parameter cannot be empty when TcpIp_RequestIpAddrAssignment is called to request IP assignment). When the IP address state changes, Up_LocalIpAddrAssignmentChg is called to notify the upper-layer module.

../../../_images/image81.png

TcpIpUdpConfig

UDP的配置参数只有TcpIpUdpTtl,该信息封装在相应IP报的首部。TcpIp为上层模块提供接口TcpIp_UdpTransmit来发送UDP报文,当收到UDP接收报文时,通过调用Up_RxIndication(一般为SoAd_RxIndication)传递给上层。

The only configuration parameter for UDP is TcpIpUdpTtl, and this information is encapsulated in the header of the corresponding IP packet. The TcpIp module provides the interface TcpIp_UdpTransmit for the upper-layer module to send UDP messages. When a UDP receive message is received, it is passed to the upper layer by calling Up_RxIndication (generally SoAd_RxIndication).

TcpIp模块除了为上层模块提供了发送接口TcpIp_TcpTransmit,收到TCP报文通过调用Up_RxIndication(一般为SoAd_RxIndication)传递给上层外,还涉及,

In addition to providing the upper-layer module with the sending interface TcpIp_TcpTransmit, and passing received TCP messages to the upper layer by calling Up_RxIndication (generally SoAd_RxIndication), the TcpIp module also involves the following:

1.作为客户端的链接接口TcpIp_TcpConnect

1.TcpIp_TcpConnect: The connection interface used as a client;

2.作为服务端进入监听模式(等待客户端发起链接请求)接口TcpIp_TcpListen

2.TcpIp_TcpListen: The interface for the server to enter the listening mode (waiting for connection requests initiated by the client);

3.增大接收窗口的接口TcpIp_TcpReceived(上层模块接收到数据需要调用该接口来释放TcpIp模块中TCP的接收窗口)

3.TcpIp_TcpReceived: The interface for increasing the receive window (the upper-layer module needs to call this interface to release the TCP receive window in the TcpIp module after receiving data).

../../../_images/image9.png

TcpIpTcpConfig

通过配置TcpIpTcpConfig(Container)的各个配置参数来说明TCP的功能实现:

The functional implementation of TCP is illustrated by configuring each configuration parameter in TcpIpTcpConfig (Container):

1.TcpIpTcpCongestionAvoidanceEnabled:拥塞避免功能(固定使能);

1.TcpIpTcpCongestionAvoidanceEnabled: Congestion avoidance function (enabled by default);

2.TcpIpTcpFastRecoveryEnabled:快速恢复功能(固定使能);

2.TcpIpTcpFastRecoveryEnabled: Fast recovery function (enabled by default);

3.TcpIpTcpFastRetransmitEnabled:快速重传功能(固定使能);

3.TcpIpTcpFastRetransmitEnabled: Fast retransmission function (enabled by default);

4.TcpIpTcpFinWait2Timeout:客户端发送FIN并收到服务端ACK后进入FIN_WAIT_2状态,在该状态下等待服务器端发送FIN的时间;

4.TcpIpTcpFinWait2Timeout: After the client sends a FIN and receives an ACK from the server, it enters the FIN_WAIT_2 state. This parameter is the time to wait for the server to send a FIN in this state;

5.TcpIpTcpKeepAliveEnabled:是否使能TCP保活机制;

5.TcpIpTcpKeepAliveEnabled: Whether to enable the TCP keep-alive mechanism;

6.TcpIpTcpKeepAliveInterval:(在TcpIpTcpKeepAliveEnabled使能前提下才有效)保活探测报文的发送间隔时间;

6.TcpIpTcpKeepAliveInterval: (Effective only when TcpIpTcpKeepAliveEnabled is enabled) The interval for sending keep-alive probe messages;

7.TcpIpTcpKeepAliveProbesMax:(在TcpIpTcpKeepAliveEnabled使能前提下才有效)保活探测报文的发送最大次数;

7.TcpIpTcpKeepAliveProbesMax: (Effective only when TcpIpTcpKeepAliveEnabled is enabled) The maximum number of keep-alive probe messages to be sent;

8.TcpIpTcpKeepAliveTime:(在TcpIpTcpKeepAliveEnabled使能前提下才有效)TCP最后一次通信,与第一次保活探测报文发送的时间间隔;

8.TcpIpTcpKeepAliveTime: (Effective only when TcpIpTcpKeepAliveEnabled is enabled) The time interval between the last TCP communication and the first keep-alive probe message;

9.TcpIpTcpMaxRtx:TCP报文最大重传次数(LwIP最大支持13次);

9.TcpIpTcpMaxRtx: The maximum number of retransmissions for TCP messages (lwIP supports a maximum of 13 times);

10.TcpIpTcpMsl:TCP客户端在TIME_WAIT状态下需要等待2×MSL时间才能切换到CLOSED状态;

10.TcpIpTcpMsl: The TCP client needs to wait for 2×MSL time in the TIME_WAIT state before switching to the CLOSED state;

11.TcpIpTcpNagleEnabled:糊涂窗口避免功能(固定使能);

11.TcpIpTcpNagleEnabled: Silly window avoidance function (enabled by default);

12.TcpIpTcpReceiveWindowMax:接收窗口最大值;

12.TcpIpTcpReceiveWindowMax: The maximum value of the receive window;

13.TcpIpTcpRetransmissionTimeout:超时重传的超时时间,不支持(LWIP中重传超时RTT是根据网络状况动态计算的,不是固定配置值);

13.TcpIpTcpRetransmissionTimeout: The timeout period for timeout retransmission (not supported; the retransmission timeout RTT in LWIP is dynamically calculated based on network conditions, not a fixed configuration value);

14.TcpIpTcpSlowStartEnabled:慢启动功能(固定使能);

14.TcpIpTcpSlowStartEnabled: Slow start function (enabled by default);

15.TcpIpTcpSynMaxRtx:链接请求重传最大次数(LwIP最大支持13次);

15.TcpIpTcpSynMaxRtx: The maximum number of retransmissions for connection requests (lwIP supports a maximum of 13 times);

16.TcpIpTcpSynReceivedTimeout:服务端收到SYN后,回复SYN/ACK,进入到SYN_RCVD状态,在该状态等待客户端回复ACK的时间;

16.TcpIpTcpSynReceivedTimeout: After the server receives a SYN, it replies with a SYN/ACK and enters the SYN_RCVD state. This parameter is the time to wait for the client to reply with an ACK in this state;

17.TcpIpTcpTtl:该信息封装在相应IP报首部。

17.TcpIpTcpTtl: This information is encapsulated in the header of the corresponding IP packet.