current position:Home>Do you want to ask about network knowledge in the interview? Just know a little
Do you want to ask about network knowledge in the interview? Just know a little
2022-01-27 00:11:34 【nezha】
Catalog
-
- One 、TCP And UDP
- Two 、 be based on TCP Connection oriented socket of protocol (Internet Socket)
- 3、 ... and 、 be based on UDP Connectionless socket for protocol (Datagram Sockets)
- Four 、 Blocking problem of receiving data
- 5、 ... and 、TCP Realize data upload
- 6、 ... and 、UDP Realize data upload
- 7、 ... and 、 Network layer security
One 、TCP And UDP
TCP(Transmission Control Protocol, Transmission control protocol ) agreement : Responsible for segmenting the files to be transferred transmitted , Generally used to establish a session , Its basic characteristic is reliable transmission 、 flow control , The so-called three handshakes 、 Four waves are also based on TCP Agreed .
UDP(User Data Protocol, User datagram protocol ) agreement : One data packet can complete data communication , Packets are not segmented , No need to establish a session , No need for flow control , It's an unreliable transmission , On screen broadcast 、 multicast 、 Broadcasts are based on UDP agreement .
Two 、 be based on TCP Connection oriented socket of protocol (Internet Socket)
1、TCP
The Transmission Control Protocol Transmission control protocol .
2、 Streaming socket
We often talk about sockets, that is Internet Scoket, According to the data transmission mode , Can be Internet Scoket There are several kinds of , In the use of socket() When creating a network connection , It must be told which data transmission mode it is , Simply put, it is the control protocol of data transmission .
The computer field is called : Streaming socket (Stream Sockets), Use... In computer code SOCK_STREAM Express .
3、SOCK_STREAM Has the following characteristics
- reliable 、 Two way communication data flow ;
- Data transmission is carried out in sequence ;
- The data is accurate in transmission , It has its own retransmission mechanism ;
- The sending and receiving of data are out of sync , There is a buffer ;
- The typical application of stream format socket is HTTP agreement , Because the browser must have complete and correct data when loading and parsing .
3、 ... and 、 be based on UDP Connectionless socket for protocol (Datagram Sockets)
1、UDP
User Datagram Protocol User datagram protocol .
2、 Datagram format socket
be based on UDP Connectionless socket for protocol , The computer field is called : Datagram format socket (Datagram Sockets), Used in computer code SOCK_DGRAM Express .
SOCK_DGRAM It's a high efficiency 、 high velocity 、 Unreliable communication data flow . It is based on UDP Agreed , No data verification , Only data transmission .
3、SOCK_DGRAM Has the following characteristics
- There is a limit on the size of data transmitted each time ;
- The pursuit of high efficiency 、 high velocity ;
- The transmitted data may be lost or damaged ( Small probability events );
- Sending and receiving data is synchronous , That is, there are data boundaries ;
- A typical application of datagram format is QQ Video and voice , Because the requirements of both are high efficiency and low latency , At the same time, the loss of data with small probability will not affect the transmission quality of the whole data .
Four 、 Blocking problem of receiving data
1、TCP
If there is no data , Blocking Socket I'll wait , Until there are several ;
Non blocking Socket return WSAEWOULDBLOCK;
If there's data , Take as much as you have .
2、UDP
If there is no data , Blocking Socket I'll wait ;
Non blocking Socket return WSAEWOULDBLOCK;
If there's data , It will wait for the whole contract to arrive , And receive the whole contract , To return to .
5、 ... and 、TCP Realize data upload
1、TCP Server side
package com.tcpip;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
public class TcpServerTest {
public static void main(String[] args) throws Exception {
//1、 Create services
ServerSocket serverSocket = new ServerSocket(9000);
//2、 Listen for client connections
Socket socket = serverSocket.accept();
//3、 Get input stream
InputStream is = socket.getInputStream();
//4、 File output
FileOutputStream fos = new FileOutputStream(new File("copy.png"));
byte[] buffer = new byte[1024];
int len;
while ((len=is.read(buffer))!=-1){
fos.write(buffer,0,len);
}
//5、 close resource
fos.close();
is.close();
socket.close();
serverSocket.close();
}
}
2、TCP client
package com.tcpip;
import java.io.File;
import java.io.FileInputStream;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.Socket;
public class TcpClientTest {
public static void main(String[] args) throws Exception {
//1、 Create a socket Connect
Socket socket = new Socket(InetAddress.getByName("127.0.0.1"),9000);
//2、 Create an output stream
OutputStream os = socket.getOutputStream();
//3、 Read the file
FileInputStream fis = new FileInputStream(new File("01.png"));
//4、 write file
byte[] buffer = new byte[1024];
int len;
while ((len=fis.read(buffer))!=-1){
os.write(buffer,0,len);
}
//5. close resource
fis.close();
os.close();
socket.close();
}
}
3、 test
6、 ... and 、UDP Realize data upload
1、UDP The receiver
package com.tcpip;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
public class UdpServerTest {
public static void main(String[] args) throws Exception {
//1、 Open ports
DatagramSocket socket = new DatagramSocket(9090);
//2、 Receive packets
byte[] buffer = new byte[1024];
DatagramPacket packet = new DatagramPacket(buffer,0,buffer.length);
socket.receive(packet);
System.out.println(new String(packet.getData(),0,packet.getData().length));
//3、 Close the connection
socket.close();
}
}
2、UDP The sender
package com.tcpip;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
public class UdpClientTest {
public static void main(String[] args) throws Exception {
//1、 Build a socket
DatagramSocket socket = new DatagramSocket();
//2、 Build a package
String msg = "UDP test ";
InetAddress localhost = InetAddress.getByName("localhost");
int port = 9090;
DatagramPacket packet = new DatagramPacket(msg.getBytes(),0,msg.getBytes().length,localhost,port);
//3、 Send package
socket.send(packet);
//4、 close resource
socket.close();
}
}
3、 test
7、 ... and 、 Network layer security
1、 What are the security issues ?
- IP Deceptive attack
- Smurf attack (DDOS A type of attack )
- ICMP Redirection and unreachable attacks
- IP Address scanning attack
2、ipidea brief introduction
ipidea Is an overseas reptile agent , Provide overseas housing ip And overseas static ip, Mainly engaged in data collection business , Maintain long-term cooperation with multiple data acquisition enterprises . It provides 9000 ten thousand ip resources , You can customize the settings according to the capture requirements ip Rotation time , So as to avoid being blocked by the website . Support account secret authentication and API There are two ways to extract ip resources , The most important thing is to support free testing .
See the world's leading Internet big data for more details IP resources
3、ipidea Generate api link , Copy the link to apply
Plain or transparent ip During test extraction ip At the same time, it will waste a lot of time , Last , It may also fail ip. It's just that you can use agents ip, The way of use is simpler , Whether it's practical , stability 、 Security can be guaranteed . Use IPIDEA Conduct ip Extract and use .
4、 Build agent ip Operation and use
In the process of server maintenance or its own agent ip when , Many of them are not maintained in , So many agents ip appear , agent ip The use of is relatively simple , If there are problems, you can feed back to the agent in time and find technicians to solve them . Crawlers are used to quickly complete the work requirements , Using agents can save working time , Finish the work quickly .
Java Learning route supporting articles :Java Summary of learning routes , Brick movers counter attack Java Architects ( The best in the whole network )
Basic recommendation :Java Basic tutorial series
Practical recommendation :Spring Boot Basic course
brief introduction :Java Quality creators in the field 、CSDN The author of the official account of the No 、Java Architects, strivers
Scan the QR code on the left side of the home page , Join the group chat , Learning together 、 Progress together
Welcome to thumb up Collection Leaving a message.
copyright notice
author[nezha],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270011308628.html
The sidebar is recommended
- Spring IOC container loading process
- [thinking] the difference between singleton mode and static method - object-oriented programming
- Hadoop environment setup (MySQL environment configuration)
- 10 minutes, using node JS creates a real-time early warning system for bad weather!
- Git tool
- Force deduction algorithm - 92 Reverse linked list II
- What is the sub problem of dynamic programming?
- C / C + +: static keyword summary
- Idea does not have the artifacts option when configuring Tomcat
- Anaconda can't open it
guess what you like
-
I don't know how to start this
-
Matlab simulation of transportation optimization algorithm based on PSO
-
MySQL slow log optimization
-
[Vue] as the window is stretched (larger, smaller, wider and higher), the text will not be displayed
-
Popular Linux distributions for embedded computing
-
Suzhou computer research
-
After installing SSL Certificate in Windows + tomcat, the domain name request is not successful. Please answer!!
-
Implementation time output and greetings of jQuery instance
-
The 72 year old uncle became popular. Wu Jing and Guo fan made his story into a film, which made countless dreamers blush
-
How to save computer research
Random recommended
- Springboot implements excel import and export, which is easy to use, and poi can be thrown away
- The final examination subjects of a class are mathematical programming, and the scores are sorted and output from high to low
- Two pronged approach, Tsinghua Professor Pro code JDK and hotspot source code notes, one-time learning to understand
- C + + recursive knapsack problem
- The use of GIT and GitHub and the latest git tutorial are easy to understand -- Video notes of crazy God speaking
- PostgreSQL statement query
- Ignition database test
- Context didn't understand why he got a high salary?, Nginxfair principle
- Bootstrap switch switch control user's guide, springcloud actual combat video
- A list that contains only strings. What other search methods can be used except sequential search
- [matlab path planning] multi ant colony algorithm grid map path planning [including GUI source code 650]
- [matlab path planning] improved genetic algorithm grid map path planning [including source code phase 525]
- Iinternet network path management system
- Appium settings app is not running after 5000ms
- Reactnative foundation - 07 (background image, status bar, statusbar)
- Reactnative foundation - 04 (custom rpx)
- If you want an embedded database (H2, hsql or Derby), please put it on the classpath
- When using stm32g070 Hal library, if you want to write to flash, you must perform an erase. If you don't let it, you can't write continuously.
- Linux checks where the software is installed and what files are installed
- SQL statement fuzzy query and time interval filtering
- 69. Sqrt (x) (c + + problem solving version with vs runnable source program)
- Fresh students are about to graduate. Do you choose Java development or big data?
- Java project: OA management system (java + SSM + bootstrap + MySQL + JSP)
- Titanic passenger survival prediction
- Vectorization of deep learning formula
- Configuration and use of private image warehouse of microservice architect docker
- Relearn JavaScript events
- For someone, delete return 1 and return 0
- How does Java dynamically obtain what type of data is passed? It is used to judge whether the data is the same, dynamic data type
- How does the database cow optimize SQL?
- [data structure] chain structure of binary tree (pre order traversal) (middle order traversal) (post order traversal) (sequence traversal)
- Webpack packaging optimization solution
- 5. Operation element
- Detailed explanation of red and black trees
- redhat7. 9 install database 19C
- Blue Bridge Cup notes: (the given elements are not repeated) complete arrangement (arrangement cannot be repeated, arrangement can be repeated)
- Detailed explanation of springboot default package scanning mechanism and @ componentscan specified scanning path
- How to solve the run-time exception of test times
- Detailed explanation of k8s management tool kubectl
- Android system view memory command