[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN105871917A - Transmission control protocol TCP connection scheduling method and device - Google Patents

Transmission control protocol TCP connection scheduling method and device Download PDF

Info

Publication number
CN105871917A
CN105871917A CN201610404657.3A CN201610404657A CN105871917A CN 105871917 A CN105871917 A CN 105871917A CN 201610404657 A CN201610404657 A CN 201610404657A CN 105871917 A CN105871917 A CN 105871917A
Authority
CN
China
Prior art keywords
thread
host
connection
client
connects
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.)
Pending
Application number
CN201610404657.3A
Other languages
Chinese (zh)
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.)
Beijing Kingsoft Security Management System Technology Co Ltd
Original Assignee
Beijing Kingsoft Security Management System Technology Co Ltd
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 Beijing Kingsoft Security Management System Technology Co Ltd filed Critical Beijing Kingsoft Security Management System Technology Co Ltd
Priority to CN201610404657.3A priority Critical patent/CN105871917A/en
Publication of CN105871917A publication Critical patent/CN105871917A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/16Implementation or adaptation of Internet protocol [IP], of transmission control protocol [TCP] or of user datagram protocol [UDP]
    • H04L69/163In-band adaptation of TCP data exchange; In-band control procedures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Security & Cryptography (AREA)
  • Small-Scale Networks (AREA)

Abstract

The invention discloses a transmission control protocol TCP connection scheduling method and device. The method comprises the steps that: a new connection is received by a main thread; the connection is scheduled to a worker thread; when the connection is a service connection, the corresponding client connection and a host thread are determined according to the service connection; when the host thread is different from the worker thread, the service connection is scheduled to the host thread, and data is forwarded on the host thread. Thus, when a plurality of connections are received by a proxy server, the two connections keeping the mutual data forwarding are in the same thread, so the locking and unlocking operations in the frequent network input and output process are avoided, and the forwarding efficiency is improved.

Description

Transmission control protocol TCP connects the method and device of scheduling
Technical field
The present invention relates to data interaction field, the method connecting scheduling particularly to transmission control protocol TCP And device.
Background technology
In point-to-point application system, when needing from the other side's reliable communication being in different private network, first taste Burrowing penetrates, if wearing in examination transmission control protocol (Transmission Control Protocol, TCP) Failure thoroughly, then forwarded and counterparting communications by the proxy server being on public network.
Proxy server is multi-threaded architecture, and when receiving multiple connection, a connection writes data to separately One transmit queue connected, and another connection sends according to this from transmit queue reading, then will be to another The transmit queue connected or relief area lock, so due to network input and output (Input frequently Output, IO) and add unblock continually, reduce forward efficiency.
Summary of the invention
The embodiment of the present invention provides a kind of transmission control protocol TCP to connect the method and device of scheduling, it is possible to Avoid the locking of transmit queue or relief area, improve forward efficiency.
Embodiments provide a kind of method that transmission control protocol TCP connects scheduling, including:
Main thread accepts a new connection;
Described connection is dispatched to worker thread by described main thread;
When described be connected as service connect time, according to described service connect determine correspondence client connect and institute State the host thread that client connects;
When the host thread that described client connects is different from described worker thread, described service is connected and adjusts The host thread that degree connects to described client;
The host thread enterprising row data connected described client forward.
Thus, when proxy server receives multiple connection, two companies that data mutually forward can be kept It is connected on same thread, this avoid and network input/output procedure frequently adds solution latching operation, improve Forward efficiency.
Optionally, when the host thread that described client connects is identical with described worker thread, including:
The host thread enterprising row data connected described client forward.
Optionally, the host thread enterprising row data connected described client forward, including:
When described client connects and is not matched, complete between described client connects and be connected with described service Coupling;
The host thread enterprising row data connected described client forward.
Optionally, the host thread enterprising row data connected described client forward, including:
When the mark that described client connects connects the mark coupling of corresponding client's connection with described service, The host thread enterprising row data connected described client forward.
Optionally, when there is multiple worker thread, described connection is dispatched to described work by described main thread Make thread, including:
Described main thread uses rotation therapy, and described connection is dispatched to described worker thread.
Thus, proxy server connects the equilibrium of number in can realizing each worker thread.
The embodiment of the present invention additionally provides a kind of transmission control protocol TCP and connects the device of scheduling, including:
Main thread module, for accepting a new connection;
Scheduler module, for being dispatched to worker thread mould by the described connection that described main thread module accepts Block;
Described worker thread module, is connected as service connection described in dispatching when described scheduler module Time, the host thread that client connects and described client connects determining correspondence is connected according to described service;
Described scheduler module is different from described worker thread for the host thread connected as described client Time, described service is connected and is dispatched to the host thread that described client connects;
Transceiver module, forwards for the host thread enterprising row data connected described client.
Optionally, described scheduler module, it is additionally operable to described worker thread is set to what described client connected Host thread.
Optionally, described transceiver module, it is additionally operable between described client connects and be connected with described service Coupling.
Optionally, described transceiver module, it is additionally operable to determine that the mark that described client connects connects with described service Connect the coupling of the mark of client's connection of correspondence.
Optionally, described scheduler module, it is additionally operable to use rotation therapy, described connection is dispatched to described work Make threading models.
Accompanying drawing explanation
Fig. 1 is the system architecture diagram in the embodiment of the present invention;
Fig. 2 is the flow process of a kind of method that transmission control protocol TCP connects scheduling in the embodiment of the present invention Figure;
Fig. 3 is the flow chart of a kind of proxy server dispatching method in the embodiment of the present invention;
Fig. 4 is the flow chart of a kind of method identifying connection in the embodiment of the present invention;
Fig. 5 is a kind of flow chart servicing the matching process that connection is connected with client in the embodiment of the present invention;
Fig. 6 is the flow process that in the embodiment of the present invention, another kind of service connects the matching process being connected with client Figure;
Fig. 7 is the signal of the device that a kind of transmission control protocol TCP connects scheduling in the embodiment of the present invention Figure.
Detailed description of the invention
Here will illustrate exemplary embodiment in detail, its example represents in the accompanying drawings.Following When description relates to accompanying drawing, unless otherwise indicated, the same numbers in different accompanying drawings represents same or analogous Key element.Embodiment described in following exemplary embodiment does not represent the institute consistent with the present invention There is embodiment.On the contrary, they only with as appended claims describes in detail, the one of the present invention The example of the apparatus and method that a little aspects are consistent.
Fig. 1 is the system architecture diagram in the embodiment of the present invention, and this system architecture includes terminal A, agency's clothes Business device, P2P server and terminal B.Working-flow is as follows:
1, terminal A first connects concurrent message msg1 to proxy server, is connected as c1;
2, proxy server messaging msg2 is to P2P server;
3, by existing connection messaging msg3 to terminal B after P2P server receives message;
4, after B receives msg3, concurrent message msg4 is to proxy server in connection, is connected as c2.
Wherein, these 4 message formats of msg1 to msg4 are determined by application layer protocol, but have to comply with Specification is as follows:
1) msg1 is including at least the device id of terminal B;
2) msg2 includes at least device id and the connection ID of c1 of terminal B;
3) msg3 indicates including at least connection ID and the connection agency of c1;
4) msg4 includes at least device id and the connection ID of c1 of terminal B.
Fig. 2 is the flow process of a kind of method that transmission control protocol TCP connects scheduling in the embodiment of the present invention Figure, the method can apply in the proxy server shown in Fig. 1.
S201, main thread accept a new connection;
Described connection is dispatched to worker thread by S202, described main thread;
S203, when described be connected as service connect time, connect according to described service and determine the client of correspondence even Connect the host thread connected with described client;
S204, when the host thread that described client connects is different from described worker thread, by described service Connect and be dispatched to the host thread that described client connects;
S205, the host thread enterprising row data forwarding connected described client.
Wherein, proxy server is multi-threaded architecture, and main thread is responsible for binding well-known port and monitoring connection, Worker thread is responsible for data and is forwarded.
In S201, the main thread of proxy server accepts a new connection.
In S202, the connection that main thread in S201 accepts is dispatched on worker thread by proxy server. When proxy server is configured for multiple worker thread, optionally, proxy server can will connect at random It is dispatched to certain worker thread, or is scheduling according to preset rules.Further alternative, agency service Device can use rotation therapy to be scheduling, as it is shown on figure 3, worker thread group includes g worker thread altogether, By the way of index i is incremented by, determine the worker thread t this connection being dispatched to.
After connection being dispatched to worker thread in S202, receive in this worker thread and analyze application Layer protocol data, to identify connection type.I.e. determine that this connection is to ring from request of data side or data Ying Fang, wherein, request of data side is that client connects, and data response is put and connected into service, connects place Thread is host thread.
As shown in Figure 4, optionally, connect if this connection is client, then need to notify P2P server Client corresponding to request connects agency, and etc. to be matched.Further alternative, if etc. to be matched Time exceedes the scheduled time, then quote response timeout mistake, and close connection.If this is connected as illegal chain Connect, then quote response request error, and close link.
In S203, optionally, connect if this connection is service, then connect according to this service and determine correspondence Client connect and client connect host thread.
In S204, this service is connected and is dispatched to the host thread that described client connects.Optionally, S204 An optional detailed description of the invention for coupling client connect flow process 1.Concrete, coupling client connects Flow process 1 is as shown in Figure 5.
Wherein, proxy server searches client's connection according to connection ID from client's connection table and client connects The host thread connect, when client's connection does not exists or client is connected as currently connecting, reports corresponding mistake also Close this connection, when client connects not for currently connecting, it is judged that whether host thread is work at present line Journey, even service connect and client connects not in same thread, then will service connection be dispatched to The host thread that client connects, if service connects and client is connected in same thread, then this thread is Host thread.Further, when service connects and client is connected in same thread, it is also possible to enter one Step judge client connection be the most matched, device id mutually the most equal, it is judged that by rear, complete visitor Family connects the coupling being connected with service.
In S205, the host thread enterprising row data that proxy server connects client forward.Optionally, When in S204, when during beginning, client's connection is connected not in same thread with service, owing to service connects Being scheduled in the time interval of host thread, client's connection likely disconnects, it is also possible to be connected to one Other of individual identical ID connects.Therefore, in order to avoid the mistake that these are possible, coupling visitor can be entered Family flow process 2, as shown in Figure 6.
Wherein, proxy server searches client's connection and host's line according to connection ID from client's connection table Journey, when client connect existence, host thread is current thread, client connect be not matched, device id Time identical, client connects and service matching connection success, and proxy server carries out data forwarding.Otherwise, Corresponding error message quoted as the case may be by proxy server.
Fig. 7 is the schematic diagram of the device that transmission control protocol TCP connects scheduling in the embodiment of the present invention, should Device can be used for the method performed as shown in Figures 2 to 6, as follows:
S701 main thread module, for accepting a new connection;
S702 scheduler module, for being dispatched to worker thread by the described connection that described main thread module accepts Module;
Worker thread module described in S703, is connected as service even described in dispatching when described scheduler module When connecing, connect the host thread that client connects and described client connects determining correspondence according to described service;
Scheduler module described in S702, for the host thread that connects as described client with described worker thread not Meanwhile, described service connection is dispatched to the host thread that described client connects;
S704 transceiver module, forwards for the host thread enterprising row data connected described client.
Optionally, when the host thread that described client connects is identical with described worker thread,
S702 scheduler module, is additionally operable to described worker thread is set to host's line that described client connects Journey.
Optionally, S704 transceiver module is additionally operable to, and completes between described client connects and be connected with described service Coupling.
Optionally, S704 transceiver module is additionally operable to, and determines that the mark that described client connects connects with described service Connect the coupling of the mark of client's connection of correspondence.
Optionally, S702 scheduler module is additionally operable to, and uses rotation therapy, described connection is dispatched to described work Make threading models.
Above to technical scheme, it is described in detail, specific case pair used herein Principle and the embodiment of the present invention are set forth, and the explanation of above example is only intended to help to understand The core concept of the present invention;Simultaneously for one of ordinary skill in the art, according to the embodiment of the present invention Thought, the most all will change, in sum, this explanation Book content should not be construed as the restriction to the embodiment of the present invention.

Claims (10)

1. the method that transmission control protocol TCP connects scheduling, including:
Main thread accepts a new connection;
Described connection is dispatched to worker thread by described main thread;
When described be connected as service connect time, according to described service connect determine correspondence client connect and institute State the host thread that client connects;
When the host thread that described client connects is different from described worker thread, described service is connected and adjusts The host thread that degree connects to described client;
The host thread enterprising row data connected described client forward.
2. the method for claim 1, it is characterised in that when host's line that described client connects When journey is identical with described worker thread, including:
The host thread enterprising row data connected described client forward.
3. the method for claim 1, it is characterised in that at host's line that described client connects Cheng Shangjin row data forward, including:
When described client connects and is not matched, complete between described client connects and be connected with described service Coupling;
The host thread enterprising row data connected described client forward.
4. the method for claim 1, it is characterised in that at host's line that described client connects Cheng Shangjin row data forward, including:
When the mark that described client connects connects the mark coupling of corresponding client's connection with described service, The host thread enterprising row data connected described client forward.
5. method as described in arbitrary in Claims 1-4, it is characterised in that when there is multiple work When making thread, described connection is dispatched to described worker thread by described main thread, including:
Described main thread uses rotation therapy, and described connection is dispatched to described worker thread.
6. transmission control protocol TCP connects a device for scheduling, including:
Main thread module, for accepting a new connection;
Scheduler module, for being dispatched to worker thread mould by the described connection that described main thread module accepts Block;
Described worker thread module, is connected as service connection described in dispatching when described scheduler module Time, the host thread that client connects and described client connects determining correspondence is connected according to described service;
Described scheduler module, is additionally operable to connect described service be dispatched to host's line that described client connects Journey;
Transceiver module, forwards for the host thread enterprising row data connected described client.
7. device as claimed in claim 6, it is characterised in that when host's line that described client connects When journey is identical with described worker thread,
Described scheduler module, is additionally operable to described worker thread is set to host's line that described client connects Journey.
8. device as claimed in claim 6, it is characterised in that described transceiver module is additionally operable to:
Complete described client and connect the coupling between being connected with described service.
9. device as claimed in claim 6, it is characterised in that described transceiver module is additionally operable to:
Determine the mark that described client connects connect with described service the mark of corresponding client's connection Join.
10. device as described in arbitrary in claim 6 to 9, it is characterised in that described scheduler module It is additionally operable to:
Use rotation therapy, described connection is dispatched to described worker thread module.
CN201610404657.3A 2016-06-08 2016-06-08 Transmission control protocol TCP connection scheduling method and device Pending CN105871917A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610404657.3A CN105871917A (en) 2016-06-08 2016-06-08 Transmission control protocol TCP connection scheduling method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610404657.3A CN105871917A (en) 2016-06-08 2016-06-08 Transmission control protocol TCP connection scheduling method and device

Publications (1)

Publication Number Publication Date
CN105871917A true CN105871917A (en) 2016-08-17

Family

ID=56676222

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610404657.3A Pending CN105871917A (en) 2016-06-08 2016-06-08 Transmission control protocol TCP connection scheduling method and device

Country Status (1)

Country Link
CN (1) CN105871917A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107517249A (en) * 2017-08-14 2017-12-26 宁波甬凌新材料科技有限公司 A kind of cloud Information Exchange System
CN109672648A (en) * 2017-10-16 2019-04-23 中国科学院信息工程研究所 A kind of TCP link dynamic management approach and equipment

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103197968A (en) * 2013-03-18 2013-07-10 焦点科技股份有限公司 Thread pool processing method and system capable of fusing synchronous and asynchronous features
CN103229143A (en) * 2010-09-28 2013-07-31 施耐德电气美国股份有限公司 Service provider within network service -oriented architecture with extensible and customizable calculation engines
CN103605568A (en) * 2013-10-29 2014-02-26 北京奇虎科技有限公司 Multithread management method and device
CN103927484A (en) * 2014-04-21 2014-07-16 西安电子科技大学宁波信息技术研究院 Malicious program behavior capture method based on Qemu
US20150277946A1 (en) * 2014-03-27 2015-10-01 International Business Machines Corporation Dispatching multiple threads in a computer
WO2015144421A1 (en) * 2014-03-27 2015-10-01 International Business Machines Corporation Start virtual execution instruction for dispatching multiple threads in a computer
CN105306497A (en) * 2014-06-05 2016-02-03 北京畅游天下网络技术有限公司 Method and device for interaction between user interface (UI) and model layer data in application program
CN105630507A (en) * 2015-12-29 2016-06-01 Tcl集团股份有限公司 Method and device for drawing WebView control interface

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103229143A (en) * 2010-09-28 2013-07-31 施耐德电气美国股份有限公司 Service provider within network service -oriented architecture with extensible and customizable calculation engines
CN103197968A (en) * 2013-03-18 2013-07-10 焦点科技股份有限公司 Thread pool processing method and system capable of fusing synchronous and asynchronous features
CN103605568A (en) * 2013-10-29 2014-02-26 北京奇虎科技有限公司 Multithread management method and device
US20150277946A1 (en) * 2014-03-27 2015-10-01 International Business Machines Corporation Dispatching multiple threads in a computer
WO2015144421A1 (en) * 2014-03-27 2015-10-01 International Business Machines Corporation Start virtual execution instruction for dispatching multiple threads in a computer
CN103927484A (en) * 2014-04-21 2014-07-16 西安电子科技大学宁波信息技术研究院 Malicious program behavior capture method based on Qemu
CN105306497A (en) * 2014-06-05 2016-02-03 北京畅游天下网络技术有限公司 Method and device for interaction between user interface (UI) and model layer data in application program
CN105630507A (en) * 2015-12-29 2016-06-01 Tcl集团股份有限公司 Method and device for drawing WebView control interface

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107517249A (en) * 2017-08-14 2017-12-26 宁波甬凌新材料科技有限公司 A kind of cloud Information Exchange System
CN109672648A (en) * 2017-10-16 2019-04-23 中国科学院信息工程研究所 A kind of TCP link dynamic management approach and equipment
CN109672648B (en) * 2017-10-16 2020-05-22 中国科学院信息工程研究所 TCP link dynamic management method and equipment

Similar Documents

Publication Publication Date Title
CN114124685B (en) Method and system for node discovery and self-healing of blockchain networks
CN113347164B (en) Block chain-based distributed consensus system, method, device and storage medium
CN101262501B (en) An inter-core communication method in multi-core system and one multi-core system
CN103890808A (en) Method for operating interactive messaging service providing reception confirmation
CN102957594A (en) Message queue-based message processing method, related device and system
CN102740501B (en) wireless network access point sharing method
RU2011129701A (en) METHOD, SERVER, CLIENT AND SYSTEM FOR INSTANT EXCHANGE OF MESSAGES
CN105871917A (en) Transmission control protocol TCP connection scheduling method and device
CN103684913B (en) Method of testing, physical equipment, terminal and the system of protocol stack
CN101630984B (en) Communication anti-accident exercising system based on knowledge representation and multi-Agent cooperation technology
CN112838935A (en) Electronic data exchange method and system
CN107786308B (en) Data transmission method and terminal device
WO2016074572A1 (en) Service data processing method, device and system
CN113014610B (en) Remote access method, device and system
CN105471718B (en) A kind of implementation method of full duplex message queue
KR20140013892A (en) Method of comparing output in a plurality of information systems
CN103152428A (en) Method for carrying out service communication among nodes on cloud platform
CN101510901B (en) Communication method, communication apparatus and system between distributed equipment
CN106302432A (en) A kind of communicator based on car networking and control method
CN110069564B (en) Information query system and method based on block chain
CN110430075B (en) Method for managing logic configuration of support network controller
CN103546513B (en) The method and device of communication between a kind of customer terminal webpage
CN106817426A (en) A kind of reminding method, data transmission method and equipment
CN114157350A (en) Optical fiber misconnection detection method and system
CN113242292A (en) Message transmission method, device, equipment, medium and product

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20160817