JP6688122B2 - Communication device and control method thereof - Google Patents

Communication device and control method thereof Download PDF

Info

Publication number
JP6688122B2
JP6688122B2 JP2016064396A JP2016064396A JP6688122B2 JP 6688122 B2 JP6688122 B2 JP 6688122B2 JP 2016064396 A JP2016064396 A JP 2016064396A JP 2016064396 A JP2016064396 A JP 2016064396A JP 6688122 B2 JP6688122 B2 JP 6688122B2
Authority
JP
Japan
Prior art keywords
packet
communication device
ack
data
generated
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
JP2016064396A
Other languages
Japanese (ja)
Other versions
JP2017183833A (en
Inventor
佐々木 章友
章友 佐々木
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Canon Inc
Original Assignee
Canon Inc
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 Canon Inc filed Critical Canon Inc
Priority to JP2016064396A priority Critical patent/JP6688122B2/en
Publication of JP2017183833A publication Critical patent/JP2017183833A/en
Application granted granted Critical
Publication of JP6688122B2 publication Critical patent/JP6688122B2/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Description

本発明は、確認応答を使用するパケット通信における通信制御技術に関するものである。   The present invention relates to a communication control technique in packet communication that uses an acknowledgment.

従来、データ通信において通信の信頼性を保証するため、パケット化したデータを受信した際に受信側から送信側へACK(ACKnowledgement)と呼ばれる確認応答を送信する手法がある。これにより、送信側は受信側が正常にデータを受信したことを知ることが出来る。例えば、特許文献1に示されるように、インターネット通信において広く利用されているTCP(Transmission Control Protocol)では、パケットをオクテット単位にシーケンス番号で管理している。そして、受け取ったパケットのシーケンス番号をACKパケットとして応答している。   In order to guarantee the reliability of communication in data communication, conventionally, there is a method of transmitting an acknowledgment called ACK (ACKnowledgement) from a receiving side to a transmitting side when receiving packetized data. This allows the transmitting side to know that the receiving side has received the data normally. For example, as shown in Patent Document 1, in TCP (Transmission Control Protocol) widely used in Internet communication, packets are managed in octet units by sequence numbers. Then, the sequence number of the received packet is returned as an ACK packet.

また、TCPのACKパケットでは、受信バッファの空き容量をウィンドウサイズとして通知し、送信側は通知されたウィンドウサイズまでは、ACKパケットを受信することなくデータを連続して送信することができる。ウィンドウサイズまでデータを送信すると、送信側は、受信側からのACKパケットを受信し、新たなウィンドウサイズが通知されるまでデータを送信しない。   Further, in the TCP ACK packet, the free space of the reception buffer is notified as the window size, and the transmitting side can continuously transmit the data up to the notified window size without receiving the ACK packet. After transmitting the data up to the window size, the transmitting side does not transmit the data until receiving the ACK packet from the receiving side and notifying the new window size.

特開2000−22744号公報JP-A-2000-22744

しかしながら、TCPなどの確認応答を使用する通信方式においては、通信状況によっては次のデータを送信することができない場合がある。例えば、送信側が、ACKを受信することなく受信側の受信バッファが埋まるまでデータを送信した場合、次のデータを送信することが出来なくなる。すなわち、受信側におけるACKの生成及び送信の遅延により、送信側による次のデータの送信も遅延することになる。その結果、送信側と受信側の間のデータ転送速度が遅くなってしまうことになる。   However, in a communication method using a confirmation response such as TCP, the next data may not be transmitted depending on the communication situation. For example, if the transmitting side transmits data without receiving an ACK until the receiving buffer on the receiving side is filled, the next data cannot be transmitted. That is, the transmission of the next data by the transmission side is also delayed due to the delay in the generation and transmission of the ACK on the reception side. As a result, the data transfer rate between the transmitting side and the receiving side becomes slow.

本発明は、上記の問題点を鑑みてなされたものであり、確認応答を使用した通信におけるデータ転送速度を向上させることを目的とする。   The present invention has been made in view of the above problems, and an object of the present invention is to improve the data transfer rate in communication using confirmation responses.

上述の問題点を解決するため、本発明に係る通信装置は以下の構成を備える。すなわち、通信装置において、他の通信装置から送信されるデータパケットに対する確認応答パケットを生成する生成手段と、前記他の通信装置から受信したデータパケットに対する受信処理を行う受信手段と、前記データパケットを受信した場合に、前記生成手段により生成された該データパケットに対応する確認応答パケットを送信する送信手段と、を有し、前記生成手段は、前記受信手段による前記受信処理よりも優先度の低いタスクとして、少なくとも一部のデータパケットに対する確認応答パケットの生成処理を該データパケットの受信に先立って開始する。 In order to solve the above problems, the communication device according to the present invention has the following configuration. That is, in a communication device, a generation unit that generates an acknowledgment packet for a data packet transmitted from another communication device, a reception unit that performs a reception process for a data packet received from the other communication device, and the data packet And a transmitting means for transmitting an acknowledgment packet corresponding to the data packet generated by the generating means when the receiving means receives the data packet, and the generating means has a lower priority than the receiving process by the receiving means. As a task, the process of generating an acknowledgment packet for at least a part of the data packets is started prior to the reception of the data packets.

本発明によれば、確認応答を使用した通信におけるデータ転送速度を向上可能とする技術を提供することができる。   According to the present invention, it is possible to provide a technique capable of improving the data transfer rate in the communication using the confirmation response.

第1実施形態に係るTCP/IPスタックの構成を説明する図である。It is a figure explaining the structure of the TCP / IP stack which concerns on 1st Embodiment. 通信装置の構成を示すブロック図である。It is a block diagram which shows the structure of a communication apparatus. 第1実施形態におけるACKパケット生成の動作フローチャートである。6 is an operation flowchart of ACK packet generation in the first embodiment. タスクの優先順位の例を示す図である。It is a figure which shows the example of the priority of a task. TCP接続管理機構の構造を示す図である。It is a figure which shows the structure of a TCP connection management mechanism. 受信パケットに対するACKパケットの送信位置及び構造を示す図である。It is a figure which shows the transmission position and structure of an ACK packet with respect to a received packet. 第1実施形態におけるACKパケット送信の動作フローチャートである。6 is an operation flowchart of ACK packet transmission in the first embodiment. 第1実施形態に係るTCP通信における効果を説明する図である。It is a figure explaining the effect in TCP communication which concerns on 1st Embodiment. 各種パケットの構造を示す図である。It is a figure which shows the structure of various packets. 第2実施形態におけるACKパケット生成の動作フローチャートである。7 is an operation flowchart of ACK packet generation in the second embodiment. 第3実施形態におけるACKパケット生成の動作フローチャートである。9 is an operation flowchart of ACK packet generation in the third embodiment. 第3実施形態におけるACKパケット送信の動作フローチャートである。It is an operation | movement flowchart of ACK packet transmission in 3rd Embodiment. 第4実施形態における受信パケットに対するACKパケットの送信位置を示す図である。It is a figure which shows the transmission position of the ACK packet with respect to the received packet in 4th Embodiment. 第4実施形態の変形例1におけるACKパケット送信の動作フローチャートである。20 is an operation flowchart of ACK packet transmission in Modification 1 of the fourth embodiment. 第4実施形態の変形例2におけるACKパケット送信の動作フローチャートである。20 is an operation flowchart of ACK packet transmission in Modification 2 of the fourth embodiment.

以下に、図面を参照して、この発明の好適な実施の形態を詳しく説明する。なお、以下の実施の形態はあくまで例示であり、本発明の範囲を限定する趣旨のものではない。   Hereinafter, preferred embodiments of the present invention will be described in detail with reference to the drawings. Note that the following embodiments are merely examples, and are not intended to limit the scope of the present invention.

(第1実施形態)
本発明に係る通信装置の第1実施形態として、TCP/IP通信を行う通信装置を例に挙げて以下に説明する。特に、対向装置から到来するデータパケットの受信に先立って、該データ受信に対する確認応答パケット(ACKパケット)の生成処理を開始し、データパケットを受信した場合により短期間でACKパケットを送出可能とする形態について説明する。
(First embodiment)
As a first embodiment of the communication device according to the present invention, a communication device that performs TCP / IP communication will be described as an example and described below. In particular, prior to the reception of the data packet coming from the opposite device, the process of generating the confirmation response packet (ACK packet) for the data reception is started, and the ACK packet can be transmitted in a shorter period when the data packet is received. The form will be described.

<装置構成>
図1は、第1実施形態に係るTCP/IPスタックの構成を説明する図である。図2は、図1に示すTCP/IPスタックを搭載した通信装置212の構成を示すブロック図である。
<Device configuration>
FIG. 1 is a diagram illustrating the configuration of the TCP / IP stack according to the first embodiment. FIG. 2 is a block diagram showing the configuration of the communication device 212 equipped with the TCP / IP stack shown in FIG.

通信装置212は、CPU202、ワークメモリであるDRAM203、CPU202が実行するプログラムなどを格納するROM209を有する。また、通信装置212は、イーサネット(商標登録)規格などのネットワーク210を介した通信を行うためのLANモジュール204を有する。   The communication device 212 has a CPU 202, a DRAM 203 that is a work memory, and a ROM 209 that stores programs executed by the CPU 202. Further, the communication device 212 has a LAN module 204 for performing communication via the network 210 such as the Ethernet (registered trademark) standard.

ACK生成処理タスク110は、受信したデータの確認応答であるACKパケットを生成するタスクである。アプリケーションタスク101を構成するアプリケーションは、データの送受信を行う通信アプリケーションである。第1実施形態においては、TCP/IPの送信処理はアプリケーションタスク101で行われる。   The ACK generation processing task 110 is a task that generates an ACK packet that is an acknowledgment of the received data. The applications that make up the application task 101 are communication applications that send and receive data. In the first embodiment, the TCP / IP transmission process is performed by the application task 101.

受信バッファ102は、上述の通信アプリケーションのための受信バッファであり、受信処理タスク103が受信キュー104を介して受信したデータがコピーされる。上述の通信アプリケーションによる受信データの読み出しは、受信バッファ102を介して行われる。受信キュー104は、LANドライバ106が受信したパケットが挿入されるキューである。受信キュー104は、例えばDRAM203内に構成されている。   The reception buffer 102 is a reception buffer for the above-mentioned communication application, and the data received by the reception processing task 103 via the reception queue 104 is copied. The reading of the received data by the above-described communication application is performed via the reception buffer 102. The reception queue 104 is a queue into which the packet received by the LAN driver 106 is inserted. The reception queue 104 is configured in the DRAM 203, for example.

送信キュー105は、アプリケーションタスク101のTCP/IPの送信処理により生成されたTCP/IPパケットが挿入されるキューである。送信キュー105は、例えばDRAM203内に構成されている。   The transmission queue 105 is a queue into which the TCP / IP packet generated by the TCP / IP transmission process of the application task 101 is inserted. The transmission queue 105 is configured in the DRAM 203, for example.

LANドライバ106は、LANモジュール204を制御し、イーサネット(商標登録)規格などに準拠したLAN210を介してパケットの送受信を行う機能部である。ACKパケットバッファ107は、生成したACKパケットを埋めるバッファであり、DRAM203内に構成されている。TCP接続管理機構108は、TCP接続を管理する機能部であり、DRAM203内に構成されている。   The LAN driver 106 is a functional unit that controls the LAN module 204 and transmits / receives a packet via the LAN 210 conforming to the Ethernet (registered trademark) standard or the like. The ACK packet buffer 107 is a buffer for filling the generated ACK packet, and is configured in the DRAM 203. The TCP connection management mechanism 108 is a functional unit that manages TCP connections and is configured in the DRAM 203.

<装置の動作>
図5は、TCP接続管理機構108の構造を示す図である。TCP接続管理機構108は、TCP接続管理構造体401、生成されたACKパケットを管理するためのACKパケット管理構造体402、TCP管理接続構造体の先頭を保持するTCP接続構造体先頭403を含む。TCP接続管理構造体401は、TCP接続管理構造体先頭403からリンクされる。また、次(後続)のTCP接続管理構造体401へは“次のTCP接続”のポインタによりリンクされている。
<Device operation>
FIG. 5 is a diagram showing the structure of the TCP connection management mechanism 108. The TCP connection management mechanism 108 includes a TCP connection management structure 401, an ACK packet management structure 402 for managing the generated ACK packet, and a TCP connection structure head 403 holding the head of the TCP management connection structure. The TCP connection management structure 401 is linked from the TCP connection management structure head 403. The next (successive) TCP connection management structure 401 is linked by the "next TCP connection" pointer.

図3は、第1実施形態におけるACKパケット生成の動作フローチャートである。   FIG. 3 is an operation flowchart of ACK packet generation in the first embodiment.

S302では、CPU202は、タスクが実行のイベントを待機し、イベントが派生するとS303に進む。S303では、CPU202は、TCP接続管理構造体先頭403から“次のTCP接続”を抜き出す。S304では、CPU202は、次のTCP接続が存在するか否かを判定する。TCP接続がなければ(すなわち、TCP接続管理構造体401の“次のTCP接続”の値がNULLであれば)イベント待ち(S302)に戻る。TCP接続があれば(すなわち、TCP接続管理構造体401の“次のTCP接続”がNULLでなければ)S305に進む。   In S302, the CPU 202 waits for an event of task execution, and when an event is derived, the process proceeds to S303. In S303, the CPU 202 extracts the "next TCP connection" from the TCP connection management structure head 403. In S304, the CPU 202 determines whether or not the next TCP connection exists. If there is no TCP connection (that is, if the value of "next TCP connection" of the TCP connection management structure 401 is NULL), the process returns to the event wait (S302). If there is a TCP connection (that is, "next TCP connection" of the TCP connection management structure 401 is not NULL), the process proceeds to S305.

S305では、CPU202は、TCP接続管理構造体401から生成済み確認応答番号(生成済みACK番号)を抜き出す。S306では、CPU202は、受信バッファサイズと生成済みACK番号から生成予定のACK番号の最大値を求める。生成予定のACK番号の最大値を設定しておくことにより、無限にACKパケットを生成することを防ぐことができる。生成予定のACK番号の最大値は、例えば、受信側ウィンドウサイズに基づいて以下のように求めることができる。   In S305, the CPU 202 extracts the generated confirmation response number (generated ACK number) from the TCP connection management structure 401. In S306, the CPU 202 obtains the maximum value of the ACK number to be generated from the reception buffer size and the generated ACK number. By setting the maximum value of the ACK number to be generated, it is possible to prevent the ACK packet from being generated indefinitely. The maximum value of the ACK number to be generated can be calculated as follows based on the window size on the receiving side, for example.

生成予定のACK番号の最大値 = 受信済みシーケンス番号 + 受信側ウィンドウサイズ − 生成済みACK番号
S307では、CPU202は、生成済みACK番号と生成予定のACK番号の最大値を比較する。生成済みACK番号が生成予定のACK番号の最大値より小さければS308に進み、生成済みACK番号が生成予定ACK番号の最大値以上であった場合は、S310に進む。
Maximum value of ACK number to be generated = Received sequence number + Reception side window size−Generated ACK number In S307, the CPU 202 compares the generated ACK number with the maximum value of the ACK number to be generated. If the generated ACK number is smaller than the maximum value of the planned ACK number, the process proceeds to S308, and if the generated ACK number is equal to or larger than the maximum value of the planned ACK number, the process proceeds to S310.

S308では、CPU202は、ACKパケットを生成し、生成済みACK番号を更新する。ただし、対応するデータパケットを未受信である場合、ACKパケットの生成において、シーケンス番号とウィンドウサイズは未知のパラメータである。シーケンス番号はデータを送った場合、ウィンドウサイズはTCPを使用するアプリケーションの読み込みタイミングに依存する。そのため、ACKパケットの生成時には、シーケンス番号とウィンドウサイズに“0”を入れてチェックサムを計算してACKパケットのチェックサムに代入する。そして、ACKパケットの送信時に、確定したシーケンス番号とウィンドウサイズを代入してチェックサムにシーケンス番号とウィンドウサイズを足すようにする。ACKパケットの生成及びACK番号の更新について図6を参照して更に説明する。   In S308, the CPU 202 generates an ACK packet and updates the generated ACK number. However, when the corresponding data packet has not been received, the sequence number and window size are unknown parameters in the generation of the ACK packet. When the data is sent as the sequence number, the window size depends on the read timing of the application using TCP. Therefore, when the ACK packet is generated, "0" is put in the sequence number and the window size, the checksum is calculated, and the checksum is substituted for the checksum of the ACK packet. Then, when transmitting the ACK packet, the confirmed sequence number and window size are substituted so that the sequence number and window size are added to the checksum. Generation of the ACK packet and updating of the ACK number will be further described with reference to FIG.

図6は、受信パケットに対するACKパケットの送信位置(タイミング)及び構造を示す図である。なお、TCPでは、最大セグメントサイズ(MSS:Maximum Segment Size)より大きいサイズのデータを受信した場合、すなわち、2個のパケットを受信した場合に1個のACKパケットを送信することが推奨されている。そのため、図6においては、生成するACK番号は生成済みのACK番号に(MSS×2)を加えたものとしている。   FIG. 6 is a diagram showing a transmission position (timing) and a structure of an ACK packet with respect to a received packet. In TCP, it is recommended that one ACK packet be transmitted when data of a size larger than the maximum segment size (MSS) is received, that is, when two packets are received. . Therefore, in FIG. 6, the generated ACK number is obtained by adding (MSS × 2) to the generated ACK number.

点線の矩形で示されるパケット501は、到着する予測されるパケット(すなわち、現時点で未受信のパケット)を示している。また、パケット501には、併せて当該パケットの「シーケンス番号の開始位置」と「TCPのデータサイズ」が記述されている。例えば、パケット501では、“2”がシーケンス番号であり、“1460”がTCPのMSSサイズ(当該パケットでのデータサイズ)を示している。   A packet 501 indicated by a dotted-line rectangle represents a predicted packet that arrives (that is, a packet that has not been received at this time). The packet 501 also describes the “sequence number start position” and the “TCP data size” of the packet. For example, in the packet 501, “2” is the sequence number and “1460” is the TCP MSS size (data size in the packet).

三角マークで示すタイミング502は、ACKパケットが送信される時間的な位置を示している。ここでは、上述の通り、2個目のパケットの受信にしたあとに送信している例を示している。ACKパケット503は、生成されるACKパケットの構造の例を示している。図6では、受信するデータを含むパケットのシーケンス番号の初期値が“2”であり、MSSサイズ×2=2920であるため、生成するACKパケットのACK番号は、それぞれ“2922”、“5842”、“8762”となっている。   A timing 502 indicated by a triangle mark indicates a temporal position at which the ACK packet is transmitted. Here, as described above, an example is shown in which the second packet is received and then transmitted. The ACK packet 503 shows an example of the structure of the generated ACK packet. In FIG. 6, since the initial value of the sequence number of the packet including the data to be received is “2” and the MSS size × 2 = 2920, the ACK numbers of the generated ACK packets are “2922” and “5842”, respectively. , "8762".

S309では、CPU202は、生成したACKパケットをACKパケット管理構造体の生成済みACKパケット管理のキューの最後にキューイングする。   In S309, the CPU 202 queues the generated ACK packet at the end of the generated ACK packet management queue of the ACK packet management structure.

S310では、CPU202は、現在注目しているTCP接続に対するACKパケットをこれ以上生成する必要はないため、次のTCP接続管理構造体401を抜き出す。   In S310, the CPU 202 does not need to generate any more ACK packet for the TCP connection currently being focused on, so the CPU 202 extracts the next TCP connection management structure 401.

なお、イベント待ち(S302)の解除は、アプリケーションがデータを読み込んだとき、TCP−SYNパケットを受信したとき、TCP−SYNパケットを送信するときに行われる。また、TCPデータパケットを受信したとき、TCPデータパケットを送信するとき、TCP接続を切断するときにも行われる。   The event waiting (S302) is released when the application reads data, receives a TCP-SYN packet, or transmits a TCP-SYN packet. It is also performed when a TCP data packet is received, when a TCP data packet is transmitted, and when a TCP connection is disconnected.

図4は、ACKパケットの生成(図3)の優先順位の例を示す図である。図4(a)は、アイドルタスクでACKパケットの生成を行う場合のタスクの優先順位を示している。上に行くほど優先度が高いタスクであり、下に行くほど優先度が低いタスクであることを示している。アイドルタスクは、機器組み込み型のOSにおいて、他に実行すべき処理がないアイドル状態の場合に実行される、何の処理も行わないタスクである。(a)では、ここにACK生成処理を組み込むことで、すべき処理がない場合、つまりCPUにおいて他に処理するタスクがない場合に実行することができる。   FIG. 4 is a diagram showing an example of the priority order of ACK packet generation (FIG. 3). FIG. 4A shows the priority order of the tasks when the ACK packet is generated by the idle task. The higher the task is, the higher the priority is, and the lower the task is, the lower the priority is. The idle task is a task that is executed in the device built-in OS in the idle state where there is no other process to be executed and does not perform any process. In (a), by incorporating an ACK generation process here, it can be executed when there is no process to be performed, that is, when there is no other task to be processed in the CPU.

また、図4(b)は、ACKパケットの生成の専用タスクを設けた場合のタスクの優先順位を示している。(b)では、アイドルタスクよりやや優先順位が高いタスクとして、ACK生成専用のタスクを設けた場合を示している。また、(c)では、アプリケーションタスク毎に独立したACK生成処理タスクを設けた場合を示している。このように構成しても、アイドルタスクが実行される直前の状態、つまりCPUが他に処理するタスクがない場合に実行することができる。   Further, FIG. 4B shows the priority order of tasks when a dedicated task for generating an ACK packet is provided. (B) shows a case where a task dedicated to ACK generation is provided as a task having a slightly higher priority than the idle task. Further, (c) shows a case where an independent ACK generation processing task is provided for each application task. Even with this configuration, the idle task can be executed in a state immediately before execution, that is, when the CPU has no other task to process.

なお、ネットワーク処理をネットワーク以外の処理よりも優先させる場合、ACK生成タスクの優先順位がネットワーク以外の処理の優先順位よりも高くなるよう構成するとよい。また、TCP接続要求受付直後やTCP接続完了後など、TCP通信開始より前に行うよう構成してもよい。   When the network processing is prioritized over the processing other than the network, the priority of the ACK generation task may be set higher than the priority of the processing other than the network. Further, it may be configured to be performed before the TCP communication is started, such as immediately after receiving the TCP connection request or after completing the TCP connection.

図7は、第1実施形態におけるACKパケット送信の動作フローチャートである。この動作は、TCPパケットの受信を待機し、S601でTCPパケットの受信をトリガに開始される。   FIG. 7 is an operation flowchart of ACK packet transmission in the first embodiment. This operation waits for the reception of the TCP packet, and is triggered by the reception of the TCP packet in S601.

S601では、CPU202は、TCPパケットを受信する。S602では、CPU202は、TCPパケットの宛先アドレス、宛先ポート番号、送信元アドレス、送信元ポート番号などから、受信したTCPパケットに対応するTCP接続管理構造体を検索する。ここでは、検索の結果、TCP接続管理構造体401が特定される。   In S601, the CPU 202 receives a TCP packet. In S602, the CPU 202 searches the TCP connection management structure corresponding to the received TCP packet from the destination address, the destination port number, the source address, the source port number, etc. of the TCP packet. Here, as a result of the search, the TCP connection management structure 401 is specified.

S603では、CPU202は、受信したTCPパケットに対応するTCP接続管理構造体が存在するか否かを判断し、存在する場合はS604に進み、存在しない場合はS613に進む。S613では、CPU202は、TCP_Reset(TCP−RST)パケットを送信した後、S618に進み処理を終了する。   In S603, the CPU 202 determines whether or not the TCP connection management structure corresponding to the received TCP packet exists. If it exists, the process proceeds to S604, and if it does not exist, the process proceeds to S613. In S613, the CPU 202 transmits a TCP_Reset (TCP-RST) packet, and then proceeds to S618 and ends the processing.

S604では、CPU202は、受信したパケットのデータを、当該受信パケットに対応するTCP接続管理構造体にキューイングしたり、受信したデータの順序制御を行うなどのTCP受信処理を行う。   In S604, the CPU 202 performs TCP reception processing such as queuing the data of the received packet in the TCP connection management structure corresponding to the received packet and controlling the order of the received data.

S605では、CPU202は、受信したデータに対してACKを送信するかどうか判断する。ACKを送信しない場合はS618に進み処理を終了する。ACKを送信する場合は、S606では、CPU202は、TCP接続管理構造体のACKパケットを調査し、S607では、CPU202は、生成済みのACKパケットが存在するか否かを判断する。生成済みのACKパケットがなければ、S614では、受信したデータに対応するACKパケットを生成して送信した後、S618に進み処理を終了する。生成済みのACKパケットがあればS608に進む。   In S605, the CPU 202 determines whether to send an ACK for the received data. If no ACK is sent, the process advances to step S618 to end the process. When transmitting an ACK, in S606, the CPU 202 checks the ACK packet of the TCP connection management structure, and in S607, the CPU 202 determines whether or not there is a generated ACK packet. If there is no generated ACK packet, in S614, an ACK packet corresponding to the received data is generated and transmitted, and then the process proceeds to S618 and ends the processing. If there is a generated ACK packet, the process proceeds to S608.

S608及びS609では、CPU202は、“受信パケットにおけるシーケンス番号とデータサイズとの和(すなわち、応答すべきACK番号)”と、“生成済みのACKパケットのACK番号”とを比較する。生成済みのACKパケットのACK番号が応答すべきACK番号より大きい場合はS614に進みACKパケットを新規に生成し送信する。一方、生成済みのACKパケットのACK番号と応答すべきACK番号とが同じである場合はS615に進み、生成済みのACKパケットのACK番号が応答すべきACK番号より小さい場合はS610に進む。   In S608 and S609, the CPU 202 compares “the sum of the sequence number and the data size in the received packet (that is, the ACK number to respond)” with the “ACK number of the generated ACK packet”. If the ACK number of the generated ACK packet is larger than the ACK number to be responded to, the process proceeds to S614 and a new ACK packet is generated and transmitted. On the other hand, if the ACK number of the generated ACK packet and the ACK number to be responded are the same, the process proceeds to S615, and if the ACK number of the generated ACK packet is smaller than the ACK number to be responded, the process proceeds to S610.

S615では、CPU202は、生成済みのACKパケットを調整する。具体的には、TCP接続管理構造体からシーケンス番号と受信バッファ残量をACKパケットに代入する。そして、それらの値をチェックサムに足し込む。その後、S616では、CPU202は、調整された生成済みのACKパケットを送信する。S617では、送信したACKパケットをフリーにした後、すなわち、現在注目しているACKパケットを破棄し、S618に進み処理を終了する。   In S615, the CPU 202 adjusts the generated ACK packet. Specifically, the sequence number and the reception buffer remaining amount are substituted into the ACK packet from the TCP connection management structure. Then, those values are added to the checksum. After that, in S616, the CPU 202 transmits the adjusted generated ACK packet. In S617, after the transmitted ACK packet is made free, that is, the ACK packet currently focused on is discarded, and the process proceeds to S618 and ends the process.

S610では、CPU202は、次の生成済みのACKパケットがあるかどうかを調べる。次の生成済みのACKパケットがある場合はS611に進み。一方、次の生成済みのACKパケットが無い場合はS615に進み、現在注目している生成済みのACKパケットを調整して送信する。   In S610, the CPU 202 checks whether there is a next generated ACK packet. If there is the next generated ACK packet, the process proceeds to S611. On the other hand, if there is no next generated ACK packet, the process advances to step S615 to adjust and transmit the currently generated generated ACK packet.

S611では、CPU202は、“受信パケットにおけるシーケンス番号とデータサイズとの和(すなわち、応答すべきACK番号)”と、“次の生成済みのACKパケットのACK番号”とを比較する。次のACK番号の方が小さければ、S612に進み、現在の生成済みのACKパケットをフリーにした後、次の生成済みのACKを現在の生成済みのACKとして設定し、S609に戻る。一方、次のACK番号の方が大きい場合は、当該次の生成済みのACKパケットは受信していないデータに対するものであるためS615に進み、現在注目している生成済みのACKパケットを調整して送信する。   In step S <b> 611, the CPU 202 compares “the sum of the sequence number and the data size in the received packet (that is, the ACK number to respond)” with the “ACK number of the next generated ACK packet”. If the next ACK number is smaller, the process proceeds to S612, the current generated ACK packet is freed, the next generated ACK is set as the current generated ACK, and the process returns to S609. On the other hand, if the next ACK number is larger, the next generated ACK packet is for data that has not been received, and thus the processing proceeds to step S615 to adjust the currently generated generated ACK packet. Send.

<ACKパケットにおけるIPヘッダ生成>
ACKパケットの生成処理(S308)に含まれる各種処理について図5及び図9を参照して説明する。図9(a)は、TCPのACKパケットの構造を示し、図9(b)は、TCPヘッダと仮想ヘッダの構造を示している。
<IP header generation in ACK packet>
Various processes included in the ACK packet generation process (S308) will be described with reference to FIGS. 5 and 9. 9A shows the structure of the TCP ACK packet, and FIG. 9B shows the structure of the TCP header and the virtual header.

TCPのACKパケットは、IPヘッダ(20バイト)、TCPヘッダ(20バイト)から構成されており、このパケットを送信することで送信側にTCPデータを受信したことを通知する。仮想ヘッダとTCPヘッダは、TCPチェックサムの計算に使われる。   The TCP ACK packet is composed of an IP header (20 bytes) and a TCP header (20 bytes). By transmitting this packet, the sender is notified that TCP data has been received. The virtual header and the TCP header are used to calculate the TCP checksum.

まず、TCP接続管理構造体401を参照し、送信元IPアドレス、宛先IPアドレスを調べ、仮想ヘッダの送信元IPアドレス、宛先IPアドレスに代入する。仮想ヘッダのZeroには“0x00”、プロトコル番号にはTCPを示す“0x06”、TCP長にはTCPヘッダ長である“20”をそれぞれ代入する。   First, the TCP connection management structure 401 is referenced, the source IP address and the destination IP address are checked, and the source IP address and the destination IP address of the virtual header are substituted. Substitute “0x00” for Zero of the virtual header, “0x06” indicating TCP for the protocol number, and “20” that is the TCP header length for the TCP length.

また、TCP接続管理構造体401を参照し、送信元ポート番号、宛先ポート番号を調べ、TCPヘッダの送信元ポート番号、宛先ポート番号にコピーする。更に、TCP接続管理構造体401を参照し、送信済みシーケンス番号と受信済みシーケンス番号を調べ、それぞれを、TCPヘッダの送信済み番号に、TCPヘッダのACK番号に代入する。   Further, the TCP connection management structure 401 is referred to, the source port number and the destination port number are checked, and the source port number and the destination port number of the TCP header are copied. Further, referring to the TCP connection management structure 401, the transmitted sequence number and the received sequence number are checked, and each is substituted for the transmitted number of the TCP header and the ACK number of the TCP header.

ヘッダ長には20÷4(32ビット単位で表現されるため)で“5”を代入する。Flag+ReservedにはACKパケットであるので“ACKフラグ”を立てる。更に、window sizeには、この時の残りの受信バッファサイズを代入する。チェックサムに“0”、緊急ポインタに“0”を代入する。仮想ヘッダ+TCPヘッダのチェックサムを計算し、チェックサムに代入する。次にTCPヘッダを残したまま仮想ヘッダを取り除き、IPヘッダを生成する。   "5" is substituted for the header length by 20/4 (because it is expressed in units of 32 bits). Since Flag + Reserved is an ACK packet, an "ACK flag" is set. Furthermore, the remaining receive buffer size at this time is substituted into the window size. Substitute "0" for the checksum and "0" for the urgent pointer. The checksum of the virtual header + TCP header is calculated, and is substituted for the checksum. Next, the virtual header is removed while leaving the TCP header, and the IP header is generated.

次に、生成したIPヘッダの各部に値を代入する。送信元IPアドレスと宛先IPアドレスはTCP接続管理構造体401の情報を代入する。全体長にはIPヘッダ長+TCPヘッダ長である“40”を代入する。プロトコル番号にはTCPを示す“0x06”、ヘッダチェックサムには“0”を代入する。そして、ヘッダチェックサムには、IPヘッダ部分20バイトのチェックサムを計算した結果を代入する。   Next, a value is substituted for each part of the generated IP header. The information of the TCP connection management structure 401 is substituted for the source IP address and the destination IP address. “40” which is the IP header length + TCP header length is substituted for the total length. “0x06” indicating TCP is assigned to the protocol number, and “0” is assigned to the header checksum. Then, the result of calculating the checksum of 20 bytes of the IP header is substituted for the header checksum.

このように、ACKパケットの生成には、仮想ヘッダの生成、TCPヘッダの生成、仮想ヘッダのチェックサム計算、TCPヘッダのチェックサム計算、IPヘッダの生成、IPヘッダのチェックサム計算、が含まれる。このような様々なデータ処理が必要であるため、ACKパケットの生成には相応の時間を要することになる。   As described above, generation of an ACK packet includes generation of a virtual header, generation of a TCP header, calculation of a virtual header checksum, calculation of a TCP header checksum, generation of an IP header, and calculation of an IP header checksum. . Since such various data processings are required, it takes a certain amount of time to generate the ACK packet.

<効果>
図8は、第1実施形態に係るTCP通信における効果を説明する図である。図8(a)は、従来技術における送受信の動作を示しており、図8(b)は、第1実施形態における送受信の動作を示している。それぞれ、TCP接続確立後の、送信側機器から受信側機器へのデータ送信、受信側機器から送信側機器へのACK送信を例示的に示している。図8において縦方向は時間の経過を示している。特に、受信側機器における「ACK生成」「受信処理」「idle」の各時間を例示的に示している。
<Effect>
FIG. 8 is a diagram illustrating an effect in TCP communication according to the first embodiment. FIG. 8A shows a transmission / reception operation in the conventional technique, and FIG. 8B shows a transmission / reception operation in the first embodiment. Each of them exemplarily shows data transmission from the transmission side device to the reception side device and ACK transmission from the reception side device to the transmission side device after the TCP connection is established. In FIG. 8, the vertical direction indicates the passage of time. Particularly, the respective times of “ACK generation”, “reception processing”, and “idle” in the receiving side device are shown as an example.

なお、「ACK生成」は、ACK生成からACK送信までの処理に要する時間、「受信処理」は、TCPパケット受信からアプリケーションによるデータの読み込みまでの処理に要する時間、「idle」は、CPUの空き時間である。   Note that “ACK generation” is the time required for processing from ACK generation to ACK transmission, “Reception processing” is the time required for processing from TCP packet reception to data reading by an application, and “idle” is CPU idle. It's time.

説明を簡単にするため、図8では、送信側機器が送信するパケットの各々で送信されるデータ量は、MSS単位であるとする。また、受信側機器の受信バッファは、MSS×4のパケットを受信するといっぱいになるとする。更に、以下の説明においては、最初の6個のパケット(A〜F)の送信について詳細に説明するが、後続のパケットにおいても同様の動作が実行される。   In order to simplify the explanation, in FIG. 8, it is assumed that the amount of data transmitted in each packet transmitted by the transmitting device is in MSS units. Further, it is assumed that the receiving buffer of the receiving side device becomes full when receiving an MSS × 4 packet. Furthermore, in the following description, the transmission of the first six packets (A to F) will be described in detail, but the same operation is performed for the subsequent packets.

・従来技術における送受信の動作
送信側機器は、受信側機器のウィンドウサイズ(残りの受信バッファサイズ)分のパケット(ここでは、A、B、C、Dの4個)を送信する。受信側機器は、パケットを受信する毎に受信処理を行う。TCPでは連続して大きなパケットを受信する場合、受信側機器は、2×MSSのデータを受信するとACKを1回送信する。そのため、ここでは、受信側機器は、2個のパケット(A、B)の受信処理を行い、これらの受信処理の完了後、Bまでのパケットを受信したことを示すACK(図における「A+B」)を生成し送信する。同様に、後続の2個のパケット(C、D)の受信処理を行い、これらの受信処理の完了後、Dまでのパケットを受信したことを示すACK(図における「C+D」)を生成し、送信する。
-Transmission / reception operation in the related art The transmission-side device transmits packets (here, four packets A, B, C, and D) corresponding to the window size (remaining reception buffer size) of the reception-side device. The receiving device performs a reception process each time a packet is received. In TCP, when receiving a large number of packets in succession, the receiving device transmits an ACK once when receiving 2 × MSS data. Therefore, here, the receiving side device performs the reception process of two packets (A, B), and after completion of these reception processes, an ACK (“A + B” in the figure) indicating that the packets up to B have been received. ) Is generated and transmitted. Similarly, the following two packets (C, D) are received, and after completion of these reception processes, an ACK (“C + D” in the figure) indicating that packets up to D have been received is generated, Send.

送信側機器が上述の4個のパケット(A、B、C、D)を送った時点で相手のウィンドウサイズがいっぱいになっているため、送信側機器は、受信側機器が送信するACKを受信するまで次のパケット(E以降)を送信することができない。   Since the window size of the other party is full when the sending device sends the above four packets (A, B, C, D), the sending device receives the ACK sent by the receiving device. The next packet (E and later) cannot be transmitted until after.

送信側機器は、ACKパケット(上述の「A+B」)を受信するとウィンドウサイズが2MSS分空いたことが分かるため、2個のパケット(E、F)を送信する。この時点で、受信側機器は、2個のパケット(C、D)の受信処理とこれらのパケットに対するACK(図における「C+D」)の送信を終えている。しかしながら、受信側機器は、次のパケット(E以降)を受信していないため、アイドルタスクを実行している。その後、受信側機器は、2個のパケット(E、F)を受信すると、それぞれ受信処理を行い、Fまでのパケットを受信したことを示すACK(図における「E+F」)を生成し、送信する。   When the transmitting device receives the ACK packet (“A + B” described above), it knows that the window size is vacant by 2 MSS, and thus transmits the two packets (E, F). At this point, the receiving-side device has completed the reception process of two packets (C, D) and the transmission of ACK (“C + D” in the figure) for these packets. However, since the receiving device has not received the next packet (after E), it is executing the idle task. After that, when the receiving side device receives two packets (E, F), each of them performs a receiving process, generates an ACK (“E + F” in the figure) indicating that the packets up to F have been received, and transmits the ACK. .

・第1実施形態における送受信の動作
送信側機器は、受信側機器のウィンドウサイズ分のパケット(ここでは、A、B、C、Dの4個)を送信する。受信側機器は、2個のパケット(A、B)の受信処理を行い、これらの受信処理の完了後、Bまでのパケットを受信したことを示すACKを生成し送信する。同様に、2個のパケット(C、D)の受信処理を行い、これらの受信処理の完了後、Dまでのパケットを受信したことを示すACKを生成し、送信する。ここまでの動作は従来技術と同じである。
-Transmission / reception operation in the first embodiment The transmission-side device transmits packets for the window size of the reception-side device (here, four packets A, B, C, and D). The reception side device performs the reception process of two packets (A, B), and after completion of these reception processes, generates and transmits ACK indicating that the packets up to B have been received. Similarly, reception processing of two packets (C, D) is performed, and after completion of these reception processings, an ACK indicating that packets up to D have been received is generated and transmitted. The operation up to this point is the same as in the prior art.

ACK(「C+D」)を送信後、受信側機器は、後続のパケット(E以降)の到着までの間(すなわち、従来の動作では「idle」であった期間)、後続のパケットに対応するACKの生成処理を行う。受信側機器は、パケット(E)を受信すると当該パケットの受信処理を行い、パケット(F)を受信すると当該パケットの受信処理を行う。   After transmitting the ACK (“C + D”), the receiving device receives the ACK corresponding to the subsequent packet until the arrival of the subsequent packet (after E) (that is, the period of “idle” in the conventional operation). Is generated. When receiving the packet (E), the receiving side device performs the receiving process of the packet, and when receiving the packet (F), the receiving device performs the receiving process of the packet.

受信側機器は、Fまでのパケットを受信したことを示すACK(図における「E+F」)を図7の動作に従って選択し送信する。すなわち、先行して生成済みのACKを選択し使用しているため、Fまでのパケットを受信した後、従来より短い時間で対応するACK(「E+F」)を送信することができる。以降も同様な動作を行うことにより、受信側機器がRのパケットを受信するまでの時間をδだけ短くすることができる。すなわち、同じ量のデータをより短時間に送信することが可能となっており、送信側機器から受信側機器により高速にデータを伝送することが可能となる。   The receiving device selects and transmits ACK (“E + F” in the figure) indicating that the packets up to F have been received according to the operation of FIG. 7. That is, since the previously generated ACK is selected and used, the corresponding ACK (“E + F”) can be transmitted in a shorter time than before after receiving the packets up to F. By performing the same operation thereafter, the time until the receiving side device receives the R packet can be shortened by δ. That is, the same amount of data can be transmitted in a shorter time, and the data can be transmitted from the transmission side device to the reception side device at high speed.

以上説明したとおり第1実施形態によれば、TCP通信におけるACKパケットの生成処理を、対応するデータパケットの受信に先立って開始する。これにより、対応するデータパケットを受信した際に、ACKパケットの生成処理の少なくとも一部が完了しているため、速やかに、ACKパケットを送信することが可能となり、通信時間を短縮することが可能となる。特に、ACKパケットの生成を優先順位の低いタスクあるいはアイドルタスクにおいて実行することにより、他の処理に悪影響を与えることなく、CPUをより有効利用することが可能となる。   As described above, according to the first embodiment, the ACK packet generation process in TCP communication is started prior to the reception of the corresponding data packet. As a result, at least a part of the generation process of the ACK packet is completed when the corresponding data packet is received, so that the ACK packet can be transmitted promptly and the communication time can be shortened. Becomes In particular, by executing the generation of the ACK packet in the task with the low priority or the idle task, it becomes possible to use the CPU more effectively without adversely affecting other processing.

なお、上述の説明では、ACKパケットの生成に関連する処理を全てCPUが行っているものとして説明をしているが、一部の処理をハードウェアにオフロードするよう構成してもよい。   In the above description, it is assumed that the CPU performs all the processing related to the generation of the ACK packet, but a part of the processing may be offloaded to hardware.

(第2実施形態)
第2実施形態では、所定の種別の通信接続、例えば、大量のデータを受信するTCP接続のみを対象として、第1実施形態で説明したACKパケットの生成処理を行う形態について説明する。
(Second embodiment)
The second embodiment will describe a mode in which the ACK packet generation process described in the first embodiment is performed only for a predetermined type of communication connection, for example, a TCP connection that receives a large amount of data.

図10は、第2実施形態におけるACKパケット生成の動作フローチャートである。なお、図10は、図3に対して、S304とS305との間にS1111を追加したものに相当する。具体的には、S1111において、CPU202は、S304において存在すると判定されたTCP接続に対して、当該TCP接続が大量のデータを受信するTCP接続であるか否かを判断する。   FIG. 10 is an operation flowchart of ACK packet generation in the second embodiment. Note that FIG. 10 corresponds to FIG. 3 with S1111 added between S304 and S305. Specifically, in S1111, the CPU 202 determines, with respect to the TCP connection determined to exist in S304, whether the TCP connection is a TCP connection that receives a large amount of data.

そして、大量のデータを受信するTCP接続である場合にのみ、事前にACKパケットを生成する。すなわち、大量のデータを受信するTCP接続でない場合は、事前にACKパケットを生成せず、データパケットを受信後にACKパケットを生成する。   Then, only in the case of a TCP connection that receives a large amount of data, an ACK packet is generated in advance. That is, if the TCP connection does not receive a large amount of data, the ACK packet is not generated in advance, but the ACK packet is generated after the data packet is received.

なお、大量のデータを受信するかどうかの判断は、例えば、TCP接続管理構造体401のフラグに、大量のデータを受信することを示すフラグが存在しているか否かに基づいて判定する。すなわち、大量のデータを受信するアプリケーションは、通信前や通信中に大量のデータを受信することを示すフラグをTCP接続管理構造体401に設定する。   It should be noted that whether or not to receive a large amount of data is determined, for example, based on whether or not the flag of the TCP connection management structure 401 includes a flag indicating that a large amount of data will be received. That is, an application that receives a large amount of data sets a flag indicating that a large amount of data will be received before or during communication in the TCP connection management structure 401.

また、アプリケーションがフラグを設定する代わりに、プロトコルスタックが、フラグを設定するよう構成してもよい。例えば、受信したパケットの先頭を読み出し、画像データ、動画データであった場合に大量のデータを受信することを示すフラグを設定するとよい。   Also, instead of the application setting the flag, the protocol stack may be configured to set the flag. For example, the head of the received packet may be read, and a flag indicating that a large amount of data is received when the data is image data or moving image data may be set.

以上説明したとおり第2実施形態によれば、画像データや音声データなどの大量のデータを受信する場合のみ事前にACKパケットを生成する。これにより、事前に生成したACKパケットに使用されるメモリ量を減らすことができ、また、CPUを他の処理に利用することが可能となる。   As described above, according to the second embodiment, the ACK packet is generated in advance only when a large amount of data such as image data and audio data is received. As a result, the amount of memory used for the ACK packet generated in advance can be reduced, and the CPU can be used for other processing.

(第3実施形態)
第3実施形態では、同時接続数に基づいて事前に生成するACKパケットに関して制限を設ける形態について説明する。以下の説明では、同時接続数に基づいて、生成可能なACKパケットの個数の上限値(ACK_MAX)を決定する例について説明する。
(Third Embodiment)
In the third embodiment, a form will be described in which an ACK packet generated in advance based on the number of simultaneous connections is limited. In the following description, an example will be described in which the upper limit value (ACK_MAX) of the number of ACK packets that can be generated is determined based on the number of simultaneous connections.

図11は、第3実施形態におけるACKパケット生成の動作フローチャートである。図11は、図3に対して、S307とS308との間にS1211,S1212を追加したものに相当する。また、図12は、第3実施形態におけるACKパケット送信の動作フローチャートである。なお、図12は、図7に対して、ACKをフリー(S612,S617)にした後にS1319,S1320を追加したものに相当する。   FIG. 11 is an operation flowchart of ACK packet generation in the third embodiment. FIG. 11 corresponds to FIG. 3 with S1211 and S1212 added between S307 and S308. In addition, FIG. 12 is an operation flowchart of ACK packet transmission in the third embodiment. Note that FIG. 12 corresponds to FIG. 7 in which S1319 and S1320 are added after ACK is free (S612 and S617).

以下の説明において、ACK_MAXは、生成するACKパケットの個数の上限値、ack_nowは、現在生成済みのACKパケットの個数をそれぞれ示すパラメータである。ACK_MAXの値は、通信装置212が搭載するメモリのサイズ等に基づいて静的に決定しても良いし、通信装置212の使用者が設定する形態でも良い。また、ack_nowの値は、例えば、通信装置212の起動時あるいはTCPスタックの起動時にゼロクリアされる(起動時には、生成済みACKパケットは0個)。   In the following description, ACK_MAX is an upper limit value for the number of ACK packets to be generated, and ack_now is a parameter indicating the number of ACK packets currently generated. The value of ACK_MAX may be statically determined based on the size of the memory installed in the communication device 212, or may be set by the user of the communication device 212. Further, the value of ack_now is cleared to zero when the communication device 212 is started up or when the TCP stack is started up (at the time of start-up, the number of generated ACK packets is 0).

具体的には、ACKパケット生成フロー(図11)のS307において生成済みACK番号と生成予定ACK番号を比較し、生成済みACK番号が生成予定ACK番号より小さい場合S1211に進む。   Specifically, in S307 of the ACK packet generation flow (FIG. 11), the generated ACK number is compared with the planned ACK number, and if the generated ACK number is smaller than the planned ACK number, the process proceeds to S1211.

S1211では、CPU202は、ack_nowとACK_MAXとを比較する。ack_nowがACK_MAXより小さければ、S1212で、ack_nowを1増やし(インクリメント)、S308でACKパケットを生成する。   In S1211, the CPU 202 compares ack_now with ACK_MAX. If ack_now is smaller than ACK_MAX, ack_now is incremented (incremented) by 1 in S1212, and an ACK packet is generated in S308.

一方、ACKパケット送信フロー(図12)においてACKをフリーにする場合は、ack_nowを1減らす(デクリメント)。これにより、現在生成済みのACKパケットの個数を正しく管理することが可能となる。   On the other hand, in the case of making ACK free in the ACK packet transmission flow (FIG. 12), ack_now is decremented by 1 (decrement). This makes it possible to correctly manage the number of currently generated ACK packets.

以上説明したとおり第3実施形態によれば、生成するACKパケットの個数に上限を設けることができる。これにより、TCPの同時接続数が多い場合などにおいて、ACKパケットを多量に生成することによるメモリの過剰な消費を防ぐことが可能となる。なお、ACK_MAXをTCP接続毎に決定するよう構成してもよい。また、TCP接続毎に異なる最大個数(ACK_MAX)を設定してもよい。TCP接続毎に異なる最大個数(ACK_MAX)を設定する場合、その上限値を接続の受信バッファサイズをMSSで割った値を使用して決定してもよい。   As described above, according to the third embodiment, it is possible to set an upper limit on the number of generated ACK packets. As a result, when the number of simultaneous TCP connections is large, it is possible to prevent excessive memory consumption due to the generation of a large number of ACK packets. The ACK_MAX may be determined for each TCP connection. Also, a different maximum number (ACK_MAX) may be set for each TCP connection. When setting a different maximum number (ACK_MAX) for each TCP connection, the upper limit value may be determined using a value obtained by dividing the connection reception buffer size by the MSS.

(第4実施形態)
第4実施形態では、受信したデータパケットのデータサイズが、予測されたサイズと一致しない場合の動作について説明する。
(Fourth Embodiment)
In the fourth embodiment, the operation when the data size of the received data packet does not match the predicted size will be described.

図13は、第4実施形態における受信パケットに対するACKパケットの送信位置を示す図である。なお、点線の矩形は受信側機器が未受信であり、実線で示す矩形は受信側端末が受信済みであることを示している。   FIG. 13 is a diagram showing the transmission position of the ACK packet with respect to the received packet in the fourth embodiment. The dotted-line rectangle indicates that the receiving-side device has not received, and the solid-line rectangle indicates that the receiving-side terminal has already received.

図13(a)に示すパケット群を受信することを想定し、図13(a)のタイミング502でACKを生成したとする。しかし、実際には図13(b)に示すように、受信パケット501−03のようなパケットを受信することがある。この場合、タイミング502−02やタイミング502−03のように、ACKパケットの送信タイミング及びACK番号が、データパケットの受信タイミング及びデータサイズの区切り単位からずれることになる。   Assuming that the packet group shown in FIG. 13A is received, it is assumed that the ACK is generated at the timing 502 in FIG. However, actually, as shown in FIG. 13B, a packet like the received packet 501-03 may be received. In this case, the transmission timing and the ACK number of the ACK packet deviate from the reception timing of the data packet and the delimiter unit of the data size, such as timing 502-02 and timing 502-03.

ところで、TCPでは、データの送達確認をパケット単位では無くバイト単位(シーケンス番号)で管理している。そのため、予め生成したACKパケットを送信しても、正常にデータ通信を継続することが可能である。そこで、例えば、図13(b)では、パケット501−05を受信したときに、タイミング502−02でACKパケットを送信する。   Incidentally, in TCP, data delivery confirmation is managed in byte units (sequence numbers) instead of packet units. Therefore, even if the ACK packet generated in advance is transmitted, the data communication can be normally continued. Therefore, for example, in FIG. 13B, when the packet 501-05 is received, an ACK packet is transmitted at timing 502-02.

このように、生成したACKパケットの“ACK番号”と“受信したパケットのシーケンス番号+データサイズ”とが一致しない場合であっても、正常にデータ通信を継続することが可能である。すなわち、“受信したパケットのシーケンス番号+データサイズ”よりも小さいACK番号を有するACKパケットを送信することにより、ACKパケットを作り直すこと無く通信を継続することが可能となる。   As described above, even when the “ACK number” of the generated ACK packet and the “sequence number of the received packet + data size” do not match, it is possible to continue data communication normally. That is, by transmitting an ACK packet having an ACK number smaller than “the received packet sequence number + data size”, communication can be continued without recreating the ACK packet.

・変形例1
上述のように、TCPにおいては、受信したデータパケットを単位としたACKパケットを返信しなくとも、正常に通信を継続することが出来る。ただし、受信したパケットを単位としたACKパケットを返信するよう構成してもよい。
-Modification 1
As described above, in TCP, communication can be normally continued without returning an ACK packet in units of received data packets. However, an ACK packet may be returned in units of received packets.

図13(c)は、第4実施形態の変形例1における受信パケットに対するACKパケットの送信位置を示す図である。タイミング512−01、512−02において送信されるACKパケットは、上述の図13(b)のタイミング502−01、502−02において送信されるACKパケットと同様である。一方、タイミング512−03において送信されるACKパケットは、受信したパケットの単位に対する確認応答となるように生成し送信している。なお、図13(c)においては、各タイミングの下に括弧書きで生成済みACKパケットのACK番号を示している。   FIG. 13C is a diagram showing the transmission position of the ACK packet with respect to the received packet in the first modification of the fourth embodiment. The ACK packets transmitted at timings 512-01 and 512-02 are the same as the ACK packets transmitted at timings 502-01 and 502-02 in FIG. 13B described above. On the other hand, the ACK packet transmitted at timing 512-03 is generated and transmitted so as to be an acknowledgment for the unit of the received packet. In FIG. 13C, the ACK number of the generated ACK packet is shown in parentheses below each timing.

図14は、第4実施形態の変形例1におけるACKパケット送信の動作フローチャートである。なお、図14は、図7に対して、S1619を追加したものに相当する。図14において、S610に進むのは、現在注目している生成済みACKパケットにおいて“(受信パケットの)シーケンス番号とデータサイズとの和”が“ACK番号”より小さい場合である。具体的には、現在注目している生成済みACKパケットのACK番号がずれている場合である。   FIG. 14 is an operation flowchart of ACK packet transmission in the first modification of the fourth embodiment. Note that FIG. 14 corresponds to FIG. 7 with S1619 added. In FIG. 14, the process proceeds to S610 when the “sum of the sequence number (of the received packet) and the data size” of the generated ACK packet of interest is smaller than the “ACK number”. Specifically, this is a case where the ACK numbers of the generated ACK packets that are currently focused are deviated.

その状態において、次のACKパケットが無い場合、S1619では、CPU202は、TCP接続管理構造体の生成済みACK番号を、受信したパケットのシーケンス番号及びデータサイズに基づいた値に書き換える。これにより、例えば、タイミング512−03で送信されることになるACKパケットのACK番号は、“8762(=2+1460×6)”だったものが“8032(=5112+1460×2)”に書き換わることになる。すなわち、ACK番号のずれが修正され、受信したデータを単位としたACKパケットを返信することが可能となる。   If there is no next ACK packet in that state, in S1619, the CPU 202 rewrites the generated ACK number of the TCP connection management structure to a value based on the sequence number and data size of the received packet. As a result, for example, the ACK number of the ACK packet to be transmitted at the timing 512-03 was changed from “8762 (= 2 + 1460 × 6)” to “8032 (= 5112 + 1460 × 2)”. Become. That is, the deviation of the ACK number is corrected, and it becomes possible to send back an ACK packet in units of received data.

・変形例2
ところで、受信したデータパケットのデータサイズが予測されたサイズと相違しかつ図13(b)に示すような応答を行った場合には問題が生じることがある。具体的には、図13(b)のタイミング502−02でACKパケットを送信した後、パケット501−06以降のパケットを受信しなかった場合、受信済みのデータ(パケット501−05の一部)に対するACKパケットは送信されないことになる。そこで、変形例2では、生成したACKパケットに対して強制送信のためのタイマを設け、タイマ発火時に当該ACKパケットを送信する。
-Modification 2
By the way, a problem may occur when the data size of the received data packet is different from the predicted size and the response shown in FIG. 13B is made. Specifically, when the ACK packet is transmitted at the timing 502-02 in FIG. 13B and the packets after the packet 501-06 are not received, the received data (a part of the packet 501-05) is received. Will not be sent. Therefore, in the second modification, a timer for forced transmission is provided for the generated ACK packet, and the ACK packet is transmitted when the timer fires.

図15は、第4実施形態の変形例2におけるACKパケット送信の動作フローチャートである。なお、図15は、図7に対して、S1719、S1720、S1721を追加したものに相当する。図15において、S610に進むのは、現在注目している生成済みACKパケットにおいて“(受信パケットの)シーケンス番号とデータサイズとの和”が“ACK番号”より小さい場合である。具体的には、現在注目している生成済みACKパケットのACK番号がずれている場合である。   FIG. 15 is an operation flowchart of ACK packet transmission in the second modification of the fourth embodiment. Note that FIG. 15 corresponds to FIG. 7 with addition of S1719, S1720, and S1721. In FIG. 15, the process proceeds to S610 when the “sum of the sequence number (of the received packet) and the data size” of the generated ACK packet of interest is smaller than the “ACK number”. Specifically, this is a case where the ACK numbers of the generated ACK packets that are currently focused are deviated.

その状態において、次のACKパケットが無い場合、S1719では、CPU202は、ACK強制送信タイマを設定する。なお、別のACKパケットを送信する場合(S614、S616)には、タイムアウトによるACKパケットを送信する必要がない。そのため、S1720、S1721においては、ACK強制送信タイマをOFFにするよう制御する。一方、ACK強制送信タイマがタイムアウトすると、これまで受信したデータに対するACKパケットとして、生成したACKパケットを送信する。   If there is no next ACK packet in that state, the CPU 202 sets the ACK forced transmission timer in S1719. When another ACK packet is transmitted (S614, S616), it is not necessary to transmit the ACK packet due to timeout. Therefore, in S1720 and S1721, the ACK forced transmission timer is controlled to be turned off. On the other hand, when the ACK forced transmission timer times out, the generated ACK packet is transmitted as an ACK packet for the data received so far.

このように構成することで、受信したデータパケットのデータサイズが予測されたサイズと相違する場合においても、受信したデータに対するACKパケットの返信漏れを防ぐことが可能となる。   With this configuration, even when the data size of the received data packet is different from the predicted size, it is possible to prevent omission of the ACK packet reply to the received data.

(その他の実施例)
本発明は、上述の実施形態の1以上の機能を実現するプログラムを、ネットワーク又は記憶媒体を介してシステム又は装置に供給し、そのシステム又は装置のコンピュータにおける1つ以上のプロセッサーがプログラムを読出し実行する処理でも実現可能である。また、1以上の機能を実現する回路(例えば、ASIC)によっても実現可能である。
(Other embodiments)
The present invention supplies a program that realizes one or more functions of the above-described embodiments to a system or apparatus via a network or a storage medium, and one or more processors in a computer of the system or apparatus read and execute the program. It can also be realized by the processing. It can also be realized by a circuit (for example, ASIC) that realizes one or more functions.

101 アプリケーションタスク; 102 受信バッファ; 103 受信処理タスク; 104 受信キュー; 105 送信キュー; 106 LANドライバ; 107 ACKパケットバッファ; 108 TCP接続管理機構; 110 ACK生成処理タスク   101 application task; 102 reception buffer; 103 reception processing task; 104 reception queue; 105 transmission queue; 106 LAN driver; 107 ACK packet buffer; 108 TCP connection management mechanism; 110 ACK generation processing task

Claims (12)

通信装置であって、
他の通信装置から送信されるデータパケットに対する確認応答パケットを生成する生成手段と、
前記他の通信装置から受信したデータパケットに対する受信処理を行う受信手段と、
前記データパケットを受信した場合に、前記生成手段により生成された該データパケットに対応する確認応答パケットを送信する送信手段と、
を有し、
前記生成手段は、前記受信手段による前記受信処理よりも優先度の低いタスクとして、少なくとも一部のデータパケットに対する確認応答パケットの生成処理を該データパケットの受信に先立って開始する
ことを特徴とする通信装置。
A communication device,
Generating means for generating an acknowledgment packet for a data packet transmitted from another communication device;
Receiving means for receiving data packets received from the other communication device;
Transmitting means for transmitting an acknowledgment packet corresponding to the data packet generated by the generating means when the data packet is received,
Have
The generation means starts the generation processing of the acknowledgment packet for at least a part of the data packets as a task having a lower priority than the reception processing by the reception means prior to the reception of the data packets. Communication device.
前記送信手段は、データパケットを受信した際に、該データパケットに対応する確認応答パケットが既に前記生成手段により生成されている場合は、該生成された確認応答パケットを送信し、該データパケットに対応する確認応答パケットが前記生成手段により生成されていない場合は、前記データパケットに対応する確認応答パケット前記生成手段によ生成された後に、該生成された確認応答パケットを送信する
ことを特徴とする請求項1に記載の通信装置。
When the data packet is received, when the confirmation response packet corresponding to the data packet has already been generated by the generation unit, the transmission unit transmits the generated confirmation response packet to the data packet. If the corresponding acknowledgment packet is not generated by the generating means, that the acknowledgment packet corresponding to the data packet after being generated Ri by said generating means, for transmitting an acknowledgment packet the generated The communication device according to claim 1, wherein the communication device is a communication device.
前記生成手段は、CPUがプログラムを実行することにより実現され、
前記生成手段は、データパケットの受信に先立った該データパケットに対する確認応答パケットの生成処理を、前記CPUにおいて該生成処理より優先度の高いタスクが存在しない場合又は該CPUがアイドル状態にある場合に、実行する
ことを特徴とする請求項1又は2に記載の通信装置。
The generation means is realized by the CPU executing a program,
The generation means performs the generation processing of the acknowledgment packet for the data packet prior to the reception of the data packet when there is no task having a higher priority than the generation processing in the CPU or when the CPU is in the idle state. The communication device according to claim 1, wherein the communication device executes.
未受信のデータパケットに対して前記生成手段が生成可能な確認応答パケットの個数の上限値を設定する設定手段を更に有する
ことを特徴とする請求項1から3の何れか1項に記載の通信装置。
The communication according to any one of claims 1 to 3, further comprising setting means for setting an upper limit value of the number of confirmation response packets that can be generated by the generation means for unreceived data packets. apparatus.
前記通信装置と前記他の通信装置とはTCP(Transmission Control Protocol)に準拠した通信を行い、
既に受信したデータパケットのTCPヘッダに記述されたシーケンス番号と最大セグメントサイズとに基づいて、未受信のデータパケットに対する確認応答パケットの確認応答番号を決定する決定手段を更に有する
ことを特徴とする請求項1から4の何れか1項に記載の通信装置。
The communication device and the other communication device perform communication conforming to TCP (Transmission Control Protocol),
It further comprises a determining means for determining the acknowledgment number of the acknowledgment packet for the unreceived data packet based on the sequence number and the maximum segment size described in the TCP header of the already received data packet. The communication device according to any one of items 1 to 4.
前記生成手段は、前記他の通信装置との間の通信接続が所定の種別の通信接続であることに応じて、データパケットに対する確認応答パケットの生成処理を該データパケットの受信に先立って開始する
ことを特徴とする請求項1から5の何れか1項に記載の通信装置。
When the communication connection with the other communication device is a communication connection of a predetermined type, the generation means starts the generation processing of the confirmation response packet for the data packet before receiving the data packet. The communication device according to claim 1, wherein the communication device is a communication device.
前記他の通信装置との間の通信接続が前記所定の種別の通信接続であるか否かを、当該通信接続を使用するアプリケーションによって接続管理構造体に設定されたフラグ及び当該通信接続で利用されるプロトコルスタックによって接続管理構造体に設定されたフラグの少なくとも一方に基づいて判定する判定手段を更に有する
ことを特徴とする請求項6に記載の通信装置。
Whether or not the communication connection with the other communication device is the predetermined type of communication connection is used by the flag set in the connection management structure by the application using the communication connection and the communication connection. 7. The communication device according to claim 6, further comprising a determination unit that determines based on at least one of the flags set in the connection management structure by the protocol stack.
データパケットを受信したとき、該データパケットにおけるシーケンス番号とデータサイズとの和と、前記生成手段により既に生成された確認応答パケットの確認応答番号と、を比較する比較手段を有し、
前記比較手段により前記和と一致する前記確認応答番号を有する確認応答パケットが無いと判定された場合、前記送信手段は、前記和よりも小さい前記確認応答番号を有する確認応答パケットを送信する
ことを特徴とする請求項1から7の何れか1項に記載の通信装置。
When a data packet is received, it has a comparison means for comparing the sum of the sequence number and the data size in the data packet with the confirmation response number of the confirmation response packet already generated by the generation means,
When it is determined by the comparison means that there is no acknowledgment packet having the acknowledgment number that matches the sum, the transmitting means transmits an acknowledgment packet having the acknowledgment number smaller than the sum. The communication device according to any one of claims 1 to 7, which is characterized.
データパケットを受信したとき、該データパケットにおけるシーケンス番号とデータサイズとの和と、前記生成手段により既に生成された確認応答パケットの確認応答番号と、を比較する比較手段を有し、
前記比較手段により前記和と一致する前記確認応答番号を有する確認応答パケットが無いと判定された場合、前記生成手段は、前記和よりも小さい前記確認応答番号を有する確認応答パケットの該確認応答番号を前記和の値に書き換え、
前記送信手段は、該書き換えを行った確認応答パケットを送信する
ことを特徴とする請求項1から7の何れか1項に記載の通信装置。
When a data packet is received, it has a comparison means for comparing the sum of the sequence number and the data size in the data packet with the confirmation response number of the confirmation response packet already generated by the generation means,
When it is determined by the comparison unit that there is no acknowledgment packet having the acknowledgment number that matches the sum, the generation unit determines the acknowledgment number of the acknowledgment packet having the acknowledgment number smaller than the sum. To the sum value above,
8. The communication device according to claim 1, wherein the transmission unit transmits the rewritten confirmation response packet.
前記受信処理は、前記他の通信装置から送信されたデータパケットに係るデータのキューイング、もしくは、順序制御処理を少なくとも含む  The reception process includes at least queuing of data related to a data packet transmitted from the other communication device, or an order control process.
ことを特徴とする請求項1から9の何れか1項に記載の通信装置。The communication device according to claim 1, wherein the communication device is a communication device.
通信装置の制御方法であって、
他の通信装置から送信されるデータパケットに対する確認応答パケットを生成する生成工程と、
前記他の通信装置から受信したデータパケットに対する受信処理を行う受信工程と、
前記データパケットを受信した場合に、前記生成工程により生成された該データパケットに対応する確認応答パケットを送信する送信工程と、
を含み、
前記生成工程における少なくとも一部のデータパケットに対する確認応答パケットの生成処理は、前記受信工程による前記受信処理よりも優先度の低いタスクとして、該データパケットの受信に先立って開始される
ことを特徴とする制御方法。
A method of controlling a communication device, comprising:
A generation step of generating an acknowledgment packet for a data packet transmitted from another communication device,
A receiving step of performing a receiving process for a data packet received from the other communication device,
A transmitting step of transmitting an acknowledgment packet corresponding to the data packet generated by the generating step when the data packet is received,
Including,
The generation processing of the acknowledgment packet for at least a part of the data packets in the generation step is started prior to the reception of the data packets as a task having a lower priority than the reception processing in the reception step. that control how to be.
コンピュータを、請求項1から10の何れか1項に記載の通信装置の各手段として機能させるためのプログラム。 Program for causing a computer to function as each unit of the communication apparatus according to any one of claims 1 to 10.
JP2016064396A 2016-03-28 2016-03-28 Communication device and control method thereof Active JP6688122B2 (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2016064396A JP6688122B2 (en) 2016-03-28 2016-03-28 Communication device and control method thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2016064396A JP6688122B2 (en) 2016-03-28 2016-03-28 Communication device and control method thereof

Publications (2)

Publication Number Publication Date
JP2017183833A JP2017183833A (en) 2017-10-05
JP6688122B2 true JP6688122B2 (en) 2020-04-28

Family

ID=60008688

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2016064396A Active JP6688122B2 (en) 2016-03-28 2016-03-28 Communication device and control method thereof

Country Status (1)

Country Link
JP (1) JP6688122B2 (en)

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100568232B1 (en) * 2003-07-28 2006-04-07 삼성전자주식회사 Network device and method for efficient data transmission/reception using transport layer in mobile ad-hoc network
KR100785293B1 (en) * 2005-02-11 2007-12-12 삼성전자주식회사 System and Method for TCP Congestion Control Using Multiple TCP ACKs
US8838782B2 (en) * 2008-09-19 2014-09-16 Nec Corporation Network protocol processing system and network protocol processing method
JP5854044B2 (en) * 2011-01-12 2016-02-09 日本電気株式会社 Communication apparatus, packet retransmission control method, packet retransmission control program

Also Published As

Publication number Publication date
JP2017183833A (en) 2017-10-05

Similar Documents

Publication Publication Date Title
CN109936510B (en) Multi-path RDMA transport
US10430374B2 (en) Selective acknowledgement of RDMA packets
US8311059B2 (en) Receive coalescing and automatic acknowledge in network interface controller
JP4921569B2 (en) Data processing for TCP connection using offload unit
US5167035A (en) Transferring messages between nodes in a network
US7953093B2 (en) TCP/IP reordering
EP3396883A1 (en) Data transmission method and related device
US7185114B1 (en) Virtual memory systems and methods
WO2014037760A1 (en) Method and system for increasing data flow transmission
TW200537877A (en) Retransmission system and method for a transport offload engine
US20070291782A1 (en) Acknowledgement filtering
US7009967B1 (en) Systems and methods for transmitting data packets
WO2019001484A1 (en) Method, apparatus and system for adjusting rate of sending side
JP6963411B2 (en) Communication equipment, communication methods, and programs
US8578040B2 (en) Method, system and article for client application control of network transmission loss tolerance
JP2007013449A (en) Shaper control method, data communication system, network interface device and network repeating device
US20040267960A1 (en) Force master capability during multicast transfers
EP3826244B1 (en) Congestion control method and related device
EP1901497A1 (en) Apparatus for low latency communications through an alternate path
JP6688122B2 (en) Communication device and control method thereof
US7213074B2 (en) Method using receive and transmit protocol aware logic modules for confirming checksum values stored in network packet
JP3415027B2 (en) Data communication device and data communication method
JP2017011580A (en) Communication device, control method, and program
JP2000224260A (en) Communication controller
US7646724B2 (en) Dynamic blocking in a shared host-network interface

Legal Events

Date Code Title Description
A621 Written request for application examination

Free format text: JAPANESE INTERMEDIATE CODE: A621

Effective date: 20190123

A977 Report on retrieval

Free format text: JAPANESE INTERMEDIATE CODE: A971007

Effective date: 20191029

A131 Notification of reasons for refusal

Free format text: JAPANESE INTERMEDIATE CODE: A131

Effective date: 20191101

A521 Written amendment

Free format text: JAPANESE INTERMEDIATE CODE: A523

Effective date: 20191225

TRDD Decision of grant or rejection written
A01 Written decision to grant a patent or to grant a registration (utility model)

Free format text: JAPANESE INTERMEDIATE CODE: A01

Effective date: 20200306

A61 First payment of annual fees (during grant procedure)

Free format text: JAPANESE INTERMEDIATE CODE: A61

Effective date: 20200403

R151 Written notification of patent or utility model registration

Ref document number: 6688122

Country of ref document: JP

Free format text: JAPANESE INTERMEDIATE CODE: R151