CN100589393C - A method for realizing dual-protocol stack switching based on network card - Google Patents

A method for realizing dual-protocol stack switching based on network card Download PDF

Info

Publication number
CN100589393C
CN100589393C CN200710151461A CN200710151461A CN100589393C CN 100589393 C CN100589393 C CN 100589393C CN 200710151461 A CN200710151461 A CN 200710151461A CN 200710151461 A CN200710151461 A CN 200710151461A CN 100589393 C CN100589393 C CN 100589393C
Authority
CN
China
Prior art keywords
protocol stack
stack
switching
buffering area
network interface
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.)
Expired - Fee Related
Application number
CN200710151461A
Other languages
Chinese (zh)
Other versions
CN101150412A (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.)
ZTE Corp
Original Assignee
ZTE Corp
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 ZTE Corp filed Critical ZTE Corp
Priority to CN200710151461A priority Critical patent/CN100589393C/en
Publication of CN101150412A publication Critical patent/CN101150412A/en
Application granted granted Critical
Publication of CN100589393C publication Critical patent/CN100589393C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

This invention relats to a method for realizing switch of double-protocol stack by a network card including: 1, interruption process means to alter an interrupt function pointer to be connected to theinterrupt process function of a new protocol stack, 2, distribution and releasing of EMS memory is to exchange memory in a buffer region including release of memory of a received buffer region of a protocol stack before switch and application for distribution of memory of the protocol stack after switch and writes the address into a descriptor of the received buffer region, 3, mode of connectionis to judge if the current set-up mode of connection satisfies communication of the switched protocol stack when switching, if so, the current mode is kept, if not, new connection is set up again, thus, only different points in the switch key points are switched in each time of switch.

Description

A kind of network interface card is realized the method that dual stack switches
Technical field
The present invention relates to many network applications of communications field technology, relate more specifically to the method that network interface card realizes that the multiple network protocol stack switches.
Background technology
Popularizing and using more and more widely along with network technology, the protocol stack that certain concrete special application may need to have some specific function is supported, and in the continuous variation and renewal of application demand, the function of network protocol stack also needs ceaselessly modifications and variations.Therefore in a lot of network applications, the for example typically application in the soft switch, because having satisfied versatility, the network protocol stack that operating system carries caused to meet the eye on every side the application that some has specific (special) requirements, and caused and to have made amendment and customize protocol stack because of source code not open, therefore, the network protocol stack that the businessman of exploitation communication software often can not use operating system to carry is developed own web application, but the new protocol stack of oneself exploitation, on the protocol stack of oneself, remove to develop web application, can make network protocol stack provide special service at concrete application like this for the upper strata.But owing to consider the cost problem, the protocol stack of businessman oneself exploitation is often at concrete application, do not have the functions such as debugging, analysis and statistics of integrated application programs and driver, the network protocol stack that need operating system to carry this time is again finished these functions.Therefore under development often the needs used a plurality of network protocol stacks, and the switch speed between the protocol stack has just become problem demanding prompt solution when using a plurality of protocol stack.Because, then can cause the packet loss problem when dual stack switches, occurring, thereby can not satisfy the demand of upper level applications if the speed of switching between two protocol stacks is slow excessively.Address this problem the support that then needs lower floor's network interface card and network interface card to drive.
Network interface card (NIC, Network Interface Card) claims also " network adapter " that it is the hardware device that connects computer and network.No matter be that twisted-pair feeder connects, coaxial cable connects, or optical fiber connects, and all must could realize data communication by network interface card.The groundwork principle of network interface card is the data that mail on the arrangement computer on the netting twine, and data decomposition is sent on network for suitably big or small packet afterwards.Every network interface card all has a unique network node address, is commonly referred to MAC Address (physical address), and it is a network interface card manufacturer when producing among the burned ROM, and guarantees that this address can never repeat.People's network interface card used in everyday all is an ethernet nic.Network interface card can be divided into 10M network interface card, 10/100M adaptive net card and gigabit (1000M) network interface card by its transmission speed at present.If just as general service,, relatively be fit to use two kinds of 10M network interface card and 10/100M adaptive net cards as routine office work etc.If be applied to product scopes such as server, will select the network interface card of gigabit level.
Few at the research of dual stack switching at present, main research concentrates in the research of ipv4/ipv6 dual stack.The process that existing network interface card realization dual stack switches at first is to stop the use that current device drives as shown in Figure 1, be to discharge some resources relevant with the protocol stack of current use then, and restart facility drives to support new protocol stack.The advantage of this handoff procedure is to have versatility, can not make mistakes, and size of code is little.But its topmost shortcoming has started one time after whole network interface card being driven stop exactly again, multi-pass operation the register of network card chip, consuming time very big, cause protocol stack to occur the packet loss phenomenon between transfer period, so can not satisfy the needs of upper layer application.
Summary of the invention
Technical problem to be solved by this invention provides the method that a kind of network interface card realizes that dual stack switches, and supports the quick switching of multi-protocol stack, thereby can avoid occurring data packet loss phenomenon in the protocol stack handoff procedure.
In order to solve the problems of the technologies described above, the invention provides the method that a kind of network interface card realizes that dual stack switches, be applied to the driving of network interface card, this method comprises the steps:
(a) dual stack is switched the reference point that drives with network interface card and be abstracted into the switching emphasis;
When (b) carrying out the dual stack switching, only the difference switching that will switch in the emphasis at dual stack is come.
Further, step (a) switching emphasis comprises: interrupt processing mechanism, Memory Allocation and releasing mechanism and establishment of connection mode; The difference switching that step (b) is switched emphasis comprises:
(b1) articulate the Interrupt Process function of New Deal stack, give the New Deal stack with wrapping of will receiving and handle;
(b2) change reception buffering area internal memory, comprising: the reception buffering area internal memory of former protocol stack is discharged, and be New Deal stack application storage allocation, and New Deal stack memory address is written in the descriptor that receives buffering area;
(b3) carry out the switching of establishment of connection mode according to the needs of New Deal stack.
Further, step (b1) articulates by the Interrupt Process function of interrupt function pointed New Deal stack is finished; Step (b2) is preserved earlier the memory address of the reception buffering area of former protocol stack, and the memory address that will allocate in advance is written in the descriptor that receives buffering area then, waits protocol stack to switch to finish the internal memory of the reception buffering area of the former protocol stack of back release; Step (b3) earlier judges whether current establishment of connection mode satisfies the requirement that the New Deal stack communicates, and is satisfied then keep the mode of current connection foundation; Do not satisfy and then rebulid connection according to demand.
Further, in the preceding step that also comprises of step (b1): be Interrupt Process function definition interrupt function pointer in advance; In the preceding step that also comprises of step (b2): allocate the internal memory that receives buffering area in advance.
Further, the mode of Interrupt Process comprises the interruption delay process or interrupts absolute Timing Processing.
Further, network interface card drives and adopts zero-copy mechanism when being uploaded to protocol stack after receiving bag.
Further, the establishment of connection mode comprises automatic negotiation establishment of connection or forces establishment of connection.
Compared with prior art, because the present invention is in the handoff procedure of dual stack, adopted the mode of only switching two kinds of protocol stack differences, the common place that has kept two kinds of protocol stacks, therefore reduce two kinds of times that protocol stack switches greatly, thereby guaranteed in the protocol stack handoff procedure, can not occur phenomenons such as packet loss and connection interruption.
Description of drawings
Fig. 1 is the flow chart that existing network interface card is realized the dual stack changing method;
Fig. 2 realizes the flow chart of dual stack changing method one embodiment for adopting PCI-Express of the present invention.
Embodiment
The invention provides the method that a kind of network interface card realizes that dual stack switches, its key point is exactly that the reference point that dual stack switches and network interface card drives is abstracted into the switching emphasis, mainly comprise: (1) interrupt processing mechanism, promptly by changing the Interrupt Process function that the interrupt function pointer articulates the New Deal stack; (2) Memory Allocation and releasing mechanism promptly receive the replacing of buffering area internal memory, comprise the release of protocol stack reception buffering area internal memory before switching, and the application of switching back protocol stack Memory Allocation, and its address is written in the descriptor that receives buffering area; (3) establishment of connection mode judges when switching promptly whether current establishment of connection mode satisfies the communication of the protocol stack after switching, and is satisfied then keep current establishment of connection mode; Do not satisfy just and rebulid connection by demand.Like this, each protocol stack does not need to repeat the process that whole driving is re-loaded to protocol stack when switching, and the difference switching that just will switch in the emphasis is come, thereby has reduced the time of switching greatly.And, in the process of switching, can successfully each that receive be wrapped and give the protocol stack processing, thereby avoid occurring data packet loss phenomenon.
Below in conjunction with specific embodiments and the drawings technique scheme of the present invention is described in further detail.
Network interface card of the present invention is realized the method that dual stack switches, and is abstracted into the switching emphasis by dual stack and network interface card are driven reference point, and when protocol stack switches, only switches at the difference of protocol stack with regard to these emphasis, reaches the purpose of quickening switching.
(1) realization of interrupt processing mechanism and Interrupt Process function switching
Because the bag that receives will be uploaded to different protocol stacks, the interface of different protocol processes bags is different certainly, affirms different so interrupt the reprocessing function.It is exactly that handoff is handled function that protocol stack switches the primary problem that solves.
In network card chip controller internal register, the condition that the centering stopping pregnancy is given birth to has multiple set-up mode, and the most frequently used is the compound mode of taking the interruption delay timer and interrupting absolute timer.The implication of interruption delay timer is meant network card chip receives a bag by DMA after, can not produce an interruption immediately, but after postponing a time that pre-defines, if also there is not next bag to arrive, then produce and interrupt, if within the time of definition, received a bag again, then postpone again to produce to interrupt.The implication of interrupting absolute timer is exactly after receiving first bag, even continuously receive bag always, but after the absolute timer time arrival of definition, produces an interruption immediately.By the combination of two kinds of interrupt conditions, avoided whenever receiving that a bag interrupts and causes the not high problem of efficient with regard to producing one, and received bag but give the problem of protocol stack processing on can not be in time.
But different protocol stacks may be different to the flow process that the bag that the network interface card driving is received is handled, and needs to wrap to give different protocol stacks.Here so-called (or articulating) Interrupt Process function that switches, can be function pointer of Interrupt Process function definition in advance, when the handoff protocol stack, the Interrupt Process function of the protocol stack that this interrupt function pointed is new, handoff processing the consuming time of function will be very short like this.
(2) realization of Memory Allocation and releasing mechanism and the switching of reception buffering area internal memory
Because network interface card drives and has adopted zero-copy mechanism when being uploaded to protocol stack after receiving bag, if different protocol stacks is receiving the different Memory Allocation mechanism of bag use, just used mBlk structure pond, clBlk structure pond and a bunch buffering area pool structure to come the reception of tissue pocket and uploaded such as the network protocol stack of vxworks operation oneself, and in the other protocol stack, when receiving it may be oneself Memory Allocation and delivery mode, thereby make when the handoff protocol stack, also will switch again the release that receives internal memory in the buffering area etc.
Here, its basic thought of so-called zero-copy (Zero-Copy) mechanism is: the process that packet transmits from the network equipment to the user program space, avoid the data copy as far as possible.That is be sent to the process of protocol stack from receiving buffering area, transmission be the memory address of packet, rather than the content of packet.
PCI-Express is by the DMA transmission mechanism data to be received the data field from the FIFO of network card chip to be transferred to internal memory, under the control of CPU, the data upload in the internal memory is handled to protocol stack then.So in internal memory, want a pre-defined reception buffering area to read for network interface card DMA, because last when giving protocol stack, adopted zero-copy mechanism, and different protocol stacks may be different to the mode of buffering area Memory Allocation, therefore when the handoff protocol stack, will switch the memory field that receives buffering.
In order to quicken to receive the switching of buffering area internal memory, can take a kind of mechanism that receives the buffering area memory mechanism and postpone to discharge former protocol stack internal memory of allocating in advance, preserve the address, memory field of the reception buffering area of former protocol stack during switching earlier, the address, memory field that directly will allocate in advance then is written to and receives in the buffer descriptor, switch and discharge former protocol stack internal memory again after finishing etc. whole protocol stack, significantly reduced the time that the buffering area internal memory switches that receives like this.
(3) realization of establishment of connection mode and switching connected mode
The mode that various protocol stacks connects may be different, and the protocol stack that has Seeking Truth is possibly consulted to connect automatically, and the Seeking Truth possibly that has is forced to connect, and what also have may be that requirement connects or the like from the EEPROM reading of data.So, should change the mode that connects if desired according to the needs of protocol stack, then the establishment of connection mode also needs to switch.
Intel82546 PCI-Express chip has two kinds of modes that connect, a kind of is to consult automatically to connect, it mainly is the connection speed that detects equity side by chip automatically, thereby communication pattern and Flow Control mode determine that one's own side's connection speed is 10M, 100M or 1000M, communication mode is half-duplex or full duplex, and the mode of Flow Control etc.Another is to force connected mode, and one's own side is arranged to parameter in the prescribed limit with connection speed and communication mode according to own needs pressure in other words, thereby connects according to these parameters.Also having a kind of mode is exactly that mode (for example consulting automatically to connect or the force to connect) parameter that will connect is written among the EEPROM and goes, and determines to set up the connection of which kind of mode by the data of reading EEPROM.Connect owing to the operation that relates to network card chip, consuming time long, whether satisfy the requirement that the protocol stack after switching communicates so when protocol stack switches, at first will judge current connected mode, if satisfy, just do not need to switch connected mode; Otherwise, just rebulid connection according to demand.The optimization here mainly is the connection that acquiescence after the system start-up is set up Automatic Negotiation Mechanism, then when the handoff protocol stack, according to judging whether Automatic Negotiation Mechanism satisfies the protocol stack that current needs switch, determine whether to switch the establishment of connection mode, basically just do not need to rebulid connection like this during the handoff protocol stack, thereby avoided maximum work consuming time, guaranteed to fall sharply switching time, thereby avoided the phenomenon of packet loss.
All things considered, the emphasis that need switch when protocol stack switches are just aspect above-mentioned three.Wherein the switching of (1) and (2) mainly is the certain operations at internal memory, and little with the operative relationship of chip hardware, the time of consumption is considerably less, and the consumption of time mainly spends on (3), promptly connects the switching of setting up mode.And do not need to change the establishment of connection mode for most of protocol stacks switchings.Therefore, if can be when protocol stack switches, according to judging that communication that current connected mode satisfies the protocol stack after switching whether, determines whether to rebulid connection.Like this, just can avoid rebuliding connection as much as possible basically during the handoff protocol stack, evade maximum work consuming time thus, thereby reduce two kinds of times that protocol stack switches greatly.
Fig. 2 has represented the flow chart of the method that present embodiment PCI-Express realization dual stack switches, this flow process realizes that with PCI-Express dual stack switches to example, it is not to be used to illustrate that the present invention only limits to this, and just comes sake of clarity technical scheme of the present invention as example.This flow process may further comprise the steps:
201: close and interrupt;
202: change and receive the buffering area internal memory, comprise that mainly protocol stack receives the release of buffering area internal memory and the application of switching back protocol stack Memory Allocation before switching, and its address is written in the descriptor that receives buffering area;
203: articulate the Interrupt Process function of New Deal stack, main by this Interrupt Process function of interrupt function pointed is implemented;
204: open interruption;
205: judge that whether the current mode that connects satisfies the requirement of New Deal stack, promptly needs to change the mode that connects? if then execution in step 206; Then finish switching flow if not;
206: set up new connected mode, process ends according to the demand of New Deal stack.
In sum, adopt the inventive method, be applied to network interface card and drive the quick switching of supporting dual stack, by being switched the reference point that drives with network interface card, two kinds of protocol stacks are abstracted into the switching emphasis, making only needs to switch different place in this switching emphasis when dual stack switches, and do not need whole driving to reload one time, thus reached the purpose of the two agreement of minimizing switching time, make that according to different needs different bags being sent to different protocol stacks is processed into for reality.
Certainly; the present invention also can have other various embodiments; under the situation that does not deviate from spirit of the present invention and essence thereof; being familiar with those of ordinary skill in the art ought can make various corresponding changes and distortion according to the present invention, but these corresponding changes and distortion all should belong to the protection range of the appended claim of the present invention.
For example, the present invention is equally applicable to the driving of other network interface card product, and the present invention also is applicable to the switching between the various protocols stack.

Claims (6)

1, a kind of network interface card is realized the method that dual stack switches, and is applied to the driving of described network interface card, and described method comprises the steps:
(a) described dual stack is switched the reference point that drives with described network interface card and be abstracted into the switching emphasis, described switching emphasis comprises: interrupt processing mechanism, Memory Allocation and releasing mechanism and establishment of connection mode;
(b) carry out described dual stack when switching, do not need to repeat the process that whole driving is re-loaded to protocol stack, only at described dual stack the difference in the described switching emphasis is switched and come, described dual stack switches the described step of coming with the difference in the described switching emphasis and comprises:
(b1) articulate the Interrupt Process function of New Deal stack, give described New Deal stack with wrapping of will receiving and handle;
(b2) change reception buffering area internal memory, comprising: the reception buffering area internal memory of former protocol stack is discharged, and be described New Deal stack application storage allocation, and described New Deal stack memory address is written in the descriptor that receives buffering area;
(b3) carry out the switching of described establishment of connection mode according to the needs of described New Deal stack.
2, in accordance with the method for claim 1, it is characterized in that step (b1) is described to be articulated by the Interrupt Process function of the described New Deal stack of interrupt function pointed is finished; Step (b2) is preserved the memory address of the reception buffering area of described former protocol stack earlier, the memory address that to allocate in advance is written in the descriptor of described reception buffering area then, waits described protocol stack to switch to finish the internal memory of the described reception buffering area of the described former protocol stack of back release; Step (b3) earlier judges whether current establishment of connection mode satisfies the requirement that described New Deal stack communicates, and is satisfied then keep the mode of described current connection foundation; Do not satisfy and then rebulid connection according to demand.
3, in accordance with the method for claim 2, it is characterized in that, in the preceding step that also comprises of step (b1): be the described interrupt function pointer of described Interrupt Process function definition in advance; In the preceding step that also comprises of step (b2): allocate the described internal memory that receives buffering area in advance.
4, in accordance with the method for claim 1, it is characterized in that the mode of described Interrupt Process comprises interrupts delay process or interrupt absolute Timing Processing.
5, in accordance with the method for claim 1, it is characterized in that described network interface card drives and adopts zero-copy mechanism when being uploaded to described protocol stack after receiving bag.
6, in accordance with the method for claim 1, it is characterized in that described establishment of connection mode comprises: consult establishment of connection automatically or force establishment of connection.
CN200710151461A 2007-10-18 2007-10-18 A method for realizing dual-protocol stack switching based on network card Expired - Fee Related CN100589393C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN200710151461A CN100589393C (en) 2007-10-18 2007-10-18 A method for realizing dual-protocol stack switching based on network card

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN200710151461A CN100589393C (en) 2007-10-18 2007-10-18 A method for realizing dual-protocol stack switching based on network card

Publications (2)

Publication Number Publication Date
CN101150412A CN101150412A (en) 2008-03-26
CN100589393C true CN100589393C (en) 2010-02-10

Family

ID=39250765

Family Applications (1)

Application Number Title Priority Date Filing Date
CN200710151461A Expired - Fee Related CN100589393C (en) 2007-10-18 2007-10-18 A method for realizing dual-protocol stack switching based on network card

Country Status (1)

Country Link
CN (1) CN100589393C (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI703835B (en) * 2019-01-25 2020-09-01 中華電信股份有限公司 System and method for provisioning and monitoring virtual machine virtual network interface controller

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101640665B (en) * 2008-07-28 2012-08-22 联想(北京)有限公司 Computer and method for realizing remote wake-up on network card
CN102215148B (en) * 2010-04-09 2014-12-17 瑞昱半导体股份有限公司 Network device with automatic negotiation mechanism and related method thereof
CN105763336B (en) * 2016-02-04 2019-04-09 天津市英贝特航天科技有限公司 The multiple network protocol switching method and switching device of single network interface card
CN107438070B (en) * 2017-07-28 2020-12-04 上海联影医疗科技股份有限公司 Protocol configuration method and device
CN110391999B (en) * 2018-04-18 2022-12-16 海能达通信股份有限公司 Data communication method and system
CN110891073B (en) * 2019-12-30 2021-06-25 西安电子科技大学 Multi-protocol stack communication method for mobile communication core network

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI703835B (en) * 2019-01-25 2020-09-01 中華電信股份有限公司 System and method for provisioning and monitoring virtual machine virtual network interface controller

Also Published As

Publication number Publication date
CN101150412A (en) 2008-03-26

Similar Documents

Publication Publication Date Title
CN100589393C (en) A method for realizing dual-protocol stack switching based on network card
CN101114867B (en) Multi-channel synchronization transmitting method and system
CN102014067B (en) Message fragment sending method, device and network equipment
EP1841162A2 (en) Method and system for an OS virtualization-aware network interface card
CN102571996A (en) IP (Internet Protocol) address assignment method, IP address assignment device and network system
CN106034084A (en) Data transmission method and apparatus thereof
CN102273179A (en) Method and device for terminal batch upgrading
CN101046786A (en) DMA controller and transmission method of implementing high efficient DMA transmission
CN112769905B (en) NUMA (non uniform memory access) architecture based high-performance network card performance optimization method under Feiteng platform
WO2013056671A1 (en) Single-card multi-standby terminal, adapter module, and sim card access method
CN101452430B (en) Communication method between multi-processors and communication device comprising multi-processors
CN102185770A (en) Multi-core-architecture-based batch message transmitting and receiving method
CN101052031B (en) Data interaction method for Apple computer and radio communication terminal
CN102065568A (en) Data descriptor-based medium access control (MAC) software and hardware interaction method and hardware realization device
JP2009118482A (en) Link duplexing apparatus and method for mobile communication system
CN108959136A (en) Data delivery acceleration device, system and data transmission method based on SPI
US7107345B2 (en) Method for managing socket in mobile communication system
CN101938297A (en) Data transmission method of Bluetooth link and Bluetooth master device
CN104486187B (en) A kind of CAN communication device and method of dynamic synchronization
CN106375240B (en) Ethernet message forwarding method and system between a kind of Multi-netmouth
CN102497318A (en) System and method for achieving promiscuous port type network card
JP2010251854A (en) Communication system, terminal, program, and communication method
EP2017740B1 (en) Method for data transfer between host and device
CN112351089B (en) Data transmission method, system and device between virtual machine and accelerator
CN104793896A (en) Single-control and double-control switching method and device of double-control equipment

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20100210

Termination date: 20171018