Learning nfs/NIS 2nd Reading Notes-Chapter1 network fundamentals

Source: Internet
Author: User
Learning nfs nis 2nd Edition notes

1. For a layer-7 model, see Appendix 1.

From the figure in Attachment 1, we can see that the different networks we have seen are all on the data link layer, such as Ethernet, Token network, or X.25, it has nothing to do with the physical layer. The physical layer is only different from the transmission media. For example, the token network can also run on five cat-5e twisted pair wires. As we can see later, because data link is responsible for filling the MAC address, packaging and organizing data in packets mode, and calculating checksum, different networks are different on this layer.

In addition, we can also see that RPC is based on the above layer of TCP/IP. We often say that NFS is based on RPC, so now we can understand that, NFS encoding is based on rpc APIs, while our commonly used connect and socket APIs are all TCP/IP. Therefore, our programs are based on TCP, UDP, and IP, NFS uses RPC.

=============== Physical layer and data link layer ================================

1. let's see physical layer and data link layer. the two layers are used to define the network interface of a machine. From the software perspective, the network interface defines how the machine sends data to or receives data from the network through the adapter. The data link layer defines how the bits to be sent can be converted into manageable chucks of data. Data Link Layer defines how to format data. In this layer, a set of data is defined by specifying the begin and end to form a network frame. This is what we usually call a packet. in addition, the data link layer adds checksum information, MAC addresses of source and destination, and other information to packet. Depending on the physical layer transmission media, the maximum packet size generated by the data link layer encoding is also different (because the excessive packet cannot be transmitted on the physical media ), the maximum capacity (size) that a packet can accept is what we call MTU (maximum transmission unit ).

2. loopback interface. For a loopback interface, if the data link layer finds that the data is sent to loopback, it will directly put the data to the bottom of the local "Accept data" protocol stack queue, it seems that the data is received from the network.

3. When data is transferred in layer-7 mode, each layer adds its own information to this data layer by layer envelop. After arriving at the destination, the data layer is unlocked.

4. ethernet address -- MAC address. Mac is 48bit. The first 24 bits are used to identify a hardware vendor, and the last 24 bits are used to mark the vendor. If a MAC address is FF: FF, it indicates a broadcast address. If the MAC address of destination is displayed on all machines, the data will be received.

============= Network layer ==============================

1. Concepts rams and packets. These two terms can be used in the Ethernet many times. However, there are some differences. datax is a term in the network layer, while packets is a term in the data link layer. At the network layer, we call Chuck of Data datax, but we all know that there are MTU restrictions on the data link layer. Therefore, when the data size in the network layer is greater than MTU, it is necessary to divide and encode the data. When the destination network layer is reached, the data is combined Based on the encoding. The process of data segmentation is called fragmentation. it can be seen that the performance of an MTU network is very poor, because many datapostrophes need to be separated before transmission.

2. IP address and MAC address. the difference is that ARP (Address Resolution Protocol) is used to convert an IP address to a MAC address, because for the data link layer, he only knows the MAC address. When a host wants to change an IP address to a MAC address, it sends an ARP request broadcast, the host whose IP address meets the requirements will send its MAC address to the sender.

3. Explain the IPv4 and IPv6 addresses. If you have any questions, let's review these two sections. What we usually know is clear and meaningless.

=========== Transport layer ================================
1. the transport layer has two main tasks: Split the user-sized data buffer into layer-sized writable rams acceptable to the network layer. The second task adopts some mechanisms, ensure transmission reliability (TCP ).

=========== Session and presentation layer =================================
1. Session and presentation layer define the establishment of a network connection and its lifecycle. Sessions can be established on any supported transmission protocol, such as TCP or UDP. For example, we can use TCP when using login and UDP when broadcasting information. The session protocol used by NFS and NIS is RPC.

2. The main purpose of RPC is to allow a process to call a remote call like procedure of a local process. RPC will package a procedure parameter list into a datax, and then send it to the target machine. The process on the target machine unpacks, executes the function, and then returns the result (procedure's return) package and send it back to the client. See the figure for details

Appendix 2

3. In many cases, RPC is implemented using UDP, because generally function calls are short and fast, and UDP is suitable. However, RPC does some work to make up for these defects because UDP cannot guarantee the order of packets arriving at the destination or whether packets can be reached. For example, add enough context information to the sending information to ensure that the recipient knows what the package is and which function to call after receiving the package.

4. All RPC calls will set the timeout time. If no response is received after the timeout time expires, the client program will perform the defined action, such as retry or try another server.

5. presentation layer -- External data representation. generally speaking, the presentation layer does not need to exist, because if byte is transmitted over the network, the content client and server of the byte can agree with each other. However, this presentation layer is required in some cases. The most typical case is rpc. As mentioned above, we may package and transmit a precedure argument, which may be a type of data, such as int, structure, instead of byte, the problem arises. If the client and server are in a heterogeneous system, different compilers, different floating point representation methods, and different array and string representation methods, in this case, the type of data that the client sends to the server cannot be decompressed correctly after it arrives at the server. This is where the presentation layer appears. It can unify the data to meet the above requirements. XDR (external data representation) is the presentation layer protocol used by NFS/NIS. This is a protocol developed by Sun. It will convert the client and server data into a unified format-canonical form, thus solving the above problem. Again, if the client and server transmit things in byte form, it is completely unnecessary to presentation layer.

6. Now we can understand that NFS/NIS, as the top application, uses XDR and RPC to complete their work.

============= Internet and RPC server configuration ====================================
1. XDR and RPC are very useful for an application that needs to transmit data structures over the network. Each RPC request contains all the required information, which is encoded in XDR mode, just like a local procedure to obtain the parameter list. RPC often uses connectionless connections because many RPC services are short and fast. In contrast, some applications, such as telnet or FTP, need connection-oriented, and the client and server communicate with each other using pre-defined byte order. They do not need to use RPC or XDR. Of course, it doesn't mean that RPC has to work in the connectionless environment. In fact, RPC can run over TCP. For example, many operations in NIS are based on UDP, but for example, to transmit a database, in this case, RPC uses TCP. NFS supports TCP and UDP.

2. as an RPC server, its only task is to make different function calls to different procedure requests. Therefore, RPC server can be made into a single thread (only one request can be processed at the same time ), it can also be made into multiple threads with better performance.

3. RPC does not use a pre-defined port. Instead, RPC defines a list in the/etc/RPC file by using a service number, this List defines the list of RPC servers and the service number of each Service (this is clearly for the client ). For example, NFS defines a bunch of RPC service lists, such as read block, write block, and create file. However, at the underlying layer, the RPC service still needs to use TCP/UDP port number. Therefore, Portmapper is born and can translate an RPC service number into a port number. When an RPC server is initialized, it registers the services it can provide with portmapper. A request from an RPC client will first deal with Portmapper, so as to know the address and corresponding port of the relevant RPC server, and then communicate with the RPC server; there is another way, the RPC client delegates the entire request to Portmapper, allowing Portmapper to complete related tasks. Therefore, either method requires that Portmapper running be normal. Therefore, to make nfs/NIS ineffective, simply remove the portmapper process.

=========== Socket RPC and Transport Independent RPC =========================
1. RPC originally worked on the socket, but there are also exceptions, such as RPC on Solaris, called the TI-RPC (Transport Independent RPC ). The motivation for developing this TI-RPC is that sun may have thought that the OSI network model may squeeze out the TCP/IP network in the future, they think it's a transport-independent RPC, which is the TI-RPC and now supports it on Solaris. On Solaris,/etc/netconfig is a configuration file for the TI-RPC.

After reading this chapter, I have gained a lot. I feel that Sun's NFS and NIS development requires RPC and XDR, instead of byte, and defines the frontend and backend communication protocols. For example:
1. when RPC and XDR are used, the Code logic at the communication layer is similar to the business logic. If the byte method is used, different business actions must be filled with different byte sequences, this is obviously not enough for graceful.
2. by using RPC and XDR, the client and server are well separated. Everyone performs their respective duties and does not need to change the communication code of the client or server, both the client and server can independently modify the logic code of their related functions. If you use the byte method, once there is a change, it is very troublesome to change the content sent by byte. As we all know, in network communication programs, the most feared is the change of communication protocols. RPC and XDR are adopted, just like the development of standalone programs. Function interfaces are well defined, free coding.

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.