TCP/IP Study Notes (4)

Source: Internet
Author: User
Tags ranges

TCP/IP Study Notes (4)

1. UDP protocol

UDP is a simple datagram-oriented transport layer protocol. Each output operation of a process generates a UDP datagram and assembles it into an IP datagram to be sent. UDP does not provide reliability.
UDP encapsulation format:
 

IP header (20) UDP header (8) UDP data

1. UDP header:
 

16-bit source port number 16-bit destination port number
16-bit UDP Length 16-bit UDP check
Data (if any)

The port number indicates the process of sending and receiving.
The UDP length field refers to the byte length of the UDP header and UDP data. The minimum value of this field is 8, indicating no data. This length does not include the IP header length.
The UDP test includes the test of UDP header and UDP data. Because the length of UDP datagram can be an odd number, the padding byte 0 is added at the end of the calculation. This is only for testing and calculation.

2. UDP Verification

Both UDP and TCP headers contain a 12-byte pseudo header, which contains the IP header and its own fields, and is mainly set for calculation check and. The pseudo header does not occupy the actual space. The pseudo-header contains some fields of the IP header, so that UDP checks whether the data has arrived at the destination twice and whether the IP layer has correctly transmitted the data.
The format of the UDP pseudo header is as follows:
 

32-bit source IP address
32-bit destination IP address
0 8-bit protocol (17) 16-bit UDP Length
16-bit Source Port 16-bit destination port
16-bit UDP Length 16-bit UDP check
Data (if any)

The first 12 bytes are the pseudo-header of UDP.

Note:: The length of UDP datagram occurs twice during the test and calculation. If the test result is 0, the saved value is 1 (65535). If the transfer test is 0, it indicates that the sending end has no calculation test. If an error occurs, the message is discarded and no error message is generated.

3. IP sharding

When any IP layer receives an IP data report, it must determine which interface to send data to and query the MTU of the interface. The IP address compares the MTU length with the datagram length, and fragment if necessary. Fragments can occur on the original sender host or on the intermediate router. After the IP datagram is sharded, It is reloaded only after it reaches the target host.
Fields related to the IP address header and fragment:

  • (1) Each IP datagram has an ID field that is copied to each slice.
  • (2) The flag field uses one bit to represent "more slices". except the last one, each part must be set to 1.
  • (3) The offset field refers to the position at the beginning of the offset of the original datagram.
  • (4) After the datagram is split, the total length of each piece should be changed to the length value of the piece.
  • (5) a bit in the flag field indicates "not sharding". If this bit is 1, the IP address will not partition the datagram.

If an IP address reports that a piece of data is lost, the whole data packet must be re-transmitted. Why? Because the IP layer does not have a mechanism for timeout retransmission, the higher level must be responsible for timeout retransmission.

4. ICMP inaccessibility error (sharding required)

When a vro receives a packet that requires sharding, it sets a flag of No-sharding (DF) in the IP address header. This error can be used to determine the minimum MTU on the route to the target end.
The message format is as follows:
 

Type 3 Code 4 Inspection
Reserved, must be 0 Next stop MTU
The first eight digits of data in the IP header + original IP Datagram

You can use traceroute to determine the path MTU. The task is to send the group and set the "not sharding" flag. The length of the first group sent is exactly the same as that of the egress MTU. Each time an ICMP "fragment not allowed" error is received, the length of the group is reduced. If the ICMP error message sent by the router is in the preceding format and contains the exported MTU, the MTU value is used for transmission. Otherwise, the next minimum MTU value is used for transmission. The number of MTU values is limited, so you can obtain the path MTU.

5. UDP Server Design:

  • (1) Customer IP address and port number: the IP header includes the source and destination IP addresses, and the UDP header includes the port numbers of the remote and destination terminals.
  • (2) Destination IP address
  • (3) UDP input queue: Generally, each UDP port used by the program is associated with a limited number of input queues. That is, requests that arrive almost simultaneously from different customers will be automatically queued by UDP, And the received UDP data reports will be delivered to the application in the order of receipt.
  • (4) Local IP address restriction: Most UDP servers enable the local IP address to have a wildcard character when creating a UDP port, indicating that if the UDP datagram is entered, you can receive it on any local interface. If this port is set to the port number of an interface, only the UDP datagram sent to this interface can be received. You can start multiple servers on the same port. For example, one server over Ethernet and one server over Ethernet broadcast.
  • (5) remote IP address restriction: UDP can also be set to receive only UDP datagram of the specified IP address and port number.

Ii. Broadcast

  • 1. Restricted broadcast: The restricted broadcast address is 255.255.255.255. This address is used for IP address datagram during host configuration. At this time, the host may not know the network mask of its network, even its IP address is unknown. In any case, the vro does not forward a datagram whose destination address is a restricted broadcast address. Such a datagram only appears in the local network.
  • 2. Broadcast pointing to the network: The broadcast address pointing to the network is the address with the host number all being 1, and the broadcast address of Class A network is netid.255.255.255, where netid is the network number of Class.
  • 3. subnet-specific broadcast: the broadcast address pointing to the subnet is the address with the host number all being 1. The subnet mask must be known as the IP address directly broadcasted by the subnet. If the subnet mask of Network B 128.1 is 255.255.255.0, 128.1.2.255 is the broadcast address of the corresponding subnet.
  • 4. Broadcast pointing to all subnets: Broadcast pointing to all subnets also needs to know the subnet mask of the target network. The subnet numbers and host numbers of these broadcast addresses are all 1. If the destination subnet mask is 255.255.255.0, the IP address 128.1.255.255 is a broadcast address pointing to all subnets.

Iii. Multicast
IP multicast mainly sends data to multiple destinations, and the boot guide service can be determined when the diskless workstation starts. The multi-blog address is a Class D address in the following format:
 

1 1 1 0 28-bit multicast group ID

1. the multicast address consists of up to four multicast group numbers in the 1110 region:
The range is 224.0.0.0 to 239.20.255. A host group is a set of hosts that can receive data sent to a specific multicast group address. A host group can span multiple networks. Members in the Host group can join or leave the Host group at any time. There is no limit on the number of hosts in the Host group, and hosts that do not belong to a host group can send information to the Group.
Some multicast addresses are well-known addresses:

224.0.0.1-all system groups in the mainland of the subnet 224.0.0.2-All vro groups in the mainland of the subnet 224.0.1.1-dogfight Application of Network Time Protocol NTP224.0.0.9-RIP2224.0.1.2-SGI Company

2. Convert multicast addresses to Ethernet addresses:
Iana has an ethernet address block, that is, the 24-bit high is 00-00-5e, which means that the address range of the block is from 00-00-5e-00-00-00 to 00-00-5e-ff-ff-ff. Iana generally assigns multicast addresses. To specify a multicast address, the first byte of any ethernet address must be 01, which means that the ethernet address corresponding to IP multicast ranges from 01-00-5e-00-00-00 to 01-00-5e-7f-ff-ff.
This Address Allocation maps the 23-bit Ethernet multicast address to the IP multicast group number by ing the 23-bit low in the multicast group number to the 23-bit lower in the ethernet address.
The maximum five digits in the multicast group number are ignored during the ing process. Therefore, the multicast group corresponding to each Ethernet multicast address is not unique, 32 different multicast group numbers are mapped to one ethernet address. For example, the multicast address 224.128.64.32 (hexadecimal e0-80-40-20) and 224.0.64.32 (hexadecimal e0-00-40-20) are mapped to the same ethernet address 01-00-5e-00-40-20.
Since address ing is not unique, the device driver layer or IP layer must filter the datagram because the NIC may receive multicast data frames that the host does not want to receive.

Iv. IGMP: Internet Group Management Protocol

IGMP allows all systems on a physical network to know the broadcast group where the host is currently located. Multicast routers need this information to know the interfaces to which multicast data packets should be forwarded. IGMP is also considered as part of the IP layer. IGMP packets are transmitted through IP datagram. The message format is as follows:

4-digit version 1 4-digit type (1-2) Unused Inspection
32-bit group address (Class d ip address)

IGMP type bit 1 indicates a query packet sent by the multicast router. If it is set to 2, it indicates a report packet sent by the host.
The verification and calculation are the same as those of the ICMP protocol.
The Group address is a Class d ip address, the Group address is set to 0 in the query message, and the Group address in the report is the group address to participate in.

1. Join a multicast group

A process can join a multicast group on a given interface in some way, and the process can also leave the multicast group that was previously added. A process can be added to the same multicast group on multiple interfaces. The host identifies a multicast group through the Group address and interface. The host must keep a table that contains the number of processes in multicast groups and multicast groups that contain at least one process.

2. IGMP report and query
Multicast routers use IGMP packets to record the changes of group members in the networks connected to the vro. The rules are as follows:

  • (1) When the first process is added to the group, the host sends an IGMP report. If multiple processes of the host are added to the same group, only one IGMP report is sent. This report is sent to the same interface where the process joins the group.
  • (2) When a process leaves a group, the host does not send an IGMP report, even if the last process in the group leaves. After the host knows that the group is no longer in the specified group, it will not send report packets in subsequent IGMP queries.
  • (3) The multicast router regularly sends an IGMP query to check whether there are any multicast group processes contained in the routing package. The multicast router must send an IGMP query to each interface. Because the router wants the host to return a report for each multicast group it joins, the Group address in the IGMP query packet is set to 0.
  • (4) The host sends an IGMP report to respond to an IGMP query, and sends an IGMP report back to each group that contains at least one process.

3. Implementation Details

  • (1) When a host sends an IGMP report for the first time, it is not guaranteed that the report is reliably received. The next report will be sent after a period of time.
  • (2) When a host receives a query from a vro, it does not respond immediately. Instead, it sends a response after a certain interval.
  • (3) If a host receives the same report from other hosts while waiting for the report to be sent, the response from the host does not need to be sent.
  • (4) in a single physical network without any multicast router, the only IGMP traffic is when the host is added to a new multicast group, reports sent by hosts that support IP multicast.

4. survival time field

The IGMP report and query TTL are both set to 1, which limits multicast data packets to be transmitted within the same subnet. A larger TTL value can be forwarded by multicast routers. The special address of 224.0.0.0-224.0.0.255 enables the application that is intended to be used for multicast ranges not greater than 1 hop, no matter what the TTL is, the multicast Router does not forward data from any of these addresses as the destination addresses.

5. All host groups

The address 224.0.0.1 is the address of all host groups. It involves all hosts and routers with multicast capabilities in a physical network. After the interface is initialized, all hosts with multicast capability interfaces are automatically added to this multicast group. Members of this group do not need to send IGMP reports.

 

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.