Data transmission / reception and protocol stack

Ask the OS protocol stack to send a message

Overview of data transmission and reception

When requesting message transmission / reception operation to the OS protocol stack, call it in the order determined by the program parts of the Soket library. The HTTP message sent to the Web server is digital data. To transmit and receive digital data is not limited to browsers, it is common to all applications that use the network. This behavior applies not only to the Web but also to the IP address by using the DNS server as described above and to all network applications.

Image of data transmission / reception operation using TCO protocol

When sending and receiving data, it is necessary to connect lines between them (like lines) before and after sending / receiving operations. Make a socket (Soket) at the entrance and exit of the line and connect them. First make a socket on the server side and wait for the client side to connect the line to that socket. Then, the client side also creates a socket, extends the line from the socket and connects to the server side socket. When they are connected, data is bidirectionally exchanged in such a manner that data is thrown into the socket. After the transmission / reception operation is completed, release the connection. When connecting, it is connected from the client side to the server side, but in principle it can be removed from either side when releasing the connection, but the actual order is decided by the application rule. (Disconnection Phase) When the connection is released, the socket is deleted and the communication operation is terminated.

 

Phase of data transmission / reception operation

  • Make a socket (socket creation phase)
  • Connect pipes to server side socket (connection phase)
  • Send and receive data (transmission / reception phase)
  • Remove the pipe and delete the socket (cutting phase)

It is the protocol stack inside the OS that executes these four phases. The browser requests this protocol stack to connect, and sends and receives data. In addition, while the request operation calls and executes a program part contained in the socket library, the socket library, which is a program part for data transmission and reception, only serves as an intermediary for conveying the content requested by the application as it is to the protocol stack, No substantive work is done. It is the protocol stack inside the OS that executes these four phases. The browser requests this protocol stack to connect, and sends and receives data. In addition, while the request operation calls and executes a program part contained in the socket library, the socket library, which is a program part for data transmission and reception, only serves as an intermediary for conveying the content requested by the application as it is to the protocol stack, No substantive work is done.

Create phase to make socket

In the operation of an application program (referring to a browser) requesting data transmission / reception, first, a program part of the Soket library is designated, and some of the parts are called in a predetermined order. After calling the Soket library, control transfers to it, executes the operation of creating a socket, and control is returned to the application program (browser) when it is completed.

descriptor

When a socket is created, a descriptor is returned, so the application (browser) receives it and returns it to memory. Disk preprators are used to identify sockets. For example, when two or more windows are opened in a browser to access a plurality of web servers, a plurality of sockets are required for transmitting and receiving a plurality of data. There will be multiple sockets on one computer and each must be identified. A descriptor is required at that time. A descriptor is like a number assigned to each socket. At the time of sending and receiving data, if the socket has a descriptor (number), the protocol stack can immediately determine which socket to send and receive. An application program (browser) is like a number tag called “disc player” and identifies a socket.

Connect pipes to server side socket (connection phase)

When the socket is completed, ask the protocol stack to connect to the server side socket. The application (browser) executes this requesting operation by calling a program part “connect” of the Soket library. connect (Soket library): Manipulate the IP address and port number of the descriptor server.

 
 
descriptor

The descriptor returned when the socket is created is notified to the protocol stack by connect. The protocol stack refers to the notified descriptor, judges which socket is to be connected to the socket on the server side, and executes the connection operation.

IP address

The IP address here is the IP address of the access target server examined by querying the DNS server. When data transmission / reception is executed, it is necessary to notify the protocol stack of the IP address of the partner to send and receive.

port number

IP addresses are assigned different values ​​to each computer in order to identify individual computers existing on the network. So, it is up to which computer on the network you can specify the IP address. The descriptor is passed to the application (browser) that requested the creation of the socket, and it is not to pass it directly to the connection partner. So you do not know the port number value on the connection partner side. (The client side socket’s descriptor is unknown to the client) A disk preter is used to identify a socket inside one computer, whereas a port number is a mechanism used when identifying a socket from a connection partner. It is a premise that the port number on the server side is predetermined. (80 for Web, 25 for mail) The rules for port numbers are unified throughout the world and are centrally managed so that they do not overlap with others like IP addresses.

 It is managed by the institution called IANA (Internet Assigned Number Authority).
  • Descriptor: An application (browser) managing a socket
  • IP address and port number: Identifying the socket of the other party between client and server

Send and receive data (transmission / reception phase)

Once the socket is connected to the other side, data exchange becomes possible. Application (browser) can not touch direct socket, so ask the protocol stack to send and receive via Soket library. Therefore, a program part “write” is used.

 
write (Soket library)

First, the application prepares the transmission data in the memory. Based on the URL entered by the user, the HTTP request message becomes transmission data. When the application (browser) calls “write”, it specifies the descriptor and transmission data. Then, the protocol stack transmits the transmission data to the server. Since the connected party is recorded in the socket, simply specifying the socket with the descriptor will make the destination of the transmission known and send the data. After checking the contents of the data by executing the receiving operation, the server executes processing and returns a response message.

read (Soket library)

In the operation of receiving the response message, the protocol stack is requested to receive operation via the program part “read” of the Soket library. At that time, a memory area for storing the received response message is specified. This memory area is called “reception buffer”. The response message is received by read and stored in the receiving buffer. Since the reception buffer is a memory area prepared inside the application (browser), when the message is stored in the reception buffer, the message is passed to the application (browser).  Remove the pipe and delete the socket (cutting phase)

When the browser finishes receiving the data, the transmission / reception operation ends. At that time, if you ask the program component called “close” of the Soket library to enter the disconnection phase, the connection between the sockets is also broken and the socket is also deleted.

close (Soket library)

With the HTTP protocol used on the Web, originally, when the response message is sent, the disconnection operation is to be executed from the Web server side. (The client may be the first) When the Web server side calls close and disconnects, the socket on the client side enters the disconnection phase. There, when the browser performs a receiving operation by reading, read notifies the browser that transmission / reception is terminated and disconnection, instead of passing the received data. Since it can be determined by this operation that the transmission / reception is completed, at the same time, the browser also calls close to enter the disconnection phase.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *