Brother Bird's Linux private cuisine (server) Chapter II network basic concept

Source: Internet
Author: User
Tags ip number ping and traceroute

Brother Bird's Linux private cuisine (server)

@ (Study note) [linux| Markdown| Notes]

[TOC]

Chapter II Network basic Concept 2.1 What is a network? OSI Seven layer protocol
Layered Responsible for content
Layer 1
Physical layers Physical Layer
Because the network media can only transfer 0 and 1 of this bit string, so the physical layer must define the media device used voltage and signal, but also must understand the data frame into a bit string encoding method, finally connected to the physical media and transmit/receive bit string.
Layer 2
Data Link junction data-link layer
This layer is a very special class, because the bottom is the definition of the entity, and the upper layer is the definition of software encapsulation. So the second layer is divided into two sub-layers in the data conversion action. In the Partial Hardware Media section, the main responsibility is the Mac (Media Access Control), we call this data wrapped in a Mac frame, Mac is the network media can handle the main datagram wrap, which is eventually encoded by the physical layer into a bit string data. The MAC has to use the communication protocol to access the media, the most commonly used is the IEEE 802.3 Ethernet network protocol. For a detailed MAC and Ethernet network, refer to the following section for instructions.
As for the software-biased part is controlled by the logical link layer (logical link Control, LLC), mainly in multitasking from the upper layer of packet data (packet) and into the format of the MAC, responsible for the work including information exchange, traffic control, error processing and so on.
Layer 3
Network layer
This layer is what we are most interested in, because the IP (Internet Protocol) We are referring to is defined at this level. At the same time, it also defines the online establishment, termination and maintenance of the computer, data packet transmission path selection and so on, so the most important in this level, in addition to the IP, is the packet can reach the destination route concept!
Layer 4
Transport Layer Transport layers
This hierarchy defines the sending and receiving end of the online technology (such as TCP, UDP technology), including the packet format of the technology, data packet delivery, process control, transmission process detection and recovery re-transmission, etc., to ensure that each data packet can be correctly arrived at the destination.
Layer 5
Meeting Layer Session Layers
In this level, the main definition of the two-address link between the connection and hang-up, in addition, can also establish the application of the talk, provide other enhanced services such as network management, check-in and return, the control of talk and so on. If the transport layer is to determine whether the data packets can correctly reach the target, then the meeting layer is to determine the network services to establish online confirmation.
Layer 6
Presentation Layer Presentation Layers
The data format we make on the application does not necessarily conform to the standard encoding format of the network transmission! So, at this level, the main action is to convert (or re-encode) the data format from the local application into the standard format of the network, which is then handed over to the protocol of the bottom transport layer for processing. So, at this level, the main definition is the transformation of the data format between the Network Service (or program), including the addition and decryption of the data on this layer.
Layer 7
Application Tier Application Layer
The application layer itself is not owned by the application, but is a communication interface that defines how the application enters this layer to receive or transmit the data to the application, which is ultimately presented to the user.

TCP/IP protocol

How does TCP/IP work? We will take you often connected to the Yahoo portal to make a statement, the entire online status can be seen:

  1. Application phase: You open the browser, enter the URL column in the browser, press [Enter]. At this point, the URL column and related data will be wrapped into a browser data, and down to the TCP/IP application layer;
  2. Application layer: The HTTP communication protocol provided by the application layer, the data from the browser is reported, and given an application layer header, and then dropped to the transport layer: because HTTP is reliable online, the data is dropped into the TCP packet, and given a TCP packet header, to the network layer dropped;
  3. Network layer: The TCP package into the IP packet, and then give an IP header (mainly the source and destination IP), to the link layer dropped;
  4. Link layer: When using the Ethernet network, IP will be wrapped to the Mac frame according to CSMA/CD Standard, and give the MAC header, and then turn into a bit string, transfer media to the remote host.
2.2 TCP/IP link-layer-related protocols for WAN use devices
  • Traditional dial-up: PPP protocol
  • Integrated Service Digital Network (Integrated services, ISDN)
  • Asymmetric digital Circuit (asymmetric digital subscriber Line, ADSL): via PPPoE protocol
  • Cable modem (Cable modem)
Devices used by local area networks-Ethernet networks

Since the transmission of the network information is 0 and 1, so the data transmission units per second how many bit, that is, M bits/second, Mbps meaning.

when we see network providers (Internet Services Provider, ISPs) claiming that their ADSL transmission speeds can reach downstream/upstream 2mbps/128kbps (Kbits per second), that Kb is not Bytes, but bits oh ! So 2m/128k in the actual file size transfer speed above, the maximum theoretical transmission for 256KBPS/16 KBps (Kbytes per second), so the normal download speed about 100~200 Kbytes per second between! The same truth, in the network card or some network media advertising above, they will declare their products can automatically identify the transmission speed of 10/100 Mbps (mega-bits per second), hehe! this number will have to be divided by 8, which is the unit bytes of our commonly used file capacity calculation.

name Speed Network Line level
Ethernet Network (Ethernet) 10Mbps -
High Speed Ethernet network (Fast Ethernet) 100Mbps CAT 5
Ultra High Speed Ethernet network (Gigabit Ethernet) 1000Mbps CAT 5e/cat 6
Ethernet Network Transfer Protocol: CSMA/CD

MAC (Media Access Control)

Packaging format for MAC
    • MAC Frame for Ethernet network

MTU Maximum Transmission Unit

Through the definition of the above MAC package, we now know that the standard Ethernet frame can transmit the maximum amount of data can reach the bytes, this value is called the MTU (Maximum transmission Unit, the maximum transmission unit).

Hubs, switches and related mechanisms

The biggest difference between a switch and a hub is that there is a special memory in the exchanger that records the MAC address of each switch port and the PC to which it is connected, so that when the PC from both ends of the switch is transmitting data to each other, each frame will pass through the switch's memory directly. Data and transfer it to the target host! So switch is not a shared media, and the switch has a separate bandwidth for each port (port) Oh!

switch has overcome the problem of packet collisions because he has a switch port for MAC related functions

2.3 The composition and classification of IP addresses in the network layer-related packets and data IP packets of TCP/IP

192.168.0.0~192.168.0.255 this Class C Description: 11000000.10101000.00000000.0000000011000000.10101000.00000000.11111111|----------net_id---------|-host--|- In the example above, the first three groups of numbers (192.168.0) is the domain number, and the last group of numbers is called the host number . As for the same domain definition is "in the same physical network segment, the host IP has the same net_id, and has a unique host_id", then these IP groups are the same domain IP network segment!

    • net_id and host_id restrictions: In the same network segment, net_id is constant, and host_id is not repeatable, in addition, host_id in the binary notation, not both 0 and 1, because all 0 represents the address of the entire network segment (networ K IP), and all 1 represents the address of the broadcast (broadcast IP). For example,192.168.0.0 (host_id all 0) and 192.168.0.255 (host_id all 1) cannot be used as IP settings for the host in the network segment, which means that the IP is from 192.168.0.1 to 192.168.0.254;

    • Setting the different areas of the network in the same physical network segment, if the two hosts are set to different IP network segments, because of the different broadcast address, resulting in the inability to go online through the broadcast way. It's time to communicate through a router (router) to connect two domains together.

    • The IP is graded in decimal notation in five ways:

      Class a:0.xx.xx.xx ~ 127.xx.xx.xxclass b:128.xx.xx.xx ~ 191.xx.xx.xxclass c:192.xx.xx.xx ~ 223.xx.xx.xxclass d:224 . xx.xx.xx ~ 239.xx.xx.xxclass e:240.xx.xx.xx ~ 255.xx.xx.xx

Types of IP and how to obtain them
    • Private IP (IP)

      Class A:10.0.0.0-10.255.255.255class B:172.16.0.0-172.31.255.255class c:192.168.0.0-192.168.255.255

    • Special Loopback IP Network segment

      This network segment is 127.0.0.0/8 this Class A, and the default host (localhost) IP is 127.0.0.1

    • How IP is obtained

      • Direct manual setting (static)
      • Access through dial-up
      • Automatically get network parameters (DHCP)
2.3.4 Netmask, subnet with CIDR (classless interdomain Routing) Netmask, or Subnet mask (subnet mask)
  • netmask:255.255.255.0 <== domain definition, the most important parameter
  • network:192.168.0.0 <== First IP
  • broadcast:192.168.0.255 <== The last IP to be used to set the IP number of the host: 192.168.0.1 ~ 192.168.0.254
Sub-mesh Segmentation

The original C Class net_id and host_id respectively 11000000.10101000.00000000.00000000 Network: 192.168.0.011000000.10101000.00000000.11111111 broadcast:192.168.0.255|----------net_id---------|-host--|

What are the net_id and host_id after being cut into two subnets? 11000000.10101000.00000000.0 0000000 more than a net_id, for 0 (first subnet) 11000000.10101000.00000000.1 0000000 more than a net_id, for 1 (second subnets) |----------net_id-----------|-host--|

First subnet network:11000000.10101000.00000000.0 0000000 192.168.0.0broadcast:11000000.10101000.00000000.0 1111111 192.168.0.127 |----------net_id-----------|-host-| netmask:11111111.11111111.11111111.1 0000000 255.255.255.128

Second subnet network:11000000.10101000.00000000.1 0000000 192.168.0.128broadcast:11000000.10101000.00000000.1 1111111 192.168.0.255 |----------net_id-----------|-host-| netmask:11111111.11111111.11111111.1 0000000 255.255.255.128

Example: Try to calculate 172.16.0.0, but net_id occupies 23 bits, this domain Netmask, network, broadcast and other parameters a: Because 172.16.xxx.xxx is in class B hierarchy, that is net_id It's 16-bit. But the title of the net_id took up 23 bits Oh! And so the host_id borrowed (23-16) 7 bits used in net_id. So the address of the entire IP becomes this: preset: 172. 0000000 0.00000000 |----net_id--------------|--host---| network:172. 0000000 0.00000000 172.16.0.0broadcast:172. 0000000 1.11111111 172.16.1.255netmask:11111111.11111111.1111111 0.00000000 255.255.254.0

Routing Concepts
    1. Query IP packet Destination IP address: When the PC01 has IP packets to be transmitted, the main opportunity to check the IP packet header of the destination IP address;

    2. Whether the query is located in the local domain of the router settings: PC01 main opportunity to analyze their own routing table, when the target IP and native IP net_id is found to be the same (same domain), then the PC01 directly through the LAN function, the data directly to the destination host.

    3. Query preset route (default gateway): But in this case, PC01 and PC11 are not the same domain, so PC01 will analyze the routing table for other matching routing settings, and if not, send the IP packet directly to the default router (default gate Way), in this case the default gateway is Server a.

    4. After sending the packet to the gateway, the packet flow is ignored: When the IP is sent to Server A by PC01, PC01 ignores the work that follows. When Server A receives the packet, it also analyzes its own routing information based on the above process, and then proceeds back to the correct destination host.

Tips:gateway/router: the gateway/router function is to be responsible for packet forwarding (IP Forwarding) between different domains, because the router has the function of IP Forwarding, and has the ability to manage routing, Therefore, the ability to transmit packets from different domains can be forwarded. In addition, your host and your host set the Gateway must be in the same network segment Oh!

Observing host routes: route

[[email protected] ~]# route [-n]

Options and Parameters:-N: Displays the hostname as IP

IP and MAC: The ARP and RARP protocol for the link layer

ARP (address Resolution Protocol, network addresses resolution) protocol Rarp (revers ARP, reverse network address resolution)

How to get your own native network card number (MAC):

[[email protected] ~]# ifconfig eth0

Get the IP/MAC corresponding data in the ARP table in this machine

[[email protected] ~]# arp -[nd] hostname

[[email protected] ~]# arp -s hostname(IP) Hardware_address

Options and Parameters:-N: Displays the hostname as an IP type-D: Removes the hostname hardware_address from the ARP table: sets the MAC of an IP or hostname to the ARP table

Example one: List the ARP table corresponding to the IP/MAC on the current host

[[email protected] ~]# arp -n

Address hwtype hwaddress Flags Mask Iface192.168.1.100 ether 00:01:03:01:02:03 C eth0192.168.1.240 ether 00:01:03:01:de:0 A c eth0192.168.1.254 ether 00:01:03:55:74:ab C eth0

Example two: Write the NIC card number of the 192.168.1.100 host directly into the ARP table

[[email protected] ~]# arp -s 192.168.1.100 01:00:2D:23:A1:0E

The purpose of this instruction is to establish a static ARP

ICMP protocol

The full name of ICMP is "Internet Control message Protocol, Internet Message Control Protocol"

So how do we use ICMP to verify the state of the network? The simplest instruction is to Ping and traceroute , and these two instructions can be used to verify and repay the status of the network host through the assistance of an ICMP packet.

2.4 TCP/IP Transport Layer-related packets and data

The transport layer has two key points, one is a connection-oriented TCP packet, and a non-connection-oriented UDP packet

TCP protocol for reliable online

The correlation between the packages

Three-direction AC grip of TCP

Non-connection-oriented UDP protocol

the full name of UDP is: "User Datagram Protocol, subscriber Data Flow Protocol", UDP is not the same as TCP, UDP does not provide a reliable transmission mode, because he is not a connection-oriented mechanism, because in the transmission process of UDP, the receiving end in the acceptance of the After the packet is not replied to the response packet (ACK) to the sending side, so the packet does not have a stricter check mechanism like TCP packets.

Network Firewall with OSI Layer Seven protocol 2.5 pre-Internet preparation for Internet access with IP? Host name online? DNS system?

This hostname (HOSTNAME) corresponds to the IP of the system, is the dingding known Domain Name System (DNS) ! In Linux, the DNS host IP is set in the/etc/resolv.conf file.

Brother Bird's Linux private cuisine (server) Chapter II network basic concept

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.