Python network Programming-osi Seven-tier model detailed

Source: Internet
Author: User
Tags network function sessions switches file transfer protocol

The OSI Seven-layer model enables reliable communication between different networks of different systems through seven hierarchical structural models, so its main function is to help different types of hosts achieve data transfer.

The nodes that complete the relay function are often referred to as trunking Systems. In the OSI seven layer model, the relay systems at different tiers have different names.

The level at which a device works, the key is to see which layer of data head information it is working with. When the bridge is working, it is the head of the Mac that determines the forwarding port, so obviously it is the device of the data link layer.
specifically says:
Physical layer: Network card, Network cable, hub, repeater, Modem

Data Link layer: bridge, switch

Network Layer: Router

The gateway works on the fourth transport layer and above

Hubs are physical layer devices that transmit information in the form of Broadcasts.

A switch is a machine used for exchanging messages. Many for the link layer Equipment (two-layer switch), the ability to address learning, the use of storage and forwarding in the form of exchange of Messages.

One function of routers is to connect to different networks, and the other is to choose the route of information Transmission. Choose unobstructed shortcut, can greatly improve communication speed, reduce network system communication load, Save network system resources, Improve network system patency Rate.

The difference between a switch and a router

The switch has a very high bandwidth back bus and an internal switching matrix. All the ports on the switch are hooked up on this bus, and after the control circuit receives the packet, the processing port looks for the In-memory Address table to determine which port the NIC (nic) of the destination Mac (the hardware address of the network Card) is hooked on, and the internal switch fabric quickly transmits the packet to the destination Port. The destination MAC is broadcast to all ports if it does not exist, and after the receive Port responds the switch "learns" the new address and adds it to the internal MAC address Table.
Using a switch can also "segment" the network, by comparing the MAC address table, The switch only allows the necessary network traffic through the Switch. Through the filtering and forwarding of the switch, it can effectively isolate the broadcast storm, reduce the occurrence of the mistake packet and the error packet, avoid the sharing conflict.
The switch can transmit data between multiple port pairs at the same time. Each port can be treated as a separate network segment, and the network devices connected to it enjoy full bandwidth on their own without competing with other Devices. When node A sends data to node d, Node B can send data to node C at the same time, and the two transports all have their own virtual connection with all the bandwidth of the Network. If this is a 10Mbps Ethernet switch, then the total flow of the switch is equal to 2x10mbps=20mbps, and the total flow of a hub will not exceed 10Mbps when using the 10Mbps shared hub.
In a word, the switch is a kind of network device which can complete the packet forwarding function based on MAC address Recognition. The switch can "learn" the MAC address and store it in the internal address table, by establishing a temporary switching path between the originator of the data frame and the target receiver, so that the data frame is directly from the source address to the destination Site.

From the point of view of filtering network traffic, the role of routers is very similar to switches and Bridges. But unlike switches that work on the physical layer of the network, physically dividing the network segments, routers use specialized software protocols to logically divide the entire Network. For example, a router that supports an IP protocol can divide the network into multiple sub-segments, and only network traffic that points to a particular IP address can pass through the Router. For each packet received, the router recalculates its checksum value and writes a new physical address. As a result, it is often slower to use routers to forward and filter data than the switch that only looks at the physical address of the Packet. however, for those networks with complex structures, using routers can improve the overall efficiency of the Network. Another obvious advantage of routers is the ability to automatically filter Webcasts.

What is the difference between a hub and a router?  

First say hub, which is the hub. Its role can be simply understood as connecting some machines together to form a local area Network. A switch (aka interchange hub) acts in much the same way as a hub. But there is a difference in performance: the way the hub uses shared bandwidth, and the switch is Bandwidth-exclusive. In this way, when the machine is large or the amount of data is high, the two will be more obvious. The router and the above two have obvious difference, its function is to connect the different network segment and find the most suitable path of data transmission in the Network. Routers are generated after the switch, just as the switch is generated after the hub, so the router and the switch have a certain connection, not completely independent of the two Devices. Routers mainly overcome the inability of the switch to route forward Packets.  

in general, the main differences between routers and switches are shown in the following areas:  

(1) different working levels  
The initial switch is working at the data link layer, and the router is designed to work at the network layer at the Beginning. Because the switch works in the data link layer, It works relatively simple, and the router works at the network layer, can get more protocol information, the router can make a more intelligent forwarding Decision.  

(2) data forwarding is based on a different object   The
switch uses the physical address or MAC address to determine the destination address of the forwarded Data. The router uses the IP address to determine the address of the data forwarding. The IP address is implemented in the software and describes the network on which the device Resides. MAC addresses are usually hardware-brought, distributed by the manufacturer of the network card, and have been cured to the network card, which is generally non-changing. The IP address is usually assigned automatically by the network administrator or the System.  

(3) The traditional switch can only split the conflict domain, cannot split the broadcast domain, and the router can split the broadcast domain  
The network segment connected by the switch still belongs to the same broadcast domain, and the broadcast packet propagates across all network segments connected by the Switch. In some cases, traffic congestion and security vulnerabilities can Result. Network segments connected to routers are assigned to different broadcast domains, and broadcast data does not pass through the Router. Although the third layer above the switch has the VLAN function, may also divide the broadcast domain, but each sub-broadcast domain is unable to communicate the communication, the communication between them still needs the Router.  

(4) The router provides the service   of the firewall; the
router forwards only packets of a specific address, does not transmit packets that do not support routing protocols, and the transmission of unknown destination network packets, thus preventing broadcast Storms.

Physical Layer
In the OSI reference model, the physical layer (physical layer) is the lowest layer of the reference Model and the first layer of the OSI model.
The main function of the physical layer is to use the transmission medium to provide the physical connection to the data link layer, and realize the transparent transmission of the bit Stream.
The function of physical layer is to realize the transparent transmission of bitstream between neighboring computer nodes, and to shield the difference between specific transmission media and physical equipment as much as Possible. The data link layer above does not have to consider what the Network's specific transport media is. The "transparent transmit bitstream" indicates that the bit stream has not changed after the actual circuit is transmitted, and the circuit seems to be invisible to the transmitted bit Stream.

Data Link Layer
The data link layer, The second layer of the OSI model, is responsible for establishing and managing links between Nodes. The main function of this layer is: through various control protocols, the Error-prone physical channel becomes error-free and can reliably transmit data frame data Link.
The physical link is unreliable in the computer network due to the existence of various disturbances. therefore, The main function of this layer is to provide the physical layer on the basis of the bit stream, through the error control, flow control method, The error of the physical line into a error-free data link, that is, providing a reliable way to transfer data through physical MEDIA.
This layer is also typically divided into two sub-layers of media access control (MAC) and Logical link Control (LLC).

The main task of Mac Sub-layer is to solve the problem of multi-user channel competition in the shared network, and complete the access control of the network Media.

The main task of the LLC Sublayer is to establish and maintain network connections, perform error checking, flow control, and link Control.
The specific work of the data link layer is to receive data from the physical layer in the form of a bit stream, and encapsulate it into a frame and transfer it to the previous layer, as well as the data frames from the upper layers, which are disassembled into the physical layer, and are also responsible for processing the acknowledgement frames sent back by the receiving end to provide reliable data transfer.

Network layer
The network layer is the third layer of the OSI model, which is the most complex layer in the OSI Reference model and the highest level of communication subnets. It provides services to resource subnets on the basis of the next two Tiers. The main task is to select the most appropriate path for the message or packet through the communication subnet through the routing algorithm. This layer controls the forwarding of information between the data link layer and the transport layer, establishing, maintaining, and terminating the network Connection. specifically, data at the data link layer is converted to a packet at this level, and then the information is transferred from one network device to another via path selection, segment composition, sequence, and/or exit Control.
In general, the data link layer solves the communication between nodes in the same network, and the network layer mainly solves the communication between different subnets. For example, when communicating between wans, it is inevitable that routing (that is, there may be multiple paths between two nodes) is a choice problem.

The main issues that need to be addressed when implementing network layer functionality are as Follows:
Addressing: a physical address (such as a Mac Address) used in the data link layer solves only addressing problems within the Network. When communicating between different subnets, the devices in each subnet are assigned a unique address in order to identify and locate the devices in the Network. Because the physical technology used by each subnet may be different, this address should be a logical address (such as an IP address).
Exchange: specify different ways of exchanging information. The common switching technologies are: line switching technology and storage and forwarding technology, and the latter includes message exchange technology and packet switching technology.
Routing algorithm: when there are multiple paths between the source node and the destination node, this layer can select the best path for the data grouping by the network according to the routing algorithm, and transmit the information from the most suitable path from the sending side to the receiving end.
Connection service: Unlike data link layer traffic control, the former controls the traffic between neighboring nodes of the network, and the latter controls the traffic from the source node to the destination Node. The aim is to prevent blocking and to detect Errors.

Transport Layer
The main task of the OSI under Layer 3 is Data communication, and the 3-tier task is data processing. The transport layer (Transport Layer) is the 4th layer of the OSI model. therefore, This layer is the interface and bridge of communication subnet and resource subnet, which plays a connecting role.
The main task of this layer is to provide users with reliable end-to-end error and flow control to ensure the correct transmission of the Message. The function of the transport layer is to block the details of the lower layer data communication to the high level, i.e. transparently transmitting the message to the User. Common protocols for this layer are TCP protocols in tcp/ip, SPX in Novell networks, and Microsoft's Netbios/netbeui Protocol.
The transport layer provides a transport service between the session layer and the network layer, which obtains data from the session layer and, if necessary, splits the Data. The transport layer then passes the data to the network layer and ensures that the data is delivered correctly to the network Layer. therefore, The Transport layer is responsible for providing reliable transmission of data between two nodes, when the connection between the two nodes is determined, the transport layer is responsible for monitoring the Work. In summary, the main functions of the transport layer are as follows:
Transport Connection Management: provides the ability to establish, maintain, and dismantle transport connections. In the network layer, the transport layer provides the two services of "connection-oriented" and "non-link oriented" to the high level.
Handling transmission Errors: provides reliable "connection-oriented" and less reliable "non-connected" data transfer services, error control, and Flow Control. When providing a "connection-oriented" service, data transmitted through this layer will be confirmed by the target device and the data will be re-sent if no acknowledgement has been received within the specified Time.
Monitor Service Quality.
Session Layer
The session layer, the 5th layer of the OSI model, is the interface between the user application and the network, and the main task is to provide a method for establishing and using a connection to the presentation layer of two Entities. Connecting a presentation layer between different entities is called a Session. therefore, the task of the session layer is to organize and coordinate the communication between the two session processes and manage the data exchange.
The user can set up a session in half-duplex, simplex, and full duplex mode. When a session is established, the user must provide the remote address that they want to connect to. These addresses, unlike Mac (media access control Sub-layer) addresses or network layer logical addresses, are designed for users and are more user-friendly to remember. A domain name (DN) is a remote address used on a network for example: www.3721.com is a domain name. The specific functions of the session layer are as Follows:
Session Management: allows users to establish, maintain, and terminate sessions between two physical devices, and to support data exchange between THEM. For example, you can provide single-direction sessions or two-way simultaneous sessions, and manage the order of sending in a session, and the length of time that the session Takes.
Session Flow Control: provides session traffic control and Cross-session Functionality.
Addressing: establishing a session connection using a remote ADDRESS. L
Error control: The conversational layer is logically responsible for the establishment, maintenance, and termination of data exchange, but the actual work is to receive data from the transport layer and be responsible for correcting errors. Both session control and remote procedure calls belong to this layer of Functionality. It should be noted, however, that this layer checks for errors that are not errors in the communication media, but rather advanced errors such as disk space, printer paper, and so On.
Presentation Layer
The presentation layer (Presentation Layer) is the sixth layer of the OSI model, which interprets commands and data from the application layer, assigns meanings to the various grammars, and transmits them to the session layer in a certain format. Its main function is "handling the representation of user information, such as encoding, data format conversion and encryption and decryption". The specific functions of the presentation layer are as Follows:
Data format processing: negotiate and establish the format of data interchange to resolve differences in data format representations between Applications.
Encoding of Data: handles conversion of character sets and Numbers. For example, because data types in user programs (integer or real, signed or unsigned, etc.), user identities, and so on can be represented differently, there is a need to have the ability to convert between different character sets or formats between Devices.
Compression and decompression: in order to reduce the amount of data transferred, this layer is also responsible for data compression and Recovery.
Data encryption and decryption: can improve the security of the Network.

Application Layer
The application layer (application Layer) is the highest layer of the OSI reference model, which is the interface between the computer user and the various applications and networks, with the function of providing services directly to the user and accomplishing the various tasks that the user wishes to accomplish on the Network. Based on the other 6-tier work, it is responsible for completing the connection between the application and the network operating system in the network, establishing the connection with the end user, and completing various protocols such as the Network Service and the supervision, management and service required by the network Users. In addition, the layer is responsible for coordinating the work between the various applications.
The services and protocols that the application layer provides to users are: file services, directory services, file transfer Service (FTP), remote Login Service (telnet), e-mail service (email), Print service, Security service, network management service, database service, and so On. The various network services mentioned above are completed by different application protocols and programs of this layer, and the differences between different network operating systems in the functions, interfaces, implementation technologies, hardware support, security reliability and various application interfaces are very large. The main functions of the application layer are as Follows:
User interface: The application layer is a direct interface between the user and the network, and the application and the network, allowing the user to interact with the network interactively.
Implement a variety of services: the layer has a variety of applications that can complete and implement the various services requested by the User.

Summary of OSI7 layer model
Since OSI is an ideal model, the general network system involves only a few layers, and few systems can have all 7 layers and fully comply with its provisions.
In a 7-tier model, each layer provides a special network Function. From the point of view of the network function: the following 4 layers (physical layer, Data link layer, Network layer and transport layer) mainly provide data transmission and exchange functions, namely Node-to-node communication, the 4th layer as the upper and lower part of the bridge is the most critical part of the network architecture, and the upper 3 layer (session layer, The presentation layer and the application Layer) provide the information and data processing functions between the user and the Application. In short, the next 4 layers mainly complete the function of the communication subnet, the upper 3 layer mainly completes the function of the resource Subnet.

The following is a TCP/IP layered model
┌────------────┐┌─┬─┬─-┬─┬─-┬─┬─-┬─┬─-┬─┬─-┐
│││d│f│w│f│h│g│t│i│s│u││
│││n│i│h│t│t│o│e│r│m│s│ its │
│ Fourth floor, application layer ││s│n│o│p│t│p│l│c│t│e││
││││g│i││p│h│n││p│n││
││││e│s│││e│e│││e│ It │
││││r││││r│t│││t││
└───────------─┘└─┴─┴─-┴─┴─-┴─┴─-┴─┴─-┴─┴-─┘
┌───────-----─┐┌─────────-------┬──--------─────────┐
│ Third layer, Transport Layer ││tcp│udp│
└───────-----─┘└────────-------─┴──────────--------─┘
┌───────-----─┐┌───----──┬───---─┬────────-------──┐
││││icmp││
│ Layer two, ││└──---──┘│
│││ip│
└────────-----┘└────────────────────-------------─-┘
┌────────-----┐┌─────────-------┬──────--------─────┐
│ The first layer, network interface ││arp/rarp│ Other │
└────────------┘└─────────------┴─────--------──────┘
TCP/IP Four-layer Reference Model

The TCP/IP protocol is organized into four conceptual layers, with three layers corresponding to the corresponding layers in the ISO reference model. The ICP/IP protocol family does not contain the physical layer and the data link layer, so it cannot complete the function of the whole computer network system independently, and must work in conjunction with many other protocols.
The four protocol tiers of the TCP/IP tiered model perform the following functions, respectively:
First Layer: network interface layer
Includes protocols for collaborating on the transfer of IP data over existing network Media. In fact, the TCP/IP standard does not define the functions corresponding to the ISO data link layer and the physical layer. instead, it defines protocols such as Address Resolution Protocol (Resolution protocol,arp), which provides the interface between the data structure of the TCP/IP protocol and the actual physical hardware.
Second floor: the inter-network layer
The network layer corresponding to the OSI Seven-layer reference model. This layer contains IP protocol, RIP protocol (Routing Information Protocol, routing information protocol), which is responsible for the packing, addressing and routing of Data. It also includes the Inter-network Control Message Protocol (internet command message PROTOCOL,ICMP) to provide network diagnostic Information.
Layer Three: Transport Layer
The transport layer, which corresponds to the OSI Seven-layer reference model, provides two end-to-end communication Services. Where the TCP protocol (transmission Control PROTOCOL) provides reliable data flow transport services, The UDP protocol (use Datagram Protocol) provides unreliable user datagram Services.
Layer Fourth: Application Layer
The application layer and the expression layer corresponding to the OSI Seven-layer reference model. The Internet Application layer protocol includes finger, Whois, FTP (file transfer protocol), Gopher, HTTP (hypertext transfer protocol), telent (remote terminal protocol), SMTP (simple Mail transfer protocol), IRC (internet relay session), NNTP (network News Transfer Protocol) and so on, This is also the focus of this book will be discussed

Python network Programming-osi Seven-tier model detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.