Summary of the invention
The embodiment of the present invention provides the acquisition methods and communication equipment of a kind of network protocol IP address, is able to solve existing skill
There are switching the slow-footed of IP address caused by blocking operation to ask when carrying out IP address release due to API Function in art
Topic.
In order to achieve the above objectives, the present invention adopts the following technical scheme:
In a first aspect, providing a kind of acquisition methods of network protocol IP address, comprising:
Communication equipment controls the physical network card and moves when determining that physical network card needs to switch the first current IP address
Connection breaking in state host configuration Dynamic Host Configuration Protocol server;
The communication equipment controls the physical network card and connect with the Dynamic Host Configuration Protocol server, with trigger the physical network card and
The Dynamic Host Configuration Protocol server carry out DHCP message interaction obtain the physical network card it is to be switched after the second IP address.
With reference to first aspect, in the first mode in the cards of first aspect, described in the communication equipment control
Connection breaking in physical network card and dynamic host configuration protocol DHCP server, controls the physical network card and the Dynamic Host Configuration Protocol server
Connection includes:
The application layer of the communication equipment control operating system sends message to the driving layer of the operating system, described to disappear
Breath includes the Adapter Name and instruction information of the physical network card, and the instruction information includes being used to indicate the physical network card and institute
The first information of connection breaking in Dynamic Host Configuration Protocol server is stated, and is used to indicate what the physical network card was connect with the Dynamic Host Configuration Protocol server
Second information;
The communication equipment controls the driving layer and obtains Adapter Name and the instruction information in the message, and according to
The first information in the Adapter Name and the instruction information controls connection breaking in the physical network card and the Dynamic Host Configuration Protocol server;
The communication equipment controls the driving layer according to the second information control in the Adapter Name and the instruction information
The physical network card is made to connect with the Dynamic Host Configuration Protocol server.
The possible implementation of with reference to first aspect the first, in second of mode in the cards of first aspect
In, the Adapter Name of the physical network card and the instruction information are indicated in a manner of I/O control code.
The possible implementation of second with reference to first aspect, in the third mode in the cards of first aspect
In, the communication equipment controls Adapter Name and the instruction information for driving layer to obtain in the message, and according to described
The first information in Adapter Name and the instruction information controls connection breaking in the physical network card and the Dynamic Host Configuration Protocol server, according to
The second information in the Adapter Name and the instruction information, which controls the physical network card and connect with the Dynamic Host Configuration Protocol server, includes:
The communication equipment controls the Adapter Name that the driving layer obtains the physical network card according to the I/O control code,
And driving filtering module corresponding with the Adapter Name is determined according to the Adapter Name;
The communication equipment is by the driving filtering module according to the Adapter Name and the first information by the object
The attribute of reason network interface card is set as connection breaking, so that connection breaking in the physical network card and the Dynamic Host Configuration Protocol server;
The communication equipment is by the driving filtering module according to the Adapter Name and second information by the object
The attribute of reason network interface card is set as connecting, so that the physical network card is connect with the Dynamic Host Configuration Protocol server.
Any one into the third possible implementation of first aspect with reference to first aspect, in first aspect
In 4th kind of mode in the cards, the communication equipment triggers the physical network card and the Dynamic Host Configuration Protocol server carries out DHCP report
Text interaction obtain the physical network card it is to be switched after the second IP address include:
The communication equipment triggers the physical network card and sends DHCP request message to the Dynamic Host Configuration Protocol server;
The communication equipment receives the dhcp response message that the Dynamic Host Configuration Protocol server is sent by the physical network card, described
Dhcp response message include the Dynamic Host Configuration Protocol server be the physical network card distribution it is to be switched after second IP address.
Second aspect provides a kind of communication equipment, comprising:
Determination unit, for determining whether the physical network card of the communication equipment needs to switch the first current IP address;
Control unit is to control the physical network card when being and dynamic is main for the definitive result in the determination unit
Connection breaking in machine configuration protocol DHCP server, and control the physical network card and connect with the Dynamic Host Configuration Protocol server, to trigger
State physical network card and the Dynamic Host Configuration Protocol server carry out DHCP message interact the acquisition physical network card it is to be switched after the 2nd IP
Address.
In conjunction with second aspect, in the first mode in the cards of second aspect, described control unit is specifically used for:
The application layer for controlling the operating system of the communication equipment sends message to the driving layer of the operating system, described
Message include the physical network card Adapter Name and instruction information, the instruction information include be used to indicate the physical network card and
The first information of connection breaking in the Dynamic Host Configuration Protocol server, and be used to indicate the physical network card and connect with the Dynamic Host Configuration Protocol server
The second information;
Adapter Name and the instruction information for driving layer to obtain in the message is controlled, and single according to acquisition
The first information in Adapter Name and the instruction information that member obtains controls the physical network card and the Dynamic Host Configuration Protocol server interrupts
Connection, and the physical network card and the DHCP service are controlled according to the second information in the Adapter Name and the instruction information
Device connection.
In conjunction with the first possible implementation of second aspect, in second of mode in the cards of second aspect
In, the Adapter Name of the physical network card and the instruction information are indicated in a manner of I/O control code.
In conjunction with second of possible implementation of second aspect, in the third mode in the cards of second aspect
In, described control unit is specifically used for:
The Adapter Name that the driving layer obtains the physical network card according to the I/O control code is controlled, and according to the net
Card name determines driving filtering module corresponding with the Adapter Name;
By the driving filtering module according to the Adapter Name and the first information by the attribute of the physical network card
It is set as connection breaking, so that connection breaking in the physical network card and the Dynamic Host Configuration Protocol server;
By the driving filtering module according to the Adapter Name and second information by the attribute of the physical network card
It is set as connecting, so that the physical network card is connect with the Dynamic Host Configuration Protocol server.
In conjunction with second aspect to second aspect the third possible implementation in any one, in second aspect
In 4th kind of mode in the cards, described control unit is also used to:
It triggers the physical network card and sends DHCP request message to the Dynamic Host Configuration Protocol server;
The dhcp response message that the Dynamic Host Configuration Protocol server is sent, the dhcp response message are received by the physical network card
Including the Dynamic Host Configuration Protocol server be the physical network card distribution it is to be switched after second IP address.
The third aspect provides a kind of communication system, and the communication system includes dynamic host configuration protocol DHCP server,
It further include the communication equipment as described in claim 6~10.
The embodiment of the present invention provides the acquisition methods and communication equipment of a kind of network protocol IP address, when physical network card needs
When switching the first current IP address, connection breaking in control physical network card and dynamic host configuration protocol DHCP server, then
Control physical network card is connect with Dynamic Host Configuration Protocol server, interacts acquisition object to trigger physical network card with Dynamic Host Configuration Protocol server progress DHCP message
The second IP address after reason network interface card is to be switched.Wherein, by connection breaking in physical network card and Dynamic Host Configuration Protocol server, Physical Network can be prevented
Block the DHCP message that release IP address is sent to Dynamic Host Configuration Protocol server, then after physical network card is connect with Dynamic Host Configuration Protocol server, Ke Yili
The operation of application IP address is carried out, so as to the second IP address after quick obtaining to switching, thus can be to avoid existing
There are switching caused by blocking operation, IP address is slow-footed to be asked when carrying out IP address release due to API Function in technology
Topic.
Specific embodiment
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention carries out clear, complete
Site preparation description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.It is based on
Embodiment in the present invention, it is obtained by those of ordinary skill in the art without making creative efforts every other
Embodiment shall fall within the protection scope of the present invention.
Microsoft Windows (Microsoft's Window) is a kind of desktop operating system of Microsoft's production and research and development, i.e.,
Windows operating system, it is the computer software system for managing and controlling computer (Personal Computer, PC) resource
System or collection of programs.Windows operating system is the interface of user and computer, while being also computer hardware and other software
Interface, be responsible for computer whole softwares, hardware resource management, control and coordinate concurrent activities, realize the storage of information
And protection.
Windows operating system can be divided into application layer and inner nuclear layer.Wherein, application layer includes being provided for user using clothes
The application program Application or application software of business, it can be interacted with user, generally have visual user circle
Face.Inner nuclear layer is operating system meat and potatoes, is that one had secure access to computer hardware is provided for application program
Partial software is responsible for process, memory, device driver, file and the network system of management system, decides the performance of system
And stability.
Driving layer is located in inner nuclear layer, is the driver that in inner nuclear layer computer and equipment can communicate, is equivalent to
The interface of hardware, operating system only pass through this interface, just can control hardware device normal work.
Filter drive program is one of driving layer driver, and filter drive program, which can be modified, has driving journey
Sequence can also be filtered encryption etc. to data.Different according to driver role, driving layer can also include function
Driving etc..
There are two types of different operational modes for the computer processor of operation Windows operating system: user mode and kernel mould
Formula.The application program of application layer is run under the user mode of Windows operating system, and most drivers in inner nuclear layer exist
It is run under kernel mode, wherein application program is by calling application layer programming interface api function and operating system interaction, operation
System provides corresponding system resource for application program.
Physical network card is the network interface board for connecting computer communication with the outside world network, also known as communication adapter or network
Adapter (Network Adapter) or network interface card (Network Interface Card, NIC).
Communication equipment such as computer generally accesses network, in typical network environment, Radius by access device
Server is responsible for the certification of communication equipment, wherein being configured with related access rules, DHCP is responsible for distributing network ip address, interchanger
It is responsible for the switching of broadcast domain and the execution of access rules, one of network segment is generally a broadcast domain.For example, communication equipment can
To send Radius message to Radius server to be authenticated, Radius server checks that the user information of communication equipment is
No legal, if user information is legal, Radius server issues related access rules to interchanger, and communication equipment is notified to recognize
It demonstrate,proves successfully, the communication equipment is switched to the network segment of configured in advance in related access rules by interchanger at this time.Net after handover
Duan Zhong, Dynamic Host Configuration Protocol server can distribute IP address for the communication equipment.Dynamic Host Configuration Protocol server can be an individual server and set
It is standby, it can also be used as a component and be integrated in other network equipments.Communication equipment can pass through dhcp relay agent server
DHCP Agent or DHCP Proxy are connected with Dynamic Host Configuration Protocol server, wherein the communication of the relative program of operation dhcp relay agent is set
It is standby to can be described as dhcp relay agent server.Dhcp relay agent server be responsible for transfer communication equipment and Dynamic Host Configuration Protocol server it
Between interactive information, such as DHCP message.
Virtual LAN (Virtual Local Area Network, VLAN) is one group of equipment and user in logic,
These equipment and user are not limited by physical location, can be divided according to management function.In shared network, an object
The network segment of reason is exactly a broadcast domain, and in exchange network, broadcast domain can be one group of second arbitrarily selected layer network
The VLAN network segment of address composition.VLAN network segment can limit broadcasting area, form virtual workgroup, can be also used for control network
Mutual access between middle difference department, different websites, so as to dynamically manage network.
The embodiment of the present invention provides a kind of acquisition methods of network protocol IP address, referring to fig. 2, comprising:
201, communication equipment controls physical network card and moves when determining that physical network card needs switch the first current IP address
Connection breaking in state host configuration Dynamic Host Configuration Protocol server.
202, communication equipment control physical network card connect with Dynamic Host Configuration Protocol server, with trigger physical network card and Dynamic Host Configuration Protocol server into
Row DHCP message interaction obtain physical network card it is to be switched after the second IP address.
The embodiment of the present invention provides a kind of acquisition methods of network protocol IP address, when physical network card needs to switch currently
When the first IP address, connection breaking in control physical network card and dynamic host configuration protocol DHCP server then controls Physical Network
Card connect with Dynamic Host Configuration Protocol server, and to trigger physical network card and Dynamic Host Configuration Protocol server progress DHCP message, to interact acquisition physical network card to be cut
The second IP address after changing.Wherein, by connection breaking in physical network card and Dynamic Host Configuration Protocol server, physical network card can be prevented to take to DHCP
Device of being engaged in sends the DHCP message of release IP address, then after physical network card is connect with Dynamic Host Configuration Protocol server, can be applied immediately
The operation of IP address, so as to quick obtaining to switching after the second IP address, thus can to avoid in the prior art due to
There are switch the slow-footed problem of IP address caused by blocking operation when API Function progress IP address release.
The embodiment of the present invention provides the acquisition methods of another network protocol IP address, and referring to Fig. 3, key step can be with
Include:
301, communication equipment controls answering for operating system when determining that physical network card needs to switch the first current IP address
Message is sent to the driving layer of operating system with layer, message includes the Adapter Name and instruction information of physical network card, indicates packet
The first information for being used to indicate connection breaking in physical network card and Dynamic Host Configuration Protocol server is included, and is used to indicate physical network card and DHCP clothes
Second information of business device connection.
302, communication equipment control driving layer obtains Adapter Name and instruction information in message, and according to Adapter Name and instruction
Connection breaking in first information control physical network card and Dynamic Host Configuration Protocol server in information.
303, communication equipment control driving layer according to Adapter Name and instruction information in the second information control physical network card with
Dynamic Host Configuration Protocol server connection, with trigger physical network card and Dynamic Host Configuration Protocol server carry out DHCP message interact acquisition physical network card it is to be switched after
The second IP address.
Wherein, communication equipment here can be the network communication equipments such as computer, the physical network card work in communication equipment
Make to be the interface of connection communication equipment and transmission medium in network, may be implemented between network transmission mediums in link layer
Physical connection and electric signal match, and can have multiple physical network cards on a communication equipment, Adapter Name and physical network card are one by one
It is corresponding.IP address is a kind of logical address for unified format that IP agreement provides, and Dynamic Host Configuration Protocol server can be to communicate in network
Each physical network card of equipment dynamically distributes an IP address, so that the communication equipment where the physical network card is connected to net
Network realizes the communication with network.
It should be noted that Dynamic Host Configuration Protocol server here is not limited to individual server apparatus, also can integrate in
On other network equipments, such as can be integrated on switches by Dynamic Host Configuration Protocol server, the embodiment of the present invention is without limitation.
In order to meet the different application demand in communication process, for example, in order to meet the service of application program in application layer
Demand, communication equipment may need to switch over the first IP address that a certain physical network card currently distributes.Illustratively, if it is logical
Letter equipment one is connected by interchanger with Dynamic Host Configuration Protocol server, while being connected by interchanger with Radius server, and Radius
Server configured in advance has following related access rules: assuming that there are VLAN broadcast domain B, corresponding Dynamic Host Configuration Protocol server one is only
The IP address in communication equipment distribution B network segment in VLAN broadcast domain B;Similarly, it is assumed that there are VLAN broadcast domain A, it is corresponding
Dynamic Host Configuration Protocol server two is only the IP address of the communication equipment distribution A network segment in VLAN broadcast domain A.If certain on communication equipment one
It is in A network segment before the certification of one physical network card, when communication equipment one needs to access the resource of B network segment, communication equipment one needs first
Authentication request message is sent to Radius server by interchanger, Radius server receives the authentication request message
Afterwards, whether the user information in query information library is legal, if user information is legal, authenticates to interchanger transmission one and successfully disappears
Breath, with trigger interchanger according to the related access rules of Radius server configured in advance by communication equipment one by current VLAN
Broadcast domain A is switched to VLAN broadcast domain B, i.e., is switched to B network segment by A network segment, and the certification success message is transmitted to communication and is set
Standby one, to notify communication equipment one to send DHCP request, the IP address of B network segment is obtained to Dynamic Host Configuration Protocol server application, to visit
Ask the resource of B network segment.
Wherein, since Windows operating system is message based operating system, and operating system executes the process of program
It is to be performed simultaneously by multithreading to realize, multithreading handles the process performance that program can be improved simultaneously, and Windows is grasped
Make in system to carry out information exchange by message between thread and thread, then inside the application layer in Windows operating system, drives
It inside dynamic layer and is to guarantee to work normally by transmitting message between application layer and driving layer.Thus, in communication equipment
After one receives the certification success message of Radius server transmission, respective thread in application program can to the certification at
Function message carries out Message Processing, and the instruction of the switching IP address obtained after processing is passed to other threads, in order to other
Thread switches over the operation of IP address.
Optionally, after the thread in application program obtains the instruction of above-mentioned switching IP address, in step 301, Physical Network
The Adapter Name and instruction information of card can be indicated in a manner of I/O control code;Wherein, instruction information includes being used to indicate Physical Network
The first information of card and connection breaking in Dynamic Host Configuration Protocol server, and it is used to indicate the second letter that physical network card is connect with Dynamic Host Configuration Protocol server
Breath.
That is, the application layer of communication equipment one can send object to driving layer by way of sending I/O control code
Manage the Adapter Name and instruction information of network interface card.Here I/O control code, that is, Ioctl control code, sending Ioctl control code is application layer
With driving layer between a kind of communication mode, by macro middle definition device type, function code, buffering method, access right etc.
An Ioctl control code can be created, different Ioctl function can be distinguished by function code different in Ioctl control code
Energy function, to provide different functions.Ioctl power function be in driver in communication equipment connect user mode and
The function that the channel I/O of kernel mode is managed.
Specifically, application program can be primary after the thread in application program receives the instruction of switching IP address
Two I/O control codes are sent to the driving layer of operating system in transmission process, and network interface card is respectively set in two I/O control codes
Name and instruction information.Wherein, the first I/O control code includes the Adapter Name and the first information of the physical network card of to be switched IP address,
The first information is used to indicate connection breaking in physical network card and Dynamic Host Configuration Protocol server one;2nd I/O control code includes to be switched IP address
Physical network card Adapter Name and the second information, the second information is used to indicate physical network card and connect with Dynamic Host Configuration Protocol server one.
Further, after application layer sends message to driving layer, in step 302, communication equipment control driving layer root
The Adapter Name of physical network card is obtained according to I/O control code, and driving filtering module corresponding with Adapter Name is determined according to Adapter Name, and
Communication equipment sets connection breaking for the attribute of physical network card according to Adapter Name and the first information by driving filtering module afterwards, with
Make connection breaking in physical network card and Dynamic Host Configuration Protocol server.
Specifically, driving layer obtains I/O after the application layer of communication equipment one sends two I/O control codes to driving layer
The Adapter Name of the physical network card of to be switched IP address in control code, and corresponding driving filtering module is determined according to Adapter Name.Its
In, the information resources rule of corresponding network interface card may be implemented on driver in driving filtering module carry corresponding with Adapter Name
Draw the functions such as (Information Resource Planning, IRP) interception, Function Extension, data encryption.
When communication equipment one does not need to carry out IP address switching, physical network card is in open state when working normally,
The attribute of physical network card is connection, and physical network card transmission medium connection connected to the network, i.e. network interface card Link State Attribute are
Connection, physical network card is connect with Dynamic Host Configuration Protocol server one at this time.In IP address switching, drove corresponding with Adapter Name is being determined
It, can be according to representing the first information of connection breaking in the first I/O control code for the attribute of physical network card by normal work after filtering module
Connection when making is set as connection breaking, then physical network card is in close state, and no longer provides corresponding connection for communication equipment one
Function, and physical network card transmission medium connected to the network disconnects, i.e., connection when network interface card Link State Attribute is by working normally
Become connection breaking, at this time connection breaking in the Dynamic Host Configuration Protocol server one in physical network card and network, thus blocked communication equipment one to
Dynamic Host Configuration Protocol server one sends message, because without carrying out DHCP when IP address release by api function in the prior art
Message interaction process.
It further, in step 303, can be with after the attribute of physical network card is set connection breaking by communication equipment
According to Adapter Name and the second information the attribute of physical network card is set as connecting by driving filtering module so that physical network card with
Dynamic Host Configuration Protocol server connection carries out DHCP message to interact acquisition physical network card to be switched to trigger physical network card and Dynamic Host Configuration Protocol server one
The second IP address afterwards.
Specifically, communication equipment one by driving filtering module according to the first information in Adapter Name and instruction information by object
It, can be according to the second information for representing connection in the 2nd I/O control code, by Physical Network after the attribute of reason network interface card is set as connection breaking
The attribute of card is re-set as connecting by the connection breaking being arranged before, then physical network card is in the open state, can be set for communication
Standby one provides corresponding linkage function, and physical network card transmission medium connected to the network is in connected state, i.e. network interface card link
Status attribute also is become connecting again from the connection breaking being arranged before, and the Dynamic Host Configuration Protocol server one in physical network card and network connects at this time
It connects.Wherein, physical network card transmission medium connected to the network is connected to, and physical network card is opened, physics can be triggered immediately
Network interface card obtain the operation of IP address, it can the physical network card and Dynamic Host Configuration Protocol server one for triggering communication equipment one immediately carry out
The second IP address after DHCP message interaction acquisition physical network card is to be switched.
The prior art is compared, in the prior art from DHCP Release message the first IP address of release is sent, to transmission
DHCP Discover message is to initially enter between application IP address process, due to needing to wait 12s left there are blocking operation
The right side, thus at least needed from starting to switch over the first IP address to the entire switching flow for getting the second new IP address
The time of 12s.In embodiments of the present invention, it is set as connection breaking from by the attribute of physical network card, to by the attribute of physical network card
It is set as connecting, so that sending DHCP Request start of heading enters application IP address process, centre almost can not prolong
When (shake also the delay that 500ms can be set in order to prevent), and it is new to getting from starting to switch over the first IP address
The entire switching flow of second IP address probably needs the time of 5s~6s, is no more than 10s under normal circumstances.As it can be seen that switching
During IP address, the acquisition speed of the method provided in an embodiment of the present invention for obtaining IP address than in the prior art is fast, obtains
It takes the required time short, the suspension time as caused by switching IP address of communication equipment one can be made short, to improve use
The service performance at family.As it can be seen that the method provided in an embodiment of the present invention for obtaining IP address, it can be to avoid in the prior art due to adjusting
There are the slow-footed problems that IP address is obtained caused by blocking operation when carrying out IP address release with api function.
Optionally, in the above process, physical network card carries out DHCP message with Dynamic Host Configuration Protocol server and interacts acquisition physical network card
The second IP address after to be switched may include: that communication equipment triggers physical network card to Dynamic Host Configuration Protocol server transmission DHCP request report
Text, then communication equipment receives the dhcp response message that Dynamic Host Configuration Protocol server is sent by physical network card, wherein dhcp response message
Including Dynamic Host Configuration Protocol server be physical network card distribution it is to be switched after the second IP address.
Specifically, physical network card sends DHCP request message to Dynamic Host Configuration Protocol server one, and receive the transmission of Dynamic Host Configuration Protocol server one
Dhcp response message, i.e., physical network card by with Dynamic Host Configuration Protocol server one carry out DHCP message interact, apply for new IP address.Its
In, it include processor and memory inside physical network card, DHCP message can be assembled framing by the physical network card of communication equipment one
The Dynamic Host Configuration Protocol server one being sent in network, one physical network card of physical network card receiving communication device in Dynamic Host Configuration Protocol server one are sent
Frame, and DHCP message that Dynamic Host Configuration Protocol server one returns assembling framing is sent to communication equipment one.
Illustratively, it if the first IP address in one original VLAN segment A of communication equipment is 192.168.3.254, and to cut
The second IP address being changed in VLAN network segment B, and according to the configuration rule of Radius server, VLAN is distributed to communication equipment one
IP address in network segment B is Dynamic Host Configuration Protocol server one in VLAN network segment B, then referring to fig. 4, apply when IP address physical network card with
The message interaction process of Dynamic Host Configuration Protocol server one may comprise steps of:
1) communication equipment one sends the first DHCP Request message to Dynamic Host Configuration Protocol server one;
2) communication equipment one receives the DHCP NAK response message that Dynamic Host Configuration Protocol server one is sent;
3) communication equipment one sends DHCP Discover message to Dynamic Host Configuration Protocol server one;
4) communication equipment one receives the DHCP Offer response message that Dynamic Host Configuration Protocol server one is sent;
5) communication equipment one sends the 2nd DHCP Request message to Dynamic Host Configuration Protocol server one;
6) communication equipment one receives the first DHCP acknowledgement character response message that Dynamic Host Configuration Protocol server one is sent.
Illustratively, can be executing above-mentioned message interaction step process, since communication equipment one is by original the
One IP address 192.168.3.254 is switched to the second IP address, is re-set as connecting and being in opening in the attribute of physical network card
After opening state, Dynamic Host Configuration Protocol server one of the communication equipment one into VLAN network segment B sends the first DHCP comprising former first IP address
Request message (the first request message), request continue to obtain the first IP address 192.168.3.254.It is serviced according to Radius
The dependency rule configured in device, the first IP address before carrying out IP address switching, in the former VLAN segment A of communication equipment one
It is to be distributed by the Dynamic Host Configuration Protocol server two in VLAN segment A, the Dynamic Host Configuration Protocol server one in VLAN network segment B cannot distribute the VLAN net
The first IP address in section A, thus Dynamic Host Configuration Protocol server one sends a DHCP NAK (Negative to communication equipment one
Acknowledgement, non-acknowledgement message) response message, notify first IP address of communication equipment 1 that can not distribute, communication is set
Standby one sends a DHCP Discover message (it was found that message) to Dynamic Host Configuration Protocol server one in turn, and request is rented one and can be distributed
VLAN network segment B in IP address, when Dynamic Host Configuration Protocol server one can to communication equipment one distribute VLAN network segment B in can use IP address
When, a DHCP Offer response message (message is provided) is sent to communication equipment one, communication equipment one receives the DHCP
The 2nd DHCP Request message (the second request message) is sent to request to use to Dynamic Host Configuration Protocol server one after Offer response message
The IP address.
Then, Dynamic Host Configuration Protocol server one sends the first DHCP ACK (Acknowledgement) response report to communication equipment one
The 2nd DHCP Request message of the transmission of communication equipment one has been received in literary (the first confirmation message), notice communication equipment one
(the second request message).At this time communication equipment one be basically completed obtain the second IP address process, can in a network into
Row communication.In addition, communication equipment one after having got the second IP address, can also send DHCP to Dynamic Host Configuration Protocol server one
Inform message (infomational message) to obtain some other network configuration informations, match once by the correlation inquired by Dynamic Host Configuration Protocol server
Confidence breath is sent to communication equipment one by the 2nd DHCP acknowledgement character response message (the second confirmation message).
It should be noted that being once to send two I/O control codes to driving layer with application layer to be in the embodiment of the present invention
What example was illustrated, include the first information for indicating connection breaking in the first I/O control code therein, is wrapped in the 2nd I/O control code
The second information for indicating connection is included, in order to first set connection breaking for the attribute of physical network card according to instruction information, then is arranged
For connection.It includes the first I/O control code for indicating connection breaking that certain application layer, which can also send one in first time, in order to root
Connection breaking first is set by the attribute of physical network card according to the first I/O control code;It includes indicating connection that one is sent at second
2nd I/O control code, in order to be set as connecting by the attribute of physical network card again according to the 2nd I/O control code.The present invention is real
Example is applied to specific embodiment without limitation.
It should be noted that can be connected by dhcp relay agent server between communication equipment and Dynamic Host Configuration Protocol server
It connects, can not also be attached by dhcp relay agent server, the embodiment of the present invention is without limitation.
In addition, the embodiment of the present invention is to be switched to application scenarios to the acquisition side of IP address with the IP address between VLAN network segment
What method was illustrated, certain this method can also be applied to IP address switching when other scenes, and the embodiment of the present invention does not limit
It is fixed.
The embodiment of the present invention provides a kind of acquisition methods of network protocol IP address, when physical network card needs to switch currently
When the first IP address, by control operating system application layer to driving layer send message, and according in message Adapter Name and
Indicate that information, connection breaking in control physical network card and Dynamic Host Configuration Protocol server then control physical network card and connect with Dynamic Host Configuration Protocol server, from
And it triggers physical network card and interacts DHCP message with Dynamic Host Configuration Protocol server to obtain the second IP address after switching.Wherein, by Physical Network
Card and Dynamic Host Configuration Protocol server connection breaking can prevent physical network card from sending the DHCP message of release IP address to Dynamic Host Configuration Protocol server, then
After physical network card is connect with Dynamic Host Configuration Protocol server, the operation of application IP address can be carried out immediately, is arrived so as to quick obtaining
The second IP address after switching, thus can be to avoid in the prior art due to existing when API Function progress IP address release
Switch the slow-footed problem of IP address caused by blocking operation.
The embodiment of the present invention provides a kind of communication equipment 500 referring to Fig. 5
Whether determination unit 501, the physical network card for being determined for communication equipment 500 need to switch the first current IP
Address.
Control unit 502 can be used for when the definitive result of determination unit 501 is to be, control physical network card and dynamic
Connection breaking in host configuration Dynamic Host Configuration Protocol server, and control physical network card and connect with Dynamic Host Configuration Protocol server, to trigger physical network card
With Dynamic Host Configuration Protocol server carry out DHCP message interact acquisition physical network card it is to be switched after the second IP address.
Wherein, physical network card work is the interface of connection communication equipment 500 and transmission medium in network in link layer, can
With between realization and network transmission mediums physical connection and electric signal match, can have multiple objects on a communication equipment 500
Network interface card is managed, Adapter Name is one-to-one with physical network card.IP address is that a kind of of IP agreement offer unifies format logically
Location, Dynamic Host Configuration Protocol server can dynamically distribute an IP address for each network interface card of communication equipment 500 in network, thus by the net
Communication equipment 500 where card is connected to network, realizes the communication with network.In order to meet the different application need in communication process
It asks, for example, in order to meet the demand for services of application program in application layer, communication equipment 500 may be needed to a certain physical network card
The first IP address currently distributed switches over.
It should be noted that Dynamic Host Configuration Protocol server here is not limited to individual server apparatus, also can integrate in
On other network equipments, such as can be integrated on switches by Dynamic Host Configuration Protocol server, the embodiment of the present invention is without limitation.
Optionally, control unit 502 can be specifically used for:
The application layer for controlling the operating system of communication equipment 500 sends message to the driving layer of operating system, and message includes
The Adapter Name and instruction information of physical network card, instruction information includes being used to indicate connection breaking in physical network card and Dynamic Host Configuration Protocol server
The first information, and it is used to indicate the second information that physical network card is connect with Dynamic Host Configuration Protocol server;
Control driving layer obtain message in Adapter Name and instruction information, and according to obtain subelement obtain Adapter Name and
Indicate connection breaking in first information control physical network card and the Dynamic Host Configuration Protocol server in information, and according in Adapter Name and instruction information
The second information control physical network card connect with Dynamic Host Configuration Protocol server.
Wherein, when carrying out IP address switching, the connection of physical network card and Dynamic Host Configuration Protocol server is interrupted, can be set with blocking communication
Standby 500 physical network card sends DHCP message to Dynamic Host Configuration Protocol server, i.e., not will do it and carry out IP by api function in the prior art
DHCP message interactive process when address discharges.And the connection of physical network card and Dynamic Host Configuration Protocol server is interrupted in communication equipment 500, resistance
After disconnected physical network card sends DHCP message to Dynamic Host Configuration Protocol server, physical network card and Dynamic Host Configuration Protocol server are reconnected, can directly be triggered
Communication equipment 500 sends the DHCP message of application IP address to Dynamic Host Configuration Protocol server.I.e. in the handoff procedure of IP address, communication is set
The process of application IP address is entered back into after not sending DHCP Release message as the prior art for 500, but is not sent out
Send DHCP Release message be directly entered the new IP address of application i.e. physical network card it is to be switched after the second IP address Shen
It please process.
Optionally, the Adapter Name of physical network card and instruction information can be indicated in a manner of I/O control code.
Optionally, control unit 502 can be specifically used for:
Control driving layer obtains the Adapter Name of physical network card according to I/O control code, and according to Adapter Name determination and Adapter Name
Corresponding driving filtering module;
Connection breaking is set for the attribute of physical network card according to Adapter Name and the first information by driving filtering module, so that
Connection breaking in physical network card and Dynamic Host Configuration Protocol server;
The attribute of physical network card is set as connecting according to Adapter Name and the second information by driving filtering module, so that object
Reason network interface card is connect with Dynamic Host Configuration Protocol server.
Optionally, control unit 502 can be also used for:
It triggers physical network card and sends DHCP request message to Dynamic Host Configuration Protocol server;
The dhcp response message that Dynamic Host Configuration Protocol server is sent is received by physical network card, dhcp response message includes DHCP service
Device be physical network card distribution it is to be switched after the second IP address.
The embodiment of the present invention provides a kind of communication equipment 500, when the physical network card of communication equipment 500 needs to switch currently
When the first IP address, by control operating system application layer to driving layer send message, and according in message Adapter Name and
Indicate that information, connection breaking in control physical network card and Dynamic Host Configuration Protocol server then control physical network card and connect with Dynamic Host Configuration Protocol server, from
And it triggers physical network card and interacts DHCP message with Dynamic Host Configuration Protocol server to obtain the second IP address after switching.Wherein, by Physical Network
Card and Dynamic Host Configuration Protocol server connection breaking can prevent physical network card from sending the DHCP message of release IP address to Dynamic Host Configuration Protocol server, then
After physical network card is connect with Dynamic Host Configuration Protocol server, the operation of application IP address can be carried out immediately, is arrived so as to quick obtaining
The second IP address after switching, thus can be to avoid in the prior art due to existing when API Function progress IP address release
Switch the slow-footed problem of IP address caused by blocking operation.
The embodiment of the present invention also provides a kind of communication equipment 600, as shown in fig. 6, the communication equipment 600 may include: total
Line 603;And it is connected to the processor 601 of bus 603, memory 602, the wherein memory 602 sum number for storing instruction
According to;The processor 601 executes the instruction for controlling physics when determining that physical network card needs to switch the first current IP address
Connection breaking in network interface card and dynamic host configuration protocol DHCP server;The processor 601 executes the instruction and is also used to control physics
Network interface card is connect with Dynamic Host Configuration Protocol server, interacts acquisition physical network card to trigger physical network card with Dynamic Host Configuration Protocol server progress DHCP message
The second IP address after to be switched.
In embodiments of the present invention, optionally, which it is main for controlling physical network card and dynamic to execute the instruction
Connection breaking in machine configuration protocol DHCP server, control physical network card is connect with Dynamic Host Configuration Protocol server may include:
The application layer for controlling operating system sends message to the driving layer of operating system, and message includes the network interface card of physical network card
Name and instruction information, instruction information include the first information for being used to indicate connection breaking in physical network card and Dynamic Host Configuration Protocol server, and
It is used to indicate the second information that physical network card is connect with Dynamic Host Configuration Protocol server;
Control driving layer obtains Adapter Name and instruction information in message, and according to first in Adapter Name and instruction information
Information controls connection breaking in physical network card and Dynamic Host Configuration Protocol server;
Control driving layer connects according to the second information control physical network card in Adapter Name and instruction information with Dynamic Host Configuration Protocol server
It connects.
In embodiments of the present invention, optionally, the Adapter Name of physical network card and instruction information table in a manner of I/O control code
Show.
In embodiments of the present invention, optionally, which executes the instruction and obtains in message for controlling driving layer
Adapter Name and instruction information, and physical network card and Dynamic Host Configuration Protocol server are controlled according to the first information in Adapter Name and instruction information
Middle connection breaking, being connect according to the second information control physical network card in Adapter Name and instruction information with Dynamic Host Configuration Protocol server can wrap
It includes:
Control driving layer obtains the Adapter Name of physical network card according to I/O control code, and according to Adapter Name determination and Adapter Name
Corresponding driving filtering module;
Connection breaking is set for the attribute of physical network card according to Adapter Name and the first information by driving filtering module, so that
Connection breaking in physical network card and Dynamic Host Configuration Protocol server;
The attribute of physical network card is set as connecting according to Adapter Name and the second information by driving filtering module, so that object
Reason network interface card is connect with Dynamic Host Configuration Protocol server.
In embodiments of the present invention, optionally, which executes the instruction and takes for triggering physical network card and DHCP
Business device carry out DHCP message interaction obtain physical network card it is to be switched after the second IP address may include:
It triggers physical network card and sends DHCP request message to Dynamic Host Configuration Protocol server;
The dhcp response message that Dynamic Host Configuration Protocol server is sent is received by physical network card, dhcp response message includes DHCP service
Device be physical network card distribution it is to be switched after the second IP address.
In addition, can be attached by dhcp relay agent server between communication equipment 600 and Dynamic Host Configuration Protocol server,
It can not be attached by dhcp relay agent server, the embodiment of the present invention is without limitation.
The embodiment of the present invention provides a kind of communication equipment 600, when the physical network card of communication equipment 600 needs to switch currently
When the first IP address, connection breaking in control physical network card and dynamic host configuration protocol DHCP server then controls Physical Network
Card connect with Dynamic Host Configuration Protocol server, and to trigger physical network card and Dynamic Host Configuration Protocol server progress DHCP message, to interact acquisition physical network card to be cut
The second IP address after changing.Wherein, by physical network card and Dynamic Host Configuration Protocol server connection breaking, physical network card can be prevented to DHCP service
Device sends the DHCP message of release IP address, then after physical network card is connect with Dynamic Host Configuration Protocol server, can carry out application IP immediately
The operation of address, so as to the second IP address after quick obtaining to switching, thus can be to avoid in the prior art due to adjusting
There are switch the slow-footed problem of IP address caused by blocking operation when carrying out IP address release with api function.
The embodiment of the present invention also provides a kind of communication system 1, as shown in fig. 7, comprises Dynamic Host Configuration Protocol server, further include as Fig. 5,
Communication equipment set forth in fig. 6, the specific implementation of the communication equipment may refer to above-described embodiment, no longer superfluous herein
It states.
In several embodiments provided herein, it should be understood that disclosed method and communication equipment, Ke Yitong
Other modes are crossed to realize.For example, apparatus embodiments described above are merely indicative, for example, the unit is drawn
Point, only a kind of logical function partition, there may be another division manner in actual implementation, such as multiple units or components can
To combine or be desirably integrated into another system, or some features can be ignored or not executed.Another point, it is shown or beg for
The mutual coupling, direct-coupling or communication connection of opinion can be through some interfaces, the INDIRECT COUPLING of device or unit
Or communication connection, it can be electrical property, mechanical or other forms.
In addition, each functional unit can integrate in one processing unit in equipment in each embodiment of the present invention,
Being also possible to the independent physics of each unit includes that can also be integrated in one unit with two or more units.And it is above-mentioned
Each unit both can take the form of hardware realization, can also be realized in the form of hardware adds SFU software functional unit.
This can be accomplished by hardware associated with program instructions for all or part of the steps of realization above method embodiment, preceding
The program stated can be stored in a computer readable storage medium, and when being executed, execute includes that the above method is real to the program
The step of applying;And storage medium above-mentioned includes: USB flash disk, mobile hard disk, read-only memory (English: Read Only
Memory, abbreviation: ROM), random access memory (English: Random Access Memory, abbreviation: RAM), magnetic disk or
The various media that can store program code such as CD.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain
Lid is within protection scope of the present invention.Therefore, protection scope of the present invention should be based on the protection scope of the described claims.