Windows Network Programming Chapter 2 Winsock Design Study Notes

Source: Internet
Author: User
Windows Network Programming 2nd Edition Chapter 2 Winsock Design Notes

1. System architecture. First, see the architecture diagram in Attachment 1. Under ws2_32.dll, it is divided into multiple layers to manage their respective tasks. In WinSock, the so-called provider refers to the packaging of different protocol implementations. For example, TCP has a TCP provider, based on our Winsock code, specify the required protocol when creating the socket to select different providers to provide services for our program. As shown in the figure, the provider is divided into two types: Base and layered. In my understanding, the base provider is the most basic implementation of the protocol, as mentioned above; the layered provider is a theme of the base provider architecture under ws2_32.dll according to the description in the book, it can intercept and manipulate all socket operations. For more information, see Chapter 12th.

2. in the provider, there is something on the kernel layer, and in the lowest layer, of course, it is the specific implementation of the Protocol, such as TCP/IP, but the implementation of these protocols, there is no socket-like calling interface, instead of the TDI interface, which is used to better decouple from upper-layer applications. In this case, there must be something to assume the role of coordinator, which is to implement the Windows Socket Kernel Mode Driver (AFD in the previous layer in the underlying driver. sys), the driver is responsible for the maintenance of connection and buffer, and provides a socket interface to upper-layer applications. At the same time, he is also responsible for communication and dialogue with the underlying layer of the TDI interface.

3. Protocol features. This Section classifies and describes network communication protocols according to certain standards. This section does not introduce TCP or UDP, but classifies the protocol based on its characteristics.

(1) message-oriented
See Appendix 2. The so-called message-type network communication has the biggest feature of "preserving message boundaries", which can be seen from the figure in Attachment 2. Send 128, 64, and 32 data respectively, and the other party also receives the three packages. UDP is a similar protocol, and the previous one mentioned appletalk. It is based on the message protocol and supports partial message.

(2) stream-oriented
See Appendix 3. The biggest difference between streaming and message types is that the data is not retained. That is to say, when we accept the data requested, it returns as much data as possible. There is no boundary or cut between the data and the data. The same is true for the sender. In the stream protocol, some data is not sent immediately, but when the buffer reaches a certain level, or after a long time, all data is sent out at a time. In terms of acceptance, the same is true. ACCEPT returns as much data as possible. Therefore, we can see from the figure in Attachment 3 that the data after the sending is merged and sent together, and the acceptance is to accept all the data at one time. The typical stream protocol is TCP, which is used to transmit data well. However, when a large amount of small data is transmitted, the stream Protocol obviously has inherent problems, because every time the data is processed with an error check, it brings additional overhead.

(3) pseudo stream
As the name suggests, we can know that this is a message-based transmission method, but with the stream feature. Merging the right half of the left half of the image and the right half of the image in the Appendix 3 is a feature of this Protocol. Send or independently send separate messages, which can be fully received at one time.

(4) connection-oriented and connectionless, reliability and ordering, Grace close the content in Chapter 1 has been discussed.

(5) broadcast data.
Broadcast data only applies to the connectionless protocol, because each machine on the network will receive data. Broadcast efficiency is low, and each machine needs to check data, resulting in additional costs.

(6) multicast data
Multicast Data is particularly useful in video conferencing. It is a source that can send data to multiple people at the same time, but not broadcast. In IP-based protocols, multicast is a modification to broadcast. First, there is an IP address dedicated for multicast in the IP address segment, each process/program that wishes to send or receive multicast data needs to apply to join a multicast group bound to a specific multicast IP address, and then send the message to this group, each program that joins the multicast group can receive the message. In fact, when adding multicast groups to each machine, a filter is set on the NIC to implement the above functions. Multicast has a special description in Chapter 9.

(7) Quality of server (QOS)
This is also very interesting. QoS is an application capability that can apply for a fixed part of the network bandwidth for specific purposes. The actual example is on-demand video. In the past, apsaravideo for VOD had to slow down some of the data. When the network data could not meet the requirements, the data in the buffer should be played first and the buffer should be filled as much as possible. Of course, this is on the Internet. If we are in a specific network, we can use QoS based on the network bandwidth required by Vod, we can retain part of the bandwidth of the network for VOD. In this way, theoretically, we do not need any buffer during Vod. Chapter 10 describes QoS in detail.

(8) partial messages
As mentioned in chapter 1, the advantage of using partial message is that it can return some data. In the Protocol that does not support partial message, when some data arrives, it cannot be retrieved from the application. Only when all the data arrives can it be retrieved from the application, if some problems occur on the network or the remaining data cannot be reached for some reason, for the protocol that does not support partial message, some data that has been received will be discarded during timeout, and the application will not receive any data.

(9) routing considerations
Netbeui is the only protocol currently supported by Winsock that does not use routing.

4. Winsock catalog. This section describes the wsaenumprotocols function, which can be used to list all the protocols supported by Winsock and the specific information of the Protocol (such as supporting data ordering and the maximum transmission size ). On this basis, we have made an in-depth introduction to the socket function. When using the socket function of WinSock 1.1, we must specify the Protocol features and protocols:

Sockets;
S = socket (af_inet, sock_stream, ipproto_tcp );

For example, we specify the stream and use the TCP protocol.

However, if some providers share the same protocol features and protocols, that is to say, if multiple providers implement the same protocol, then the socket function cannot implement this function. For example, RSVP provider can provide QoS on TCP and UDP. In this way, the provider cannot be constructed using the socket function. (In fact, more often, the socket we create is a provider, which is the provider selected by Winsock based on the parameters given when we create the socket ). In this case, the wsasocket function is useful.

For more information, see the original article of this section. To be honest, I don't know how to understand this section. If I see a specific chapter later, I may look back at it.

 

 

 

 

 

 

 

Related Article

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.