WO2012051840A1 - 一种smtp的协议栈系统及其实现方法 - Google Patents

一种smtp的协议栈系统及其实现方法 Download PDF

Info

Publication number
WO2012051840A1
WO2012051840A1 PCT/CN2011/072878 CN2011072878W WO2012051840A1 WO 2012051840 A1 WO2012051840 A1 WO 2012051840A1 CN 2011072878 W CN2011072878 W CN 2011072878W WO 2012051840 A1 WO2012051840 A1 WO 2012051840A1
Authority
WO
WIPO (PCT)
Prior art keywords
module
message
link
mail
value
Prior art date
Application number
PCT/CN2011/072878
Other languages
English (en)
French (fr)
Inventor
童遥
田贞朗
钱建阳
舒畅
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2012051840A1 publication Critical patent/WO2012051840A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/06Message adaptation to terminal or network requirements
    • H04L51/066Format adaptation, e.g. format conversion or compression

Definitions

  • the present invention relates to the field of communication network technologies, and in particular, to a protocol stack system of a Simple Mail Transfer Protocol (SMTP) and an implementation method thereof.
  • SMTP Simple Mail Transfer Protocol
  • SMTP Simple Mail Transfer Protocol
  • RFC 821 Request For Comments
  • SMTP is part of the Transmission Control Protocol/Network Interconnection Protocol (TCP/IP) suite of protocols that helps each computer find the next destination when sending or forwarding a message.
  • E-mail can be sent to the recipient's server via the server specified by SMTP, and the whole process takes only a few minutes in a minute.
  • the SMTP server is an e-mail that is used by the SMTP-sending mail server to send or forward.
  • the SMTP commands and responses are based on text, in command line units, with a newline character of CR/LF.
  • the response message is usually only one line, starting with a 3-digit code followed by a very short text description.
  • SMTP has to go through three stages: establishing a connection, transmitting a message, and releasing a connection. The specific steps include:
  • the server side indicates whether it is willing to receive mail for the recipient
  • the client first sends a DATA command to the server, indicating that the content of the email is started to be sent below;
  • value-added services there are various value-added service requirements in the communication network, such as the intelligent network platform network management alarm and the service mail notification user function.
  • value-added services are required to be loosely coupled with the underlying network.
  • Value-added services and third-party developers only need to understand the internally defined API (Application Programming Interface) and business recap, without having to understand telecommunications.
  • the specific content of network knowledge and SMTP reduces the complexity of upper-level value-added service development.
  • the technical problem to be solved by the present invention is to provide an SMTP protocol stack system and an implementation method thereof, which are used to reduce the complexity of upper-level value-added service development and ensure the response speed of upper-level value-added service development.
  • the present invention provides a protocol stack system of a simple mail transmission protocol, which is connected between a value-added service module and a mail server, and includes a communication module, a message processing module and a link management module, wherein:
  • the communication module is connected to the value-added service module and the mail server, and is configured to: receive a request message for sending a mail from the value-added service module, and receive, from the mail server, a request message for sending an email from the user mailbox to the value-added service provider;
  • the message processing module is connected to the communication module and the link management module, and is configured to: process the sending mail request message sent by the value-added service module, and the uplink mail request message sent by the user mailbox of the mail server to the value-added service provider. ;
  • the link management module connected to the mail server, is set to: Responsible for link establishment and deletion, link assignment management, link heartbeat and fault management.
  • the communication module includes an internal message receiving module and an external message receiving module
  • the internal message receiving module and the upper-layer value-added service module are connected by the WinntTcp protocol, and are set as: receiving a request message distribution session for sending a mail from the value-added service module, and converting the data delivered by the service into an internal structure and saving the session;
  • the external message receiving module and the mail server are connected through SMTP, and are set to: save the TCP message in a packet, and receive a request message from the user mailbox to send the mail to the value-added service provider.
  • the message processing module includes a group package module and an unpacking module
  • the group package module is configured to: convert the internal message group package delivered by the value-added service module into an SMTP message;
  • the unpacking module is set to: Unpack the SMTP message from the mail server and convert it to internal message save.
  • the link management module includes: a link setup and deletion module, a link assignment management module, and a link heartbeat and fault management module, where:
  • the link establishment and deletion module is configured to: establish and delete a link with the mail server; the link distribution management module is configured to: allocate an idle link for the message delivered by the value-added service module; link heartbeat and fault management module, Set to: Timed to send heartbeat messages to the mail server, and handle exceptions including chain scission and response timeouts.
  • the link allocation management module is configured to: perform link allocation management by using a serial long connection method or a serial short connection mode.
  • the protocol stack system of the simple mail transfer protocol is written in C language and is implemented in the form of a dynamic library by configuring multiple SMTP protocol stack threads.
  • the invention also provides a method for implementing a protocol stack of SMTP, comprising:
  • the message processing module performs packet processing on the sending mail request message sent by the value-added service module, and converts the internal message into an SMTP message; unpacking the uplink mail request message initiated by the user mailbox from the mail server to the value-added service provider Processing, unpacking the SMTP message into an internal message;
  • the link management module is responsible for link establishment and deletion, and performs link assignment management, link heartbeat, and fault management.
  • the link management module performs link allocation management by using a serial long connection method or a serial short connection method.
  • the protocol stack of the simple mail transfer protocol is written in C language, and is implemented in the form of a dynamic library by configuring multiple SMTP protocol stack threads.
  • the simple mail transfer protocol SMTP protocol stack system of the present invention and an implementation method thereof.
  • the protocol stack system is connected between the value-added service module and the mail server.
  • the invention is implemented in C language, and the development language of the whole system is unified, which improves the processing efficiency of the whole system and avoids compatibility problems caused by different development languages.
  • the invention can significantly improve the development speed of the value-added service mail notification function and the processing efficiency of the entire mail system.
  • Service providers do not need to understand the implementation details of SMTP, and can concentrate on providing a variety of data services, differentiate services, differentiate features, and improve service levels. BRIEF abstract
  • FIG. 1 is a diagram showing an external overall structure of an SMTP protocol stack of the present invention
  • FIG. 2 is a schematic diagram of a WinntTcp protocol packet structure between an SMTP protocol stack system and a value-added service module;
  • FIG. 3 is a schematic diagram of the header definition of the WinntTcp protocol packet
  • FIG. 4 is a diagram showing the internal overall structure of the SMTP protocol stack of the present invention.
  • FIG. 5 is a flowchart of a message sent by an SMTP protocol stack processing service according to the present invention.
  • FIG. 6 is a flow chart of processing an uplink message of a mailbox by the SMTP protocol stack of the present invention
  • FIG. 7 is a schematic diagram of a hardware networking in the specific implementation of the technical solution of the present invention. Preferred embodiment of the invention
  • Alum implements an SMTP protocol stack in C language.
  • the invention provides an SMTP protocol stack system, which completes the conversion of the service internal interface message to the SMTP protocol message, so that the service development only needs to pay attention to the business logic processing, and does not need to pay attention to the implementation details of the protocol, so that the integrated telecom operator can save investment while saving. It has also improved the speed of business development.
  • FIG. 1 The overall structure diagram of a Simple Mail Transfer Protocol (SMTP) protocol stack system of the present invention is shown in FIG. 1.
  • the SMTP protocol stack system is connected to the upper layer value-added service module on the one hand, and the lower layer mail server on the other hand. (SMTP Server) connection.
  • SMTP Server Simple Mail Transfer Protocol
  • the SMTP protocol stack system is connected to the upper value-added service modules through the TCP (WinntTcp) protocol.
  • the WinntTc protocol is the communication protocol between the internal network elements of the ZTE.
  • the WinntTcp protocol is suitable for message interaction between in-process, inter-process, and remote systems.
  • the WinntTc protocol defines the following: 1. The composition and validity of the data packet when the message is exchanged; 2. The validity detection of the link.
  • the WinntTcp protocol packet consists of a packet header and a packet body.
  • the structure of the WinntTcp protocol packet is defined by the application layer, which is defined between the value-added service and the SMTP protocol stack.
  • the header of the WinntTcp protocol packet is defined by the WinntTcp protocol, including the sender PID, the receiver PID, the event number, the packet length, the message type, the checksum, the pointer to the response data, and the length of the response data. reserved text.
  • the PID is a data type that identifies a process, including the node where the process is located, the station number of the node, and the process number on the node.
  • WinntTcp protocol header is as follows when the C language is defined:
  • SMTP is a reliable command/response based protocol, and most application layer protocols such as HTTP.
  • SMTP works in C/S (client/server) mode.
  • the SMTP protocol stack system is a client, and the mail server is a server.
  • COMMAND is the command name in ASCII form
  • Parameter I is the corresponding command parameter
  • ⁇ CRLF> is the carriage return line feed (ODH, 0AH).
  • the SMTP protocol stack system includes: a communication module 40, a message processing module 41, and a link management module 42.
  • the communication module 40 includes an internal message receiving module 401 and an external message receiving module 402, and is connected to the upper layer value-added service and the mail server.
  • the internal message receiving module and the upper-layer value-added service module are connected by the WinntTcp protocol, and are used to allocate a session, and convert the data delivered by the service into an internal structure and stored in the session, and receive the request message for sending the mail from the value-added service module.
  • the external message receiving module and the mail server are connected by SMTP, and are used for packet saving of the TCP message, and are used for receiving the request message sent from the user mailbox to the value-added service provider.
  • the message processing module 41 includes a group package module 411 and an unpacking module 412;
  • a grouping module 411 configured to convert an internal message group package delivered by the value-added service module into an SMTP message
  • the unpacking module 412 is configured to unpack the SMTP message from the mail server and convert it into an internal message save.
  • the flow chart of the message processing module 41 processing the service delivery message is as shown in FIG. 5, and includes the following steps:
  • Step 501 first performing internal session initialization, and after the initialization is completed, transferring to establish a connection and waiting for the first SMTP response;
  • Step 502 if the chain construction fails, the direct flow ends.
  • Step 503 If the link establishment is successful, the SMTP protocol is established and the internally translated message is sent. Step 503 includes the following substeps:
  • Step 5031 first, the SMTP protocol stack initiates a HELO message to the mail server, and identifies the SMTP protocol stack system identity to the mail server;
  • Step 5032 after waiting for the mail server to return a 250 OK response with the identity information of the mail server, the SMTP protocol stack then sends a MAIL From message to the mail server, and the identifier is initialized.
  • Mail session followed by the sender's address, that is, the reply path of the mail;
  • Step 5033 after waiting for the mail server to return a 250 OK response, the SMTP protocol stack then sends an RCPT TO message to the mail server to identify the mail.
  • the recipient followed by the recipient's email address, if the recipient is multiple, you need to initiate multiple RCPT TO messages;
  • Step 5034 waiting for the mail server to return a response of 250 OK again, and finally the SMTP protocol stack initiates a DATA message to the mail server, identifying the line following the command as the mail content, and the successful response of the DATA command is 354;
  • Step 5035 after the SMTP protocol stack system receives the response from the mail server returning 354 OK, the message group packet module 411 in the message processing module 41 in FIG. 4 starts to convert the internal message into an SMTP protocol message packet, and starts to send to the mail server. Finally, end with a ., if the mail server successfully receives the content of the email, it returns a 250 OK response.
  • Step 504 After receiving the response returned by the mail server, the SMTP protocol stack system returns the response message to the upper-layer value-added service module, and then ends the entire delivery process.
  • the message processing module processes 41.
  • the flow chart of the uplink mail request message initiated by the user mailbox to the value-added service provider is as shown in FIG. 6, and includes the following steps:
  • Step 601 first internal session initialization
  • Step 602 after the initialization is completed, the unpacking module 412 in the message processing module 41 unpacks the received SMTP module from the mail server, and transfers the internal message interface to the upper layer value-added service;
  • Step 603 if the sending is successful, waiting for the service to return a response; if the sending fails, directly ending the entire process;
  • Step 604 After receiving the service response, the SMTP protocol stack system returns a response message to the mail server, and the uplink message process ends.
  • the link management module 42 includes: a link setup and deletion module 421, a link assignment management module 422, a link heartbeat and fault management module 423, where: The link establishment and deletion module 421 is responsible for establishing and deleting links with the mail server; the link assignment management module 422 is responsible for allocating idle links for messages delivered by the service; the link heartbeat and fault management module 423 is responsible for timing The mail server sends heartbeat messages and handles exceptions such as broken links and response timeouts.
  • the link allocation management module 422 can implement link management in a serial long connection and a short connection manner, and is determined by setting a connection identifier (connectflag), for example, the connectflag is 1 is a serial long connection mode, 0 is the serial short connection method, and the SMTP protocol stack system uses the serial long connection method by default.
  • connectflag connection identifier
  • serial long connection method is processed as follows:
  • the link establishment and deletion module sends a link establishment request according to the mail server IP and port information in the request message, and the value-added service is added after the link is established.
  • the first request message is sent to the mail server.
  • the link is not immediately released after the first request message processing is completed.
  • the link distribution management module uses the RSET command in the SMTP as a heartbeat message with the mail server.
  • the mail server sends the RSET command, and the mail server returns an OK response, indicating that the link for sending the message continues to be maintained, and the heartbeat calculator adds 1 to complete a heartbeat. If 10 heartbeats are completed, the current link is not used for a while. The link is automatically closed. If the value-added service continues to deliver messages during the period, the currently maintained link is used, and the heartbeat calculator is cleared to 0 to restart counting.
  • the serial short connection method does not send a heartbeat and maintains the link.
  • the link management module receives the response of the mail server request message, the link is immediately released. If the value-added service continues to send the request message for sending the mail, the chain The way the setup and delete modules are re-established with the mail server.
  • the serial long connection method eliminates the overhead of building and deleting modules for multiple links, which saves the operation of allocating and releasing memory.
  • the serial short connection method eliminates the overhead of the link management module to send heartbeats and keeps the link, reduces the message interaction with the mail server, and the number of links between the mail server and the server at the same time.
  • the traffic is small, the resource consumption of the mail server can be reduced.
  • the SMTP protocol stack system of the present invention is implemented in C language, and due to the development of existing value-added services, Generally, SCE (Service Creation Environment) is used as a development tool, and the generated services are managed by SLP (Service Logic Processing). Both SCE and SLP are developed using C language, which unifies the whole.
  • SCE Service Creation Environment
  • SLP Service Logic Processing
  • Both SCE and SLP are developed using C language, which unifies the whole.
  • the development language of the system improves the processing efficiency of the entire system and avoids compatibility problems caused by different development languages.
  • the invention can significantly improve the development speed of the value-added service mail notification function and the processing efficiency of the entire mail system.
  • Service providers do not need to understand the implementation details of SMTP, and can concentrate on providing a variety of data services, differentiate services, differentiate features, and improve service levels.
  • the invention can use the plug-in API (Application Programming Interface), and the SMTP protocol stack system is implemented as a dynamic library in the form of threads.
  • a process named Protoser can be set to manage the SMTP protocol stack thread.
  • the Protoser process can manage multiple thread dynamic libraries at the same time, such as SMPP protocol stack dynamic library, SMGP protocol stack dynamic library and so on. Each protocol stack thread shares the memory space of the Protoser process.
  • a plurality of SMTP protocol stack threads can be established by configuring the configuration file, and the thread number of each thread can be configured, and the configuration is guaranteed not to be repeated, so that the value-added service is delivered.
  • you can set the round-robin distribution to the set SMTP protocol stack thread the load sharing of the SMTP protocol stack thread is realized.
  • the SMTP protocol stack system of the present invention can support the value-added service to quickly provide an email notification function, which makes up for the shortcoming of the single short message notification function, realizes diversification of service functions, can support multi-threading and load sharing, and adapts to the carrier level.
  • the network system can provide efficient mail processing functions, improve user satisfaction, and create good economic benefits.
  • the simple mail transfer protocol SMTP protocol stack system of the present invention and an implementation method thereof.
  • the protocol stack system is connected between the value-added service module and the mail server.
  • the invention is implemented in C language, and the development language of the whole system is unified, which improves the processing efficiency of the whole system and avoids compatibility problems caused by different development languages.
  • the invention can significantly improve the development speed of the value-added service mail notification function and the processing efficiency of the entire mail system. Service providers do not need to understand the implementation details of the SMTP protocol, and can concentrate on providing a variety of data services, differentiate services, differentiate features, and improve service levels.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computer And Data Communications (AREA)
  • Information Transfer Between Computers (AREA)

Description

一种 SMTP的协议栈系统及其实现方法
技术领域
本发明涉及通信网络技术领域, 尤其涉及一种简单邮件传输协议 SMTP ( Simple Mail Transfer Protocol ) 的协议栈系统及其实现方法。 背景技术
简单邮件传输协议( Simple Mail Transfer Protocol, SMTP )来源于 RFC 821 ( Request For Comments, 请求评议)规范, 是一组用于由源地址到目的地址 传送邮件的规则, 用于控制信件的中转方式。 SMTP属于传输控制协议 /网络 互连协议(TCP/IP )协议族, 帮助每台计算机在发送或中转信件时找到下一 个目的地。 通过 SMTP所指定的服务器, 就可把电子邮件(E-mail )寄到收 信人的服务器上了, 整个过程不到一分钟只要几分钟。
SMTP服务器则是遵循 SMTP的发送邮件服务器, 用来发送或中转发出 的电子邮件。 SMTP 的命令和响应都是基于文本, 以命令行为单位, 换行符 为 CR/LF。 响应信息一般只有一行, 由一个 3位数的代码开始, 后面可附上 很简短的文字说明。 在发送或中转发出的电子邮件过程中, SMTP要经过建 立连接、 传送邮件和释放连接这 3个阶段。 具体步骤包括:
( 1 )建立 TCP连接;
( 2 )客户端向服务器发送 HEL0命令以标识发件人自己的身份, 然后客 户端发送 MAIL命令;
( 3 )服务器端以 0K作为响应, 表示准备接收;
( 4 )客户端发送 RCPT命令;
( 5 )服务器端表示是否愿意为收件人接收邮件;
( 6 )客户端先向服务器发送发送 DATA命令, 表示下面开始发送邮件 内容;
( 7 )协商结束, 发送邮件, 发送邮件内容; ( 8 )结束此次发送, 用 QUIT命令退出。
随着电信增值业务的发展, 在通信网络中存在多种增值业务需求, 例如 智能网平台网管告警和业务邮件通知用户功能。 为实现这些增值业务, 要求 增值业务与下层网络松耦合, 增值业务以及第三方开发者只需要了解内部定 义的 API ( Application Programming Interface, 应用程序编程接口)和业务還 辑, 而不需深入了解电信网络知识和 SMTP的具体内容, 减小上层增值业务 开发的复杂性。
因而, 就需要一种用于增值业务的 SMTP协议栈系统及其实现方法。 发明内容
本发明所要解决的技术问题在于, 提供一种 SMTP协议栈系统及其实现 方法, 用于减小上层增值业务开发的复杂性, 保证上层增值业务开发的响应 速度。
为了解决上述问题,本发明提出了一种简单邮件传输协议的协议栈系统, 连接于增值业务模块与邮件服务器之间, 包括通讯模块、 消息处理模块和链 路管理模块, 其中:
通讯模块, 与增值业务模块和邮件服务器相连接, 设置为: 接收增值业 务模块的发送邮件的请求消息, 从邮件服务器接收来自用户邮箱的向增值业 务提供商发送邮件的请求消息;
消息处理模块, 与所述通讯模块和链路管理模块相连接, 设置为: 处理 增值业务模块下发的发送邮件请求消息以及来自邮件服务器的用户邮箱发起 的到增值业务提供商的上行邮件请求消息;
链路管理模块, 与邮件服务器连接, 设置为: 负责链路建立和删除, 链 路分配管理, 链路心跳和故障管理。
所述通讯模块, 包括内部消息接收模块和外部消息接收模块;
内部消息接收模块与上层的增值业务模块之间通过 WinntTcp协议连接, 设置为: 接收来自增值业务模块的发送邮件的请求消息分配会话, 将业务下 发的数据转换为内部结构保存在会话中; 外部消息接收模块与邮件服务器之间通过 SMTP连接, 设置为: 将 TCP 消息分包保存, 接收来自用户邮箱向增值业务提供商发送邮件的请求消息。
所述消息处理模块, 包括组包模块和解包模块;
组包模块, 设置为: 将增值业务模块下发的内部消息组包转换为 SMTP 消息;
解包模块, 设置为: 对来自邮件服务器的 SMTP消息进行解包, 转换为 内部消息保存。
所述链路管理模块包括: 链路建立和删除模块、 链路分配管理模块, 以 及链路心跳和故障管理模块, 其中:
链路建立与删除模块, 设置为: 与邮件服务器建立和删除链路; 链路分 配管理模块, 设置为: 为增值业务模块下发的消息分配空闲的链路; 链路心 跳和故障管理模块, 设置为: 定时向邮件服务器发送心跳消息, 并对包括断 链和响应超时的异常情况进行处理。
所述链路分配管理模块是设置为: 釆用串行长连接方式或者串行短连接 方式进行链路分配管理。
所述简单邮件传输协议的协议栈系统, 釆用 C语言编写, 釆用动态库的 形式, 通过配置多个 SMTP协议栈线程来实现。
本发明还提供一种 SMTP的协议栈实现方法, 包括:
利用通讯模块接收增值业务模块的发送邮件的请求消息, 从邮件服务器 接收来自用户邮箱的向增值业务提供商发送邮件的请求消息;
通过消息处理模块对增值业务模块下发的发送邮件请求消息进行组包处 理, 将内部消息转换为 SMTP消息; 对来自邮件服务器的用户邮箱发起的到 增值业务提供商的上行邮件请求消息进行解包处理, 将 SMTP消息解包为内 部消息;
利用链路管理模块负责链路建立和删除, 进行链路分配管理、 链路心跳 和故障管理。 所述链路管理模块釆用串行长连接方式或者串行短连接方式进行链路分 配管理。
所述简单邮件传输协议的协议栈是釆用 C语言编写 ,釆用动态库的形式, 通过配置多个 SMTP协议栈线程来实现。
本发明的简单邮件传输协议 SMTP的协议栈系统及其实现方法。 该协议 栈系统连接于增值业务模块与邮件服务器之间。 本发明釆用 C语言实现, 统 一了整个系统的开发语言, 提高了整个系统的处理效率, 也避免了开发语言 不同造成的兼容性问题。 本发明能够明显提高增值业务邮件通知功能的开发 速度和整个邮件系统的处理效率。服务提供商不需要了解 SMTP的实现细节, 能够集中精力提供多种多样的数据业务, 使服务差异化, 特色化, 提升服务 档次。 附图概述
图 1是本发明的 SMTP协议栈的外部总体结构图;
图 2是 SMTP协议栈系统与增值业务模块间 WinntTcp协议数据包结构 示意图;
图 3是 WinntTcp协议数据包的包头定义示意图;
图 4是本发明的 SMTP协议栈的内部总体结构图;
图 5是本发明的 SMTP协议栈处理业务下发消息的流程图;
图 6是本发明的 SMTP协议栈处理邮箱上行消息的流程图;
图 7是本发明的技术方案在具体实施时的一种硬件组网示意图。 本发明的较佳实施方式
为使本发明的目的、 技术方案和优点更加清楚, 以下结合附图对本发明 作进一步地详细说明。
考虑到电信增值业务发送邮件的需要, 为适应运营商最新的需求, 本发 明釆用 C语言实现了一种 SMTP协议栈。本发明提供一种 SMTP协议栈系统, 完成业务内部接口消息到 SMTP协议消息的转换, 使业务开发只需要关注业 务逻辑处理, 不需要关注协议的实现细节, 使综合电信运营商在节省投资的 同时又提高了业务的开发速度。
本发明的一种简单邮件传输协议(SMTP )的协议栈系统的总体结构图如 图 1所示, 该 SMTP协议栈系统一方面与上层的增值业务模块相连接, 另一 方面与下层的邮件服务器(SMTP Server )连接。
SMTP 协议栈系统与上层的各个增值业务模块之间通过类 TCP ( WinntTcp )协议连接, WinntTc 协议是中兴智能网内部网元之间的通讯协 议。 该 WinntTcp协议适用于进程内、 进程间、 远程系统间的消息交互。
WinntTc 协议定义了如下内容: 1、 消息交互时数据包的组成、 有效性 检测; 2、 链路的有效性检测。 如图 2所示, WinntTcp协议数据包由包头、 包体两部分组成。 WinntTcp协议数据包的包体的结构是由应用层定义的, 这 里是指增值业务与 SMTP协议栈之间定义。 如图 3所示, WinntTcp协议数据 包的包头由 WinntTcp协议定义, 包括发送者 PID, 接收者 PID, 事件号, 包 体长度, 消息类型, 校验码, 回应数据的指针, 回应数据的长度, 保留字段。
WinntTc 协议包头的结构定义如下:
typedef struct
PID sender;
PID receiver;
WORD event;
WORD len;
BYTE type;
DWORD secretfield;
UINT8 *ack;
WORD 16 acklen; DWORD reserve;
} MSG— HEAD;
其中 PID是标识一个进程的数据类型, 包括了进程所在的节点、 节点的 局号、 在该节点上的进程号。
WinntTcp协议包头的结构, 釆用 C语言定义时的结构如下:
typedef struct
unsigned int no :14;
unsigned int slave: 1;
unsigned int MpLeft: 1;
#else
UINT16 no:14;
UINT16 slave :1;
UINT 16 MpLeft: 1;
#endif
UINT8 unit;
UINT8 module;
UINT8 postOffice;
} PID;
在图 1所示的协议栈系统的总体结构图中, SMTP协议栈系统与邮件服 务器之间釆用标准的 SMTP, SMTP是一种可靠的基于命令 /应答的协议, 与 HTTP等多数应用层协议一样, SMTP工作在 C/S (客户端 /服务端)模式下。 在本发明的技术方案中, SMTP协议栈系统是客户端, 邮件服务器是服务端。
SMTP请求消息中的命令有 14 个, 命令的一般格式是: COMMAND
[Parameter] <CRLF>。 其中: COMMAND是 ASCII形式的命令名, Parameter 是相应的命令参数, <CRLF>是回车换行符 ( ODH, 0AH )。 邮件服务器收到 标准的 SMTP协议消息后, 再根据收件人地址发送到对应的用户邮箱。
如图 4所示, 给出了本发明的 SMTP协议栈系统的内部总体结构图, 虚 线标识了 SMTP协议栈系统。 该 SMTP协议栈系统包括: 通讯模块 40、 消息 处理模块 41和链路管理模块 42。
所述通讯模块 40, 包括内部消息接收模块 401和外部消息接收模块 402, 与上层增值业务和邮件服务器连接。 内部消息接收模块与上层的增值业务模 块之间通过 WinntTcp协议连接, 用于分配会话, 将业务下发的数据转换为内 部结构保存在会话中, 用于接收来自增值业务模块的发送邮件的请求消息; 外部消息接收模块与邮件服务器之间通过 SMTP连接,用于 TCP消息的分包 保存, 用于接收来自用户邮箱向增值业务提供商发送邮件的请求消息。
消息处理模块 41, 包括组包模块 411和解包模块 412;
组包模块 411 ,用于将对增值业务模块下发的内部消息组包转换为 SMTP 消息;
解包模块 412, 用于对来自邮件服务器的 SMTP消息进行解包, 转换为 内部消息保存。
该消息处理模块 41处理业务下发消息的流程图如图 5所示, 包括如下步 骤:
步骤 501 , 首先进行内部会话初始化, 初始化完成后转入建立连接并等 待第一次 SMTP应答;
步骤 502, 如果建链失败直接流程结束。
步骤 503 , 如果建链成功, 则完成 SMTP协议的建链和内部转换后的消 息的发送, 步骤 503又包括如下子步骤:
步骤 5031 , 首先 SMTP协议栈向邮件服务器发起 HELO消息, 向邮件服 务器标识 SMTP协议栈系统身份;
步骤 5032, 等待邮件服务器返回带有邮件服务器身份信息的 250 OK的 响应后, SMTP协议栈再向邮件服务器发起 MAIL From消息, 标识初始化一 个邮件会话, 后面紧跟的是发件人的地址, 即邮件的回复路径; 步骤 5033 , 等待邮件服务器返回 250 OK的响应后, SMTP协议栈再向 邮件服务器发起 RCPT TO消息, 标识该邮件的接收人,后面紧跟收件人的邮 箱地址, 如果收件人为多个, 则需要发起多个 RCPT TO消息;
步骤 5034, 再次等待邮件服务器返回 250 OK的响应, 最后 SMTP协议 栈再向邮件服务器发起 DATA消息, 标识跟在该命令后的行作为邮件内容, DATA命令的成功响应是 354;
步骤 5035 ,当 SMTP协议栈系统收到邮件服务器返回 354 OK的响应后, 图 4中消息处理模块 41中的消息组包模块 411开始将内部消息转换为 SMTP 协议消息包, 并开始向邮件服务器发送, 最后以.号结束, 如果邮件服务器成 功接收邮件内容后, 则返回 250 OK响应,
步骤 504, SMTP协议栈系统收到邮件服务器返回的响应后,给上层的增 值业务模块回响应消息后结束整个下发流程。
所述消息处理模块处理 41 用户邮箱发起的到增值业务提供商的上行邮 件请求消息的流程图如图 6所示, 包括如下步骤:
步骤 601 , 首先内部会话初始化;
步骤 602, 初始化完成后, 消息处理模块 41中的解包模块 412对接收的 来自邮件服务器的 SMTP模块进行解包, 并转为内部消息接口发给上层增值 业务;
步骤 603 , 如果发送成功则等待业务返回应答; 如果发送失败则直接结 束整个流程;
步骤 604, 在收到业务响应后 SMTP协议栈系统再给邮件服务器回响应 消息, 上行消息流程结束。
所述链路管理模块 42包括: 链路建立和删除模块 421、 链路分配管理模 块 422、 链路心跳和故障管理模块 423 , 其中: 链路建立与删除模块 421 , 负责与邮件服务器建立和删除链路; 链路分配管理模块 422, 负责为业务下发的消息分配空闲的链路; 链路心跳和故障管理模块 423 , 负责定时向邮件服务器发送心跳消息, 并对断链和响应超时等异常情况进行处理。
所述链路分配管理模块 422, 可以实现串行长连接和短连接两种方式的 链路管理,通过设置一个连接标识( connectflag )来进行判断,例如 connectflag 为 1是串行长连接方式, 为 0是串行短连接方式, SMTP协议栈系统默认釆 用串行长连接方式。
串行长连接方式的处理流程为:
当增值业务在 SMTP协议栈系统启动运行后第一次下发消息时, 链路建 立和删除模块根据请求消息中的邮件服务器 IP和端口信息发送建链请求,链 路建立完成后再将增值业务的第一次请求消息发送到邮件服务器, 第一次请 求消息处理完成后链路并不立即释放, 此时链路分配管理模块使用 SMTP中 的 RSET命令作为与邮件服务器之间的心跳消息, 向邮件服务器发送 RSET 命令, 邮件服务器返回 OK响应, 表示当前发送消息的链路继续保持, 同时 心跳计算器加 1表示完成一次心跳, 如果完成 10次心跳, 则表示当前链路一 段时间没被使用, 链路自动关闭, 如果期间增值业务继续下发消息, 则使用 当前保持的链路, 同时心跳计算器清 0, 重新开始计数。
串行短连接方式则没有发送心跳和保持链路的过程, 当链路管理模块接 收到邮件服务器请求消息的应答时, 立即释放链路, 如果增值业务继续下发 发送邮件的请求消息, 则链路建立和删除模块再次重新与邮件服务器建链。
串行长连接方式省去了链路建立和删除模块多次建链的开销, 也就省去 了分配和释放内存的操作, 在系统流量大的时候, 可以明显提高 SMTP协议 栈系统的处理能力; 而串行短连接方式省去了链路管理模块发送心跳和保持 链路的开销, 减少了与邮件服务器之间的消息交互, 以及同一时刻与邮件服 务器之间的链路条数, 在系统流量小的时候, 可以减少邮件服务器的资源消 耗。
本发明的 SMTP协议栈系统釆用 C语言实现,由于现有增值业务的开发, 一般使用 SCE ( Service Creation Environment, 业务生成环境)作为开发工具, 生成的业务由 SLP ( Service Logic Processing, 业务逻辑处理)来进行统一管 理, SCE和 SLP都是使用 C语言开发的, 这样统一了整个系统的开发语言, 提高了整个系统的处理效率, 也避免了开发语言不同造成的兼容性问题。
釆用本发明能够明显提高增值业务邮件通知功能的开发速度和整个邮件 系统的处理效率。 服务提供商不需要了解 SMTP的实现细节, 能够集中精力 提供多种多样的数据业务, 使服务差异化, 特色化, 提升服务档次。
考虑到电信现有运营数据业务的特点, 本发明可釆用插件式 API ( Application Programming Interface, 应用编程接口)力口载, SMTP协议栈系 统实现为一个动态库的形式, 以线程的形式存在。可以设置一个名为 Protoser 的进程对 SMTP协议栈线程进行统一管理, Protoser进程可同时管理多个线程 动态库, 如 SMPP协议栈动态库、 SMGP协议栈动态库等等。 各个协议栈线 程共享 Protoser进程的内存空间。 同时, 考虑到电信级应用流量大的实际需 求, 可通过对配置文件进行配置而建立多个 SMTP协议栈线程, 每个线程的 线程号可以配置, 配置时保证不重复就行, 这样增值业务下发时就可以设置 轮循分发到设置的多个 SMTP协议栈线程, 实现了 SMTP协议栈线程的负荷 分担。
综上, 本发明的 SMTP协议栈系统可以支持增值业务快速提供邮件通知 用户功能, 弥补了单一短信通知功能的不足, 实现了业务功能的多样化; 可 以支持多线程化和负荷分担, 适应电信级运营流量大的特点; 还具有高效的 邮件发送能力, 由于本系统是釆用纯 C语言实现, 无论对于内部消息的组包 和 SMTP消息的接收, 在处理效率上有很大的优势。
如图 7所示, 在网络中具体实现时, 可以釆用 PC机、 SUSE服务器和 HP-UNIX服务器的方式实现。 在网络系统中, 可以设置一套 HP N4000服务 器安装 SMTP协议栈系统和增值业务模块,釆用一台 SUSE Linux作为邮件服 务器机器, HP N4000服务器和 SUSE Linux机器间通过 TCP链路进行连接; 在一台 PC机上安装邮件客户端软件,例如可以使用 Windows自带的 Microsoft Office OutLook软件来接收邮件。
为模拟电信实际运营的环境, HP N4000服务器上建立两个 SMTP协议栈 线程, 线程号分别是 179和 180, 增值业务设置成轮循方式向两个线程发送 消息, 该网络系统能提供高效的邮件处理功能, 提高了用户满意度, 创造了 良好的经济效益。
以上所述仅为本发明的实施样例而已, 并不用于限制本发明, 对于本领 域的技术人员来说, 本发明可以有各种更改和变化。 凡在本发明的精神和原 则之内, 所作的任何修改、 等同替换、 改进等, 均应包含在本发明的权利要 求范围之内。
本领域普通技术人员可以理解上述方法中的全部或部分步骤可通过程序 来指令相关硬件完成, 所述程序可以存储于计算机可读存储介质中, 如只读 存储器、 磁盘或光盘等。 可选地, 上述实施例的全部或部分步骤也可以使用 一个或多个集成电路来实现。 相应地, 上述实施例中的各模块 /单元可以釆用 硬件的形式实现, 也可以釆用软件功能模块的形式实现。 本发明不限制于任 何特定形式的硬件和软件的结合。
工业实用性
本发明的简单邮件传输协议 SMTP的协议栈系统及其实现方法。 该协议 栈系统连接于增值业务模块与邮件服务器之间。 本发明釆用 C语言实现, 统 一了整个系统的开发语言, 提高了整个系统的处理效率, 也避免了开发语言 不同造成的兼容性问题。 本发明能够明显提高增值业务邮件通知功能的开发 速度和整个邮件系统的处理效率。 服务提供商不需要了解 SMTP协议的实现 细节, 能够集中精力提供多种多样的数据业务, 使服务差异化, 特色化, 提 升服务档次。

Claims

权 利 要 求 书
1、 一种简单邮件传输协议(SMTP ) 的协议栈系统, 连接于增值业务模 块与邮件服务器之间, 包括通讯模块、 消息处理模块和链路管理模块, 其中: 所述通讯模块, 与所述增值业务模块和所述邮件服务器相连接,设置为: 接收所述增值业务模块的发送邮件的请求消息, 从所述邮件服务器接收来自 用户邮箱的向增值业务提供商发送邮件的请求消息;
所述消息处理模块, 与所述通讯模块和所述链路管理模块相连接, 设置 为: 处理所述增值业务模块下发的发送邮件请求消息以及来自所述邮件服务 器的用户邮箱发起的到增值业务提供商的上行邮件请求消息;
所述链路管理模块, 与所述邮件服务器连接, 设置为: 负责链路建立和 删除, 链路分配管理, 链路心跳和故障管理。
2、 如权利要求 1所述的协议栈系统, 其中,
所述通讯模块, 包括内部消息接收模块和外部消息接收模块;
所述内部消息接收模块, 与上层的增值业务模块之间通过类传输控制协 议(WinntTcp )连接, 设置为: 接收来自所述增值业务模块的发送邮件的请 求消息分配会话, 将业务下发的数据转换为内部结构保存在会话中;
所述外部消息接收模块, 与所述邮件服务器之间通过 SMTP连接, 设置 为: 将传输控制协议(TCP ) 消息分包保存, 接收来自用户邮箱向增值业务 提供商发送邮件的请求消息。
3、 如权利要求 1所述的协议栈系统, 其中,
所述消息处理模块, 包括组包模块和解包模块;
所述组包模块, 设置为: 将所述增值业务模块下发的内部消息组包转换 为 SMTP消息;
所述解包模块,设置为: 对来自所述邮件服务器的 SMTP消息进行解包, 转换为内部消息保存。
4、 如权利要求 1所述的协议栈系统, 其中,
所述链路管理模块包括: 链路建立和删除模块、 链路分配管理模块, 以 及链路心跳和故障管理模块, 其中:
所述链路建立与删除模块设置为: 与所述邮件服务器建立和删除链路; 所述链路分配管理模块设置为: 为所述增值业务模块下发的消息分配空 闲的链路;
所述链路心跳和故障管理模块设置为: 定时向所述邮件服务器发送心跳 消息, 并对包括断链和响应超时的异常情况进行处理。
5、 如权利要求 4所述的协议栈系统, 其中,
所述链路分配管理模块是设置为: 釆用串行长连接方式或者串行短连接 方式进行链路分配管理。
6、 如权利要求 1至 5中任一项所述的协议栈系统, 其中,
所述 SMTP的协议栈系统, 釆用 C语言编写, 釆用动态库的形式, 通过 配置多个 SMTP协议栈线程来实现。
7、 一种简单邮件传输协议(SMTP ) 的协议栈实现方法, 包括: 利用通讯模块接收增值业务模块的发送邮件的请求消息, 从邮件服务器 接收来自用户邮箱的向增值业务提供商发送邮件的请求消息;
通过消息处理模块对增值业务模块下发的发送邮件请求消息进行组包处 理, 将内部消息转换为 SMTP消息; 对来自邮件服务器的用户邮箱发起的到 增值业务提供商的上行邮件请求消息进行解包处理, 将 SMTP消息解包为内 部消息;
利用链路管理模块负责链路建立和删除, 进行链路分配管理、 链路心跳 和故障管理。
8、 如权利要求 7所述的方法, 其中,
所述链路管理模块是釆用串行长连接方式或者串行短连接方式进行链路 分配管理。
9、 如权利要求 7所述的方法, 其中,
所述 SMTP的协议栈是釆用 C语言编写, 釆用动态库的形式, 通过配置 多个 SMTP协议栈线程来实现。
PCT/CN2011/072878 2010-10-20 2011-04-15 一种smtp的协议栈系统及其实现方法 WO2012051840A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN2010105230054A CN101977225A (zh) 2010-10-20 2010-10-20 一种smtp协议栈系统及其实现方法
CN201010523005.4 2010-10-20

Publications (1)

Publication Number Publication Date
WO2012051840A1 true WO2012051840A1 (zh) 2012-04-26

Family

ID=43577070

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/072878 WO2012051840A1 (zh) 2010-10-20 2011-04-15 一种smtp的协议栈系统及其实现方法

Country Status (2)

Country Link
CN (1) CN101977225A (zh)
WO (1) WO2012051840A1 (zh)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101977225A (zh) * 2010-10-20 2011-02-16 中兴通讯股份有限公司 一种smtp协议栈系统及其实现方法
CN103581211A (zh) * 2012-07-18 2014-02-12 株式会社Ntt都科摩 提供定制业务的企业应用服务器及方法
CN108667505A (zh) * 2018-04-20 2018-10-16 广州亿航智能技术有限公司 无人机通信链路的数据处理方法及计算机可读存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1337831A (zh) * 2000-07-25 2002-02-27 常宇光 移动通信系统互联网简单邮件传输协议
CN1402514A (zh) * 2001-08-15 2003-03-12 华为技术有限公司 通过智能网实现电子邮件信箱管理的系统和方法
CN101668263A (zh) * 2009-09-25 2010-03-10 天津市雅浪通讯技术有限公司 基于手机短信平台收发邮件的系统及邮件附件的处理方法
CN101977225A (zh) * 2010-10-20 2011-02-16 中兴通讯股份有限公司 一种smtp协议栈系统及其实现方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1337831A (zh) * 2000-07-25 2002-02-27 常宇光 移动通信系统互联网简单邮件传输协议
CN1402514A (zh) * 2001-08-15 2003-03-12 华为技术有限公司 通过智能网实现电子邮件信箱管理的系统和方法
CN101668263A (zh) * 2009-09-25 2010-03-10 天津市雅浪通讯技术有限公司 基于手机短信平台收发邮件的系统及邮件附件的处理方法
CN101977225A (zh) * 2010-10-20 2011-02-16 中兴通讯股份有限公司 一种smtp协议栈系统及其实现方法

Also Published As

Publication number Publication date
CN101977225A (zh) 2011-02-16

Similar Documents

Publication Publication Date Title
US7401120B2 (en) Method and apparatus for universal data exchange gateway
US20040208177A1 (en) Semiconductor circuit device, packet processing method, management system, management method and packet processing method
CN101534302B (zh) 一种提供tcp服务的方法、系统和相关装置
CN111083161A (zh) 数据传输的处理方法及装置、物联网设备
CN104363291A (zh) 一种网络通信中间件实现方法
CN1812405B (zh) 在请求-响应传输协议上的可靠单向消息传送的方法
US20090113460A1 (en) Systems and methods for providing a generic interface in a communications environment
US7529820B2 (en) Method and apparatus to perform automated task handling
CN112769598B (zh) 一种网络通信系统及其通信实现方法
CN112631788B (zh) 数据传输方法及数据传输服务器
WO2007056928A1 (fr) Procede et systeme d&#39;adaptation pour terminal de messagerie mobile
WO2017028399A1 (zh) 通信数据传输方法及系统
WO2011015020A1 (zh) 文件传输方法、系统及客户端
US8156209B1 (en) Aggregation devices processing keep-alive messages of point-to-point sessions
WO2012051840A1 (zh) 一种smtp的协议栈系统及其实现方法
WO2019114459A1 (zh) 一种传输数据的方法以及相关设备
CN108989157B (zh) 用于智能设备控制的方法、装置
WO2013075492A1 (zh) 一种基于开放业务发布平台的消息通信方法及系统
WO2011057544A1 (zh) 一种基于802.3ah协议实现点到多点OAM的方法及系统
WO2010060312A1 (zh) Web应用与外部设备网络互连的实现方法和系统
JP2011182115A (ja) 通信方法、通信システム及びサーバ
WO2024130615A1 (zh) 一种数据传输方法及相关装置
CN112532728B (zh) 一种确定性的机载高性能文件传输方法和系统
CN111935330B (zh) 一种ppp报文穿越l2tp的方法及装置
US20230130964A1 (en) Communication protocol, and a method thereof for accelerating artificial intelligence processing tasks

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11833746

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11833746

Country of ref document: EP

Kind code of ref document: A1