Background technique
With the continuous development of global IT application process, network is also being developed rapidly.For efficiently, rapidly process it is various
The purpose of affairs, more and more industries are worked using local area network inside it.It, can with the help of internal lan
To simplify information flow, the speed of information exchange is improved, to improve working efficiency.However, with the expansion of information data scale
Greatly, the increase of volume of transmitted data, run on a local area network using more and more, such as knowledge base, Web conference, database application
And backup synchronous with data etc., these are also higher and higher using the requirement of the information throughput, processing capacity of local area network.These
The appearance of the new situation that do not considered at the beginning of internal original design of local area network is easy to happen information so that local area network can't bear the heavy load
Obstruction becomes the bottleneck of development at this point, local area network cannot not only improve efficiency instead.
In order to solve above-mentioned contradiction, there has been proposed many methods.It promotes network bandwidth and increases the energy of handling up of server
Power is to solve this kind of contradictory method.However, from the aspect of the cost of operation, either merely promoted network bandwidth or
The handling capacity for increasing server all cannot fundamentally solve the problems, such as local network resource anxiety, to the big rule of old local area network
Mould hardware modification will increase the burden of cost instead.
Local area network immediate communication tool based on Socket is one of the specific example of such Local network communication software, it is very
The principle of socket communication has been annotated well, and all there is certain practical value in the application such as communication, teaching, discussion.
It has information transmit-receive speed fast, good confidentiality, and occupancy network bandwidth resources are low, and occupancy server handling capacity is low, is easy to compile
The advantages that Cheng Shixian.
Local network communication software application wide scope based on Socket, not only can handle traditional communication need, and
And can also extend to adapt to novel network application, such as Web education, data audio-visual transmission etc., possess broad application prospect.
Local area network instant message applications based on Socket can provide a kind of good, safety for original local area network, fastly
The communication mechanism of speed.Its realization is without making any change to original LAN hardware, with cheap excellent of cost of implementation
Point, its use can be effectively reduced local area network communication load, improve the service efficiency of local area network, can well solve various
Communication need.
Therefore, by the research to current local area network real-time communication method, discovery can exist when data traffic is big
Local area network and server cause very big pressure, and information occlusion occurs, and the high defect of maintenance cost needs to improve.
Summary of the invention
In order to overcome information occlusion present in current real-time communication, the deficiencies of transmission efficiency is low, Gao Chengben, present invention benefit
With Socket transmission and the technology that combines of P2P, AES encryption algorithm is introduced, it is fast to provide a kind of information transmit-receive speed, confidentiality
It is good, occupy the low real-time communication method based on Socket of network bandwidth resources.
The technical solution adopted by the present invention to solve the technical problems is:
A kind of real-time communication method based on Socket, the real-time communication method the following steps are included:
1) example for creating Socket object, determines the network protocol that the parameter type of Socket and Socket are used;
2) TCP/IP network communication protocol is selected, Transmission Control Protocol provides virtual circuit and transmission service, IP association for the process of data
The network layer that view is responsible for data provides service;
3) P2P technology is introduced, in such a way that P2P and B/S architecture mode combines, is used first using B/S mode
The IP address and PORT COM at family, are then communicated between user and user using P2P technology;
4) data transmission encryption, sender's data are encrypted through aes algorithm, then send net for encrypted content
In network, after recipient obtains the cipher-text information in network, calls aes algorithm to be decrypted, use between the computers
When Socket is communicated, realizes and check in plain text, the function of ciphertext transmission;Process is as follows:
4.1) ciphering process uses 128 key for encrypting data in aes algorithm, obtains by 3 following steps
To AESCBC128 encrypted cipher texts, process is as follows:
4.1.1) byte is replaced, and forms state matrix S (x) by 16 × 16 bytes for one, and totally 256 elements constitute S box,
High 4 in each element byte are used as x value, and low 4 are used as y value, and the element value of corresponding x and y is exactly replacement knot in S box
Fruit;
4.1.2) line position is moved, and state matrix S (x) is grouped into 4 × 4 matrix, changes member in a manner of ring shift left
The position of element, i.e. line n move to left n byte;A new matrix B (x) is obtained after permutatation;
4.1.3) column mixing, by each column and a fixed polynomial multiplications in state matrix S (x), such as formula (1)
It is shown:
As described in formula (1), new state matrix S ' (x) is obtained, as shown in formula (2):
Wherein, element { 01 }, { 02 }, { 03 } are field elements fixed in S box, and S ' (x) is column hybrid matrix;
4.2) decrypting process: passing through following 3 decrypting processes, completes the decryption to ciphertext, obtains the plaintext of transmission, process
It is as follows:
4.2.1 it) drives in the wrong direction and is displaced: ciphertext block is obtained at 4 × 4 matrix with encryption on the contrary, line n moves to right n byte
To Matrix C (x);
4.2.2) inverse column mixing: state matrix S (x) being multiplied with a fixed polynomial by column, obtains matrix S " (x),
As shown in formula (2)::
Wherein, { 09 }, { 0B }, { 0D }, { 0E } are field element fixed in S box;
4.2.3) inverse byte is replaced: it regard high 4 in each element byte as x ' value, low 4
As y ' value, the inverse S box replaced;
5) add-on system server, by server be divided into login module and monitor module, user using input account and
When password login system, server is sent by account and password, verifies its legitimacy;It is mutually communicated between users
When, it monitors module and is responsible for constantly monitoring the request sent, do corresponding operation according to request;
6) realization of real-time communication: user when sending file, the data informations such as text, the IP of acquisition other side first and
TCP port, using P2P technology, directly and other side establishes connection, and log-on data transmits thread, using aes algorithm to data information
Encrypted transmission is carried out, if transmission file, but other side does not receive for a long time, file is kept in system server, then
It is parsed by aes algorithm, is that other side views cleartext information.
Beneficial effects of the present invention are mainly manifested in: real-time communication method of the present invention is transmitted using Socket to be tied with P2P phase
The technology of conjunction introduces AES encryption algorithm, realizes the purpose of real-time communication, and information transmit-receive speed is fast, and good confidentiality occupies net
Network bandwidth resources are low.
Specific embodiment
The present invention will be further described with reference to the accompanying drawing.
It is referring to Figures 1 and 2, a kind of to be based on Socket real-time communication method, comprising the following steps:
1) example for creating Socket object, determines the network protocol that the parameter type of Socket and Socket are used;
2) TCP/IP network communication protocol is selected, Transmission Control Protocol provides virtual circuit and transmission service, IP association for the process of data
The network layer that view is responsible for data provides service;
3) P2P technology is introduced, in such a way that P2P and B/S architecture mode combines, is used first using B/S mode
The IP address and PORT COM at family, are then communicated between user and user using P2P technology;
4) data transmission encryption, sender's data are encrypted through aes algorithm, then send net for encrypted content
In network, after recipient obtains the cipher-text information in network, calls aes algorithm to be decrypted, use between the computers
When Socket is communicated, realizes and check in plain text, the function of ciphertext transmission;Process is as follows:
4.1) ciphering process uses 128 key for encrypting data in aes algorithm, obtains by 3 following steps
To AESCBC128 encrypted cipher texts, process is as follows:
4.1.1) byte is replaced, and forms state matrix S (x) by 16 × 16 bytes for one, and totally 256 elements constitute S box,
High 4 in each element byte are used as x value, and low 4 are used as y value, and the element value of corresponding x and y is exactly replacement knot in S box
Fruit;
4.1.2) line position is moved, and state matrix S (x) is grouped into 4 × 4 matrix, changes member in a manner of ring shift left
The position of element, i.e. line n move to left n byte;A new matrix B (x) is obtained after permutatation;
4.1.3) column mixing, by each column and a fixed polynomial multiplications in state matrix S (x), such as formula (1)
It is shown:
As described in formula (1), new state matrix S ' (x) is obtained, as shown in formula (2):
Wherein, element { 01 }, { 02 }, { 03 } are field elements fixed in S box, and S ' (x) is column hybrid matrix;
4.2) decrypting process: passing through following 3 decrypting processes, completes the decryption to ciphertext, obtains the plaintext of transmission, process
It is as follows:
4.2.1 it) drives in the wrong direction and is displaced: ciphertext block is obtained at 4 × 4 matrix with encryption on the contrary, line n moves to right n byte
To Matrix C (x);
4.2.2) inverse column mixing: state matrix S (x) being multiplied with a fixed polynomial by column, obtains matrix S " (x),
As shown in formula (2)::
Wherein, { 09 }, { 0B }, { 0D }, { 0E } are field element fixed in S box;
4.2.3) inverse byte is replaced: regarding high 4 in each element byte as x ' value, low 4 are used as y ' value, are replaced
The inverse S box changed;
5) add-on system server, by server be divided into login module and monitor module, user using input account and
When password login system, server is sent by account and password, verifies its legitimacy;It is mutually communicated between users
When, it monitors module and is responsible for constantly monitoring the request sent, do corresponding operation according to request;
6) realization of real-time communication: user when sending file, the data informations such as text, the IP of acquisition other side first and
TCP port, using P2P technology, directly and other side establishes connection, and log-on data transmits thread, using aes algorithm to data information
Encrypted transmission is carried out, if transmission file, but other side does not receive for a long time, file is kept in system server, then
It is parsed by aes algorithm, is that other side views cleartext information.
By taking a set of Education Administration Information System as an example, a kind of real-time communication method based on Socket, comprising the following steps:
1) example for creating Socket object, determines the network protocol that the parameter type of Socket and Socket are used;
2) TCP/IP network communication protocol is selected, Transmission Control Protocol provides virtual circuit and transmission service, IP association for the process of data
The network layer that view is responsible for data provides service;
3) P2P technology is introduced, in such a way that P2P and B/S architecture mode combines, is used first using B/S mode
The IP address and PORT COM at family, are then communicated between user and user using P2P technology;
4) data transmission encryption, sender's data are encrypted through aes algorithm, then send net for encrypted content
In network, after recipient obtains the cipher-text information in network, calls aes algorithm to be decrypted, use between the computers
When Socket is communicated, realizes and check in plain text, the function of ciphertext transmission;Process is as follows:
4.1) ciphering process uses 128 key for encrypting data in aes algorithm, obtains by 3 following steps
To AESCBC128 encrypted cipher texts, process is as follows:
4.1.1) byte is replaced, and forms state matrix S (x) by 16 × 16 bytes for one, and totally 256 elements constitute S box,
High 4 in each element byte are used as x value, and low 4 are used as y value, and the element value of corresponding x and y is exactly replacement knot in S box
Fruit;
4.1.2) line position is moved, and state matrix S (x) is grouped into 4 × 4 matrix, changes member in a manner of ring shift left
The position of element, i.e. line n move to left n byte;A new matrix B (x) is obtained after permutatation;
4.1.3) column mixing, by each column and a fixed polynomial multiplications in state matrix S (x), such as formula (1)
It is shown:
As described in formula (1), new state matrix S ' (x) is obtained, as shown in formula (2):
Wherein, element { 01 }, { 02 }, { 03 } are field elements fixed in S box, and S ' (x) is column hybrid matrix;
4.2) decrypting process: passing through following 3 decrypting processes, completes the decryption to ciphertext, obtains the plaintext of transmission, process
It is as follows:
4.2.1 it) drives in the wrong direction and is displaced: ciphertext block is obtained at 4 × 4 matrix with encryption on the contrary, line n moves to right n byte
To Matrix C (x);
4.2.2) inverse column mixing: state matrix S (x) being multiplied with a fixed polynomial by column, obtains matrix S " (x),
As shown in formula (2)::
Wherein, { 09 }, { 0B }, { 0D }, { 0E } are field element fixed in S box;
4.2.3) inverse byte is replaced: regarding high 4 in each element byte as x ' value, low 4 are used as y ' value, are replaced
The inverse S box changed;
5) add-on system server, by server be divided into login module and monitor module, user using input account and
When password login system, server is sent by account and password, verifies its legitimacy;It is mutually communicated between users
When, it monitors module and is responsible for constantly monitoring the request sent, do corresponding operation according to request;
6) realization of real-time communication: user when sending file, the data informations such as text, the IP of acquisition other side first and
TCP port, using P2P technology, directly and other side establishes connection, and log-on data transmits thread, using aes algorithm to data information
Encrypted transmission is carried out, if transmission file, but other side does not receive for a long time, file is kept in system server, then
It is parsed by aes algorithm, is that other side views cleartext information.
Described above is the good results that one embodiment that the present invention provides is shown, it is clear that the present invention is not
It is suitable only for above-described embodiment, without departing from essence spirit of the present invention and without departing from the premise of content involved by substantive content of the present invention
Under can do many variations to it and be implemented.