Summary of the invention
The technical problem to be solved in the present invention is, at the above deficiency of C/S model, proposes a kind of dynamically configuration link and connects, and is convenient to code maintenance, can better solve the control information interaction problems between each task on the veneer.
Ethernet communication device between the data processing single board of the present invention comprises:
(1) in whole communicator, plays a part, and write down the configuration information of link, the socket control table (SCBT, Socket cotrol BlockTable) of decision link setup object and mode to the task interactive information.
(2) be used to provide the transmitting-receiving interface of up-downgoing data.
(3) be used for link setup task (ESTT, EStablish Task) module with corresponding veneer link setup.
(4) be used to receive when driving message that the responsible data that will send in the buffering area are shifted transmission task (SNDT, the Send Task) module on the network onto.
(5) be used for reception task (RCVT, the Receive Task) module of receiving network data.
(6) proxy task (AGTT, Agent Task) module.
Wherein, the transmitting-receiving interface is connected with the reception task module, and the Data Receiving task module sends task module with data and links, and data transmission blocks is connected with link setup task module and proxy task module.
Ethernet communication method between the data processing single board said method comprising the steps of:
(1) link setup task (ESTT) is at first created the monitoring socket of service end, unblock receives the connection request of client then, next creates the socket of client, initiatively the opposite end veneer of record sends the unblock connection request in socket control table (SCBT), automatic regular polling then, when poll, the link setup task also will scan socket control table (SCBT), will be by other task flaggings the socket handle of makeing mistakes close, simultaneously in socket control table (SCBT), variables corresponding is set, so that can be again in poll next time and corresponding veneer link setup.
When (2) data that provide when this platform of application call send function (function is called NetCommSend ()) data, pure user data and user profile are united two into one, and copy in the socket control table (SCBT) it to corresponding buffering area that sends, send task (SNDT) to data then and send out message, when data send tasks (SNDT) when receiving message, be responsible for to send the interior data of buffering area and shift network onto and get on.When Data Receiving task (RCVT) or link setup task (ESTT) learn that the socket handle is invalid, to send out message and send task (SNDT) to data, when receiving message, data send task (SNDT) scanning socket control table (SCBT), will be by other task flaggings the socket handle that will close turn off, when application program wish to send the veneer address in socket control table (SCBT) when unregistered, data send task (SNDT) module and will adopt UDP (USer Datagram Protocol, User Datagram Protoco (UDP)) mode that data are sent to network.
(3) Data Receiving task (RCVT) adopts obstruction mode in limited time, it blocks the function in system call Select () (one of socket standard interface function) in limited time at ordinary times, when Select ()) (one of socket standard interface function) when returning the readable condition of socket, to call recv () (one of socket standard interface function) and copy data in the socket control table (SCBT) the corresponding buffering area that receives, if the data that receive have been complete user data package, giving the message distribution module after then unpacking handles, as Selecto (one of socket standard interface function) because during overtime returning, then scan socket control table (SCBT), will be by other task flaggings the socket handle that need close of makeing mistakes turn off.
(4) link setup task (ESTT) sends task (SNDT) and the shared socket handle of Data Receiving task (RCVT) to data after the link setup success.
(5) link setup task (ESTT) is after the link setup request that inserts certain data processing single board (DPB) again, in socket control table (SCBT), variables corresponding need be set, allow data transmission task (SNDT) and Data Receiving task (RCVT) that the socket handle that lost efficacy is closed; After all handles of this socket were all closed, this socket resource discharged automatically.
(6) data transmission task (SNDT) or Data Receiving task (RCVT) are when knowing that some sockets lost efficacy, in scanning socket control table (SCBT), variables corresponding need be set, allow data send task (SNDT) or Data Receiving task (RCVT) and link setup task (ESTT) handle of inefficacy socket is closed.
Utilize real time operating system (RTOS, Real one Time Oprating System) socket canonical function interface that provides and the system call function library of itself, this device has made up a network communication platform, be called NetCOInln Platform, be called for short the NP device, Here it is this ethernet communication device.This ethernet communication device is made up of three parts:
1. socket control table (SCBT, Socket Cotrol Block Table)
In whole module, play a part, and write down the configuration information of link, the object and the mode of decision link setup to the task interactive information;
2. application interface (Interface)
The up-downgoing data transmit-receive interface that provides to application;
3. task (Task)
Be divided into link setup task (ESTT), Data Receiving task (RCVT), data send task (SNDT), and proxy task (AGTT).
Link setup task (ESTT) is described
What link setup task (ESTT) adopted is the unblock polling method.
At first create the monitoring socket of server end, unblock receives the connection request of client then; Next creates the socket of client, and initiatively the opposite end veneer of record sends the unblock connection request in socket control table (SCBT).Then, automatic regular polling.
It is that monoboard programme can be without Differentiated Services device end and client that this module adopts the advantage of C/S shuffling mode, thereby has reduced the complexity of maintenance program.
In poll, link setup task (ESTT) also will scan socket control table (SCBT), will be by other task flaggings the socket handle of makeing mistakes close, simultaneously in socket control table (SCBT), variables corresponding is set, so that can be again in poll next time and corresponding veneer link setup.
Transmission task (SNDT) is described
It is the obstruction mode that data send task (SNDT).
When application program (APP) is called data that this platform provides and is sent functions (function be called NetCommSend ()) transmission data, this function unites two into one pure user data and user profile, and copy in the socket control table (SCBT) it to corresponding buffering area that sends, send tasks (SNDT) to data then and send out and trigger message.When data transmission tasks (SNDT) were received triggering message, the responsible data that will send in the buffering area were shifted network onto and are got on.When reception task (RCVT) or link setup task (ESTT) when learning that socket is invalid, will send out message and send task (SNDT) to data; When receiving message, data send tasks (SNDT) scanning socket control table (SCBT), will be by other task flaggings the socket handle that will close turn off.
When use to wish send the veneer address in socket control table (SCBT) when unregistered, this module will adopt UDP (User Datagram Protocol, User Datagram Protoco (UDP)) mode that data are sent to network.
Reception task (RCVT) is described
Reception task (RCVT) adopts obstruction mode in limited time.It blocks the function in system call select () (one of socket standard interface function) in limited time at ordinary times.As select () (one of socket standard interface function) when returning the readable condition of socket, will call recv () (one of socket standard interface function) and copy data in the socket control table (SCBT) the corresponding buffering area that receives.If the data that receive have been complete user data package, give the message distribution module after then unpacking and handle.
Because during overtime returning, then scan socket control table (SCBT) as select () (one of socket standard interface function), will be by other task flaggings the socket handle that need close of makeing mistakes turn off.
Proxy task (AGTT) is described
The function of proxy task (AGTT) is the agency as the backstage tool software.Its function is: carry out test; Performance monitoring; Finish configuration.
Each task obstruction mode has nothing in common with each other, and between rare contact.They rely on semaphore and socket control table (SCBT) to coordinate mutually.Mainly contain following several situation:
1. link setup task (ESTT) sends task (SNDT) and reception task (RCVT) dispenser sleeve interface handle to data after the link setup success;
2. link setup task (ESTT) is after the link setup request that inserts certain data processing single board (DPB) again, in socket control table (SCBT), variables corresponding need be set, allow data transmission task (SNDT) and reception task (RCVT) that the handle of inefficacy socket is closed; After all handles of this socket were all closed, this socket resource discharged automatically;
3. reception task (RCVT) (or transmission task (SNDT)) is when knowing that some sockets lost efficacy, in socket control table (SCBT), variables corresponding need be set, allow transmission task (SNDT) (or reception task (RCVT)) and link setup task (ESTT) that the handle of inefficacy socket is closed.
This device utilizes real time operating system (RTOS, Real-Time Oprating System) socket (Sockets) and the system call function library that provide, made up a network communication platform (NP, NetCommPlatform), data processing single board (DPB, Data Process Board), just can between data processing single board (DPB), carry out high speed exchanges data reliably with the service that utilizes network communication platform (NP) to provide as long as bound network communication platform (NP) device.
Specific implementation method
As shown in Figure 1, a plurality of data processing single boards (DPB) are linked together by hub (HUB) on physical relation, are the real time operating system (RTOS) of usefulness on the data processing single board (DPB).
Shown in Figure 2 is three parts of this ethernet communication device: socket control table (SCBT, i.e. SCB among the figure), interface (Interface), Task (reception task (RCVT), transmission task (SNDT), link setup task (ESTT), proxy task (AGTT)), and the relation between them, can see among the figure that application program (APP) carries out data interaction by interface (Interface) and opposite end, this is that this installs a most important function.
Shown in Figure 3 is the operational mode of link setup task (ESTT).What link setup task (ESTT) adopted is the unblock polling method.At first create the monitoring socket of server end, unblock receives the connection request (ACCEPT) of client then; Next creates the socket of client, and initiatively the opposite end veneer of record sends unblock connection request (CONNECT) in socket control table (SCBT).(IDLE) poll then, regularly.
The process of transmitting of application data shown in Figure 4.The data transmission interface that using (APP) calling interface (Interface) provides sends data, interface (Interface) module with data-moving to data buffer zone that socket control table (SCBT) provides, trigger transmission task (SNDT) simultaneously, allow it be responsible for the data in socket control table (SCBT) buffering are shifted onto on the network.Data3 is that data send the data that task (SNDT) once sends, and repeatedly sends if Data3 less than Data2, then needs data to send task (SNDT), could all shift data onto network, and this will be activated by timed message.
The receiving course of application data shown in Figure 5.When bottom interrupts detecting data on the network, will activate reception task (RCVT) reception data; Reception task (RCVT) is carried out different disposal for data of different types.Application data bag for UDP (User Datagram Protocol, User Datagram Protoco (UDP)) mode once receives, and submits corresponding APP to by Interface then; For the application data bag of TCP (Transfer Control Protocol, transmission control protocol) mode,, so also be to submit to application (APP) immediately if once can finish receiving; If just can receive several times, will go into socket control table (SCBT) so earlier and receive data buffering, wait for that an application data bag receives fully, just submit to using (APP).
In the distributed real-time system, the exchange mass data is very usual thing between the polylith data processing single board, in the communications field, bandwidth, real-time and the reliability of data exchange is had higher requirement.Still there is not ripe general solution in the market.
Ethernet communication device between the data processing single board that the present invention proposes is to conclude abstract come out according to the example in the actual development process, has stronger transplantability.The present invention has accomplished data processing single board (DPB) as long as bound network communication platform (NP) device, just can carry out high speed exchanges data reliably between data processing single board (DPB) with the service that utilizes network communication platform (NP) to provide.This device has adopted some following new technologies:
C/S shuffling technology;
Socket control table (SCBT) technology;
Configurable TCP (Transfer Control Protocol, transmission control protocol) interconnection technique.
Than traditional C/S device, advantage has: be convenient to code maintenance, and dynamically configuration link connects; Solved the control information interaction problems between each task on the veneer well; Communication module can be according to actual conditions flexible configuration TCP (Transfer Control Protocol, transmission control protocol) link, and need not restart veneer, and new configuration can come into force.