day 26

Contents

  • Development framework
    • C/S architecture
    • B/S architecture
  • OSI model
    • application layer
    • presentation layer< /li>
    • Session layer
    • Transport layer
    • Network layer
    • Data link layer
    • Physical layer
  • TCP protocol
  • socket

Development Framework

h1>

C/S architecture

  • client and server, both client and server
  • Advantages: strong stability, saving network Resources
  • Disadvantages: Using multiple software requires downloading multiple clients, software updates, and the client must also download updates

B/S Architecture

  • Browser and server, both browser side and server side
  • Advantages: The browser is used as the client, and the software can be accessed directly on the browser. No need to download multiple Client, no need to download and update software
  • Disadvantages: poor stability, consumes too much network resources

OSI model

  • open system interconnection
  • This model defines the standards for the interconnection of different computers, and is the basic framework for designing and describing computer network communications

Application layer

  • Provide user services, the specific content is specified by a specific program

presentation layer

  • Provide data encryption and decryption, compression and decompression services

session layer

    < li>Confirm to establish application link, select transmission service

Transport layer

  • Provide data transmission service and perform flow control
  • >

  • TCP/UDP protocols, they all work based on ports
  • Port number: Identifies a certain software on the computer
  • Port number range: 0-65535
  • Note: In the operating system, generally 0-1024 port numbers have been used by default, try to use port numbers after 8000
  • The default port numbers of commonly used software in development:
software name Port number
Mysql 3306
mongodb 27017
Django 8000
Tomcat 8080
Flask 5000
Redis 6379
  • To communicate between the server and the client, a connection must be established to create a two-way channel

network layer

    < li>Routing selection, network interconnection
  • IP address: Assign a logical address to each network and each host on the Internet to shield the difference in physical addresses
  • Decimal, minimum 0.0.0.0, maximum 255.255.255.255
  • Local IP: loopback address 127.0.0.1 (localhost)
  • Provide link exchange and send specific messages
  • Ethernet protocol, used to process binary data sent based on electrical signals
  • Ethernet protocol:
    1. Specify the grouping method of electrical signal data
    2. mac address, the network card number (12 digits) uniquely identified in the network

    < /li>

  • Switch: Connect multiple computers together
  • Send data based on Ethernet protocol:
    1. Features: broadcast, unicast
    2. Disadvantages: Broadcast storm, can’t boast LAN communication
  • Internet: Let the communication between LANs

physical layer< /h2>

  1. Specifications for physical hardware, network cards, interfaces, etc.
  2. Send binary data based on electrical signals

TCP protocol

  • transmission control protocol, transmission control protocol

  • TCP is a streaming protocol

  • Three handshake, four waves:

    1. Three handshake to establish a connection

    2. Send data:

      < p>The client lets the server send data, and the data is stored Put it in the memory, the data will be released in the memory only after the server confirms the receipt, otherwise it will be sent at intervals, and the server will return to confirm the receipt

      For a period of time, if the service If the terminal still does not return, cancel the sending and release the data in the memory

    3. Terminate the connection with four waves

socket

  • socket is a module that can write a set of sockets with C/S architecture
  • socket socket The word will encapsulate the work of each layer of the protocol, saving development costs
Copy# Server
import socket

server = socket.socket()< br />
# Set IP and port
server.bind(
('127.0.0.1', 8888)
)

# Semi-connection pool , The maximum number of waiting is 5
server.listen(5)

while True:
# Waiting for connection
conn, addr = server.accept() # conn: A new socket created by establishing a connection, addr: client port
print(addr)

while True:
try:
# receive data
data = conn.recv(1024).decode('utf-8') # Receive data up to 1024 bytes

if data =='q':
break

if len(data) == 0:
continue

print(data)

# Send data
conn.send( data.encode('utf-8'))

except Exception as e:
print(e)
break

conn.close()
Copy# Client
import socket

client = socket.socket()

# The server sends a connection request
client.connect(('127.0.0.1', 8888))

while True:
send_msg = input('client ---> server:')

# Send data
client.send(send_msg.encode('utf-8 '))

if send_msg =='q':
break

# Receive data
date = client.recv(1024).decode( 'utf-8')
print(date)

# Close the connection
client.close()

Contents

  • Development framework
    • C/S framework
    • B/S framework< /li>
  • OSI model
    • application layer
    • presentation layer
    • session layer
    • transmission Layer
    • Network layer
    • Data link layer
    • Physical layer
  • TCP protocol
  • socket

  • Development architecture
    • C/S architecture
    • B /S Architecture
  • OS I model
    • application layer
    • presentation layer
    • session layer
    • transport layer
    • network layer
    • Data link layer
    • Physical layer
  • TCP protocol
  • socket

< /p>

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 455 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.