当前位置:网站首页>Network Protocol 01 - Basic Concepts
Network Protocol 01 - Basic Concepts
2022-07-30 07:41:00 【Rhubarb _ yellow】
The server code mainly starts withJava为主
客户端 - Basic Concepts of the Server(1)
Java跨平台的原理
其实JavaCross-platform and interpreted languages are similar,例如JavaScript、Python等,像JavaScriptFrom a shallow perspective, browser parsing,Essentially a browser engine(如Chrome的V8)
C/C++跨平台原理
服务器环境
The structure of the server environment is roughly as follows:
- 服务器:Essentially a computer,Multiple port numbers can be set(The port is equivalent to the window through which the server provides services to the client)
- JVM:Java虚拟机(Java Virtual Machine)
- 服务器软件Tomcat:Monitor data flow on a port, 执行我们编写的Java代码,respond by port
- 开发人员的Java代码:指的就是Java代码项目,例如QQ、WeChat's background service
计算机之间的通信基础
- 首先需要知道对方的IP地址
- 其次是获取MAC地址(也就是网卡地址),输送数据到网卡,accepted by the network card
- If the network card finds that the destination address of the data is itself,就会将数据传递给上一层进行处理
- If the network card finds that the destination address of the data is not itself,就会将数据丢弃,不会传递给上一层进行处理
网卡:network interface controller,网络适配器,有一个被称为MAC地址的独一无二的48位串行号,被写在卡上的一块ROM中
计算机之间的连接方式(2)
网线直连(过程)
首先举个例子,用Cisco Packet Tracer Software Demonstration Two Computers Sending Data Packets(本质就是:Ping 对方的地址)的过程
首先计算机0通过 ICMP协议 send packets to computer0
However, the computer0Need to get the other party'sMAC地址,So you need to go firstARP协议,发出广播,which will mark the sourceIP地址和目标IP地址,以及源MAC地址,同时目标MAC地址为FFFF.FFFF.FFFF(全是1Delegate is broadcast,All NICs on the same network segment can receive)
当计算机1接收到广播,Mark the sourceIP、目标IP、源MAC、目标MAC,back to computer0
然后再通过ICMP协议传输数据
整个过程如下
Then introduce the coaxial cable、集线器、网桥、交换机、Connection methods and features of routers and other devices
同轴电缆
缺点:
- 半双工通信:Only one direction of the two computer connection channels is allowed to send data
- 容易冲突:Often two computers sending data at the same time on the same channel can cause conflicts
- 不安全:没有智商,All data will be sent once according to the connected channel,Easy to be captured by non-target computers
- 可靠性差:Once a link is broken in the middle,整个网络就会瘫痪
集线器(Hub)
相比同轴电缆
优点:more reliable,A computer disconnection does not affect global connections
缺点:Still half-duplex communication,容易冲突,不安全,没有智商
网桥(Bridge)
相比集线器:
优点:有智商,You can learn the interface on the side of each interface by learning.MAC地址,从而可以起到隔绝冲突域的作用,block non-targetMAC地址的请求
缺点:只有两个接口,All computers on the same interface side will still form a collision domain,且不安全
交换机
相比网桥:
优点:接口多,支持全双工通信,Data can be transferred between multiple devices at the same time,更安全,according to the targetMACAddress direct send the data in the past,非目标MACAddress will be blocked
缺点:Only supports connections within the same network segment:Switches can be said to be the ultimate solution for LANs,Not suitable for large-scale connections,因为需要通过Arpbroadcast to all connections(If computers all over the world were connected,就会造成广播风暴)
以上的连接方式,The connected devices all need to be in the same broadcast domain(同一网段),Once it comes to a wide range of connections,You need to set up multiple network segments to isolate the broadcast domain,However, because two hosts on different network segments cannot send data across network segments,Then the router appears
路由器
如下图所示,There are two different network segments on the left and right of the router.(默认子网掩码为255.255.255.0)
主机发送数据之前,首先会判断目标主机的IP地址是否在同一个网段
- 在同一个网段: 发ARP广播,通过交换机\集线器传递数据
- 不在同一个网段:通过路由器转发数据
The main function of the router is to isolate the broadcast domain,可以在不同网段之间转发数据,So how does the router forward data across network segments??
Want to forward data across network segments,Through the gateway,That is, the two ports of the router in the above figure Fa0/0和Fa1/0,Every gateway hasIP地址和MAC地址,而且MACThe address needs to be on the same network segment as the host on the connected side,Generally recommended for gatewaysIPThe last decimal digit of the address is1,例如常见的192.168.0.1等
And the host on the same side as the gateway needs to configure the same side gatewayIP地址
Next suppose that the computers in the connection diagram2send data to computer5,其过程为:
- 计算机2通过ARP协议(目标地址为Fa0网关的IP地址)获取Fa0网关的MAC地址
- 计算机2通过ICMPprotocol to send packets toFa0网关
- Fa0Gateway forwards data toFa1网关
- Fa1网关通过ARPagreement to acquire computer5的MAC地址
- Fa1网关通过ICMPprotocol to send packets to the computer5
- 计算机5沿着Fa1网关、Fa0网关,return the packet to the computer2
边栏推荐
猜你喜欢
随机推荐
单片机之流水灯
02-Use of Cycript
Selenium02
GNNLab: A Novel GNN System Based on Spatial Sharing Ideas
图计算在网络安全分析中的应用
图扑数字孪生北京故宫,推进旅游业元宇宙进程
牛客:删除公共字符
C 语言之学生管理系统-多文件编程
npm安装nodejs环境配置
IO进程线程->目录IO->day3
不依赖框架的文件下载
多线程基础(多线程内存,安全,通信,线程池和阻塞队列)
掌握JESD204B(三)–AD6676的调试
多线程进阶(CountDownLatch,死锁,线程安全集合类)
Network Protocol 04 - Physical and Data Link Layers
Biotinyl Cystamine_CAS:128915-82-2_生物素半胱胺
用于标记蛋白质和抗体的Biotin-LC-Sulfo-NHS|CAS:191671-46-2
Alamofire源码分析 - POST请求
Biotin-Dadps-azide|CAS:1260247-50-4|生物素-DADPS-叠氮
VsCode connects to the remote server and modifies the file code