+ Suggest network infrastructure and client services

Network architecture and evolution

Stand-alone architecture

- 就只有一个客户端,不需要和服务器交换数据

CS architecture

- 客户端(Client)--- 服务端(Server)
- - 客户端:用户安装软件
- - 服务端:统一管理数据库的主机中的软件就叫做服务端,再后来服务端不只是管理数据,外加处理业务逻辑

CS architecture requirements

- 要求操作系统安装客户端;产商操作系统部署服务端
- 每个用户需要独立安装软件、服务端升级也要每个用户升级

Interview questions: the pros and cons of data on the server and client?

数据如果放在服务端处理安全性,稳定性而且升级很容易,但是对于服务器的负荷比较大
数据如果放在客户端处理,安全性、稳定性会降低,并且升级需要每个客户端都去升级,不利于节约网络资源

BS Architecture

- 浏览器(Browser) --- 服务端(Server)
- 统一客户端即默认安装用户电脑中的资源,访问同种类的网站,具体业务的处理根据相应的协议和标砖提供的服务器程序,在服务器中处理

- 原理上来说BS架构其实就是CS架构,就现在来说BS架构与OS架构的区别:
在技术架构,核心技术,在线预订等层面上来说BS架构其实是优于CS架构的,但在原理上来说BS架构其实也是一个cs架构,因为BS的浏览器端,其实也可以说成是客户端

Composition of the Internet

Composition of the Internet (textbooks)

Internet topology is very complex, and global coverage geographically, from the work point of view, can be divided into two blocks:
- 1. Edge Structure: This section consists of all the hosts connected to the Internet composed, in part the user directly used for communication and resource sharing
- 2. the core part: a plurality of network routers connected to these networks and composition, which part is used to provide services for edge structures.
these are divided textbook:

Internet component (science):

He said part of the Internet everyone is familiar with using the Internet to open the phone or computer to read news, Taobao brush, watching vibrato, and now the Internet has become the people's lives

Block chain is known as the next generation Internet

Internet infrastructure is very large, including hardware, software parts Let us first look at when you open your browser, did not enter a URL, such a simple action, there are computer-implemented process:
- 1. Browser Check if there is cached ip address corresponding to the domain name
- 2. If there is no corresponding cache ip domain, the domain name server to resolve the request to the corresponding ip address
- 3. the browser Scoket established connection, according to the http protocol type http get header assembly, through tcp / ip packets sent.
- 4.tcp / ip protocol will transmit signals through the network layer card (wifi or cable) to a home router, the router sends a signal inside the home to manufacturers of telecommunications switches,
locate the server, the server may hosting in IDC room, perhaps in Ali cloud VPS, perhaps abroad
- the room 5. there are many large switches, cabinets, professional precision air that Taiwan ip of the server you want to access it in a cabinet
- 6. in after the server receives the signal, according to the solution will tcp / ip protocol http protocol headers that determine the data returned by the need to get request
- server 7. in fact, according to the service as well as Complex logic, there are a lot of servers behind the server, specifies that in the end servers to process the request, load balancing equipment needs to be done
- 8. To return the data is in the cache, or in a static file or in a database .
- 9 data browser returned and found some static resources (css, js, etc.) time and again launched a new http request, but these static resource files may CDN network, the whole process a request from a static resource needs step go again. and probably through the middle of the interactive machines, process route is not the same

Internet hardware

    - 1.终端设备
    - 2.网络设备
    - 3.主机设备

Internet software components

    - 1.网路协议类
    - 2.操作系统类
    - 3.平台中间插件类
    - 4.应用类

OSI seven layer protocol

Nature of the Internet is actually a series of network protocols, this protocol is called OSI protocol, is artificial division, the main difference is the role of each layer, easy to understand
seven: the application layer, presentation layer, session layer, transport layer, network layer, a data link layer, physical layer
five layers: an application layer, transport layer, network layer, data link layer, physical layer
four layers: the application layer, transport layer, network layer, network interface layer
above it in fact three dividing manner meaning is the same, but different people remember it

1. Physical layer: receiving a low voltage level
2. The data link layer: high and low voltage level interpretation, an electric signal dividing a packet into a data frame (from the packet header and the data)
the -head comprising (fixed 18 bytes)
- The sender / source address of 6 bytes
- the recipient / destination address of 6 bytes
- 6 bytes of data types
-data comprising :( their minimum 46, maximum 1500 bytes)
3. network layer: the introduction of a new address is used to distinguish between different broadcast domain / subnet, i.e. the network address of this address
- the agreement protocol called an IP network address, called an IP address defined by the address

- 子网掩码就是表示网络特征的一个参数,他在形式上等同于一个ip地址

- IP协议的作用主要是,为每一台计算机分配ip地址和确定那些地址在同一个网络

- 有了MAC地址+IP地址,我们就可以确定世界上独一无二的一台计算机了

- APR协议:获取对方的MAC地址(通过广播的形式),因为每台计算机的IP地址是已知的,所以只需要获取MAC地址,就可以确定计算机了

4. Transport Layer: establishing a communication port to port
- a determined application found on a computer, it is required by a port, a card associated with the application ID
- the TCP protocol:
reliable transmission (connection is required, three-way handshake, tetrakis sway)
- the UDP protocol:
unreliable transport (without establishing a connection, data is easily lost, the packet loss is playing lol)
5. application layer: data format predetermined application layer
- TCP protocol data can be transferred to various programs , so there is a prescribed data format for a variety of application protocols constitute the application layer exists.
- TCP protocol agreement is a nice guy who can come

Use socket to establish a simple service and client

Server

#导入一个socket模块
import socket

#想象成买手机打电话:socket.SOCK_STREAM 表示建立tcp连接 ,udp连接socket.SOCK_DGRAM
#买了个手机
soc=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
#插电话卡:绑定ip地址  传元组:(ip,端口号)
soc.bind(('192.168.11.146',8080))  #如果写本机ip,局域网外部可以访问
# soc.bind(('127.0.0.1',8080))    #如果写127.0.0.1,只能自己访问

#开机,监听,这个5 是半连接池的大小
soc.listen(5)
#等待别人给我打电话
print('xxxx')
conn,addr=soc.accept()
print('yyyy')
print(addr)
# conn 就是通路
#接收1024个字节
data=conn.recv(1024)
print('我收到客户端发的',data)
#conn.send  发送数据,数据必须是bytes格式
conn.send(b'xxxxx')

#挂断电话
conn.close()
#销毁手机
soc.close()

Client


import socket
#创建一个socket对象
soc=socket.socket()
#连接服务端
soc.connect(('192.168.11.146',8080))
#发送消息
soc.send(b'xxx')

data=soc.recv(1024)
print('我收到服务端回的',data)
#关闭连接
soc.close()

Guess you like

Origin www.cnblogs.com/xiongchao0823/p/11468977.html