@
- 1 Two services provided by the network layer
-
2. Internet Protocol IP
- 2.1 Virtual Internet
- 2.2 IP Address
- 2.3 IP address and MAC address
- 2.4 Address Resolution Protocol ARP
- 2.5 Format of IP datagrams
-
layer packet forwarding process
- 3.1 Endpoint-based forwarding
- 3.2 Longest Prefix Matching
- 4. InterNetwork Control Message Protocol ICMP
-
5.IPV6
- 5.1 Basic IPV6 initialization
- 5.2 IPV6 addresses
-
5.3 Transition from IPv4 to IPv6
- 5.3.1 Dual Protocol Stack (Dual Stack)
- 5.3.2 Tunneling
-
6. Routing protocols for the Internet
- 6.1 Hierarchical routing protocols
-
6.2 Interior Gateway Protocol RIP
- 6.2.1 Preferred questions to be answered
- 6.2.2 Distance vector algorithm
- 6.3 Interior Gateway Protocol OSRP
-
6.4 External Gateway Protocol BGP
- 6.4.1 What is BGP and how does it differ from RIP and OSRP?
- 6.4.2 Differences between EBGP and IBGP
- 6.4.3 Based on routing vectors
-
6.5 Router Components
- 6.5.1 Router Architecture
- 6.5.2 Exchange structure
-
7. Virtual Private Network VPN and Network Address Translation NAT
- 7.1 Virtual Private Network VPN
- 7.2 Network Address Translation NAT
The most important elements of this chapter are.
(1) Virtual interconnection networks and the concept of two services and two levels
(2) Relationship between IP address and MAC address.
(3) CIDR for traditionally categorized IP addresses and unclassified inter-domain routing (the latter is the focus).
(4) How routing protocols work.
1 Two services provided by the network layer
In the field of computer networks, there has been a long debate on what kind of services ("connection-oriented" or "connectionless") the network layer should provide to the transportation layer. The essence of the debate is: who should be responsible for reliable delivery in computer communications? Is it the network or the end system?
- One idea is to let the network take care of reliable transmission
This view holds that the success of telecommunication networks should be utilized to make the network responsible for reliable delivery Computer networks should mimic telecommunication networks by using connection-oriented communication. Virtual circuits (VirtualCircuit) are created prior to communication to ensure that the two parties need to communicate.
of all network resources. If network protocols for reliable transmission are then used, the packets sent can be made to reach the end point in an error-free and orderly manner, without loss or duplication.
- Another view: the network provides datagram services
The pioneers of the Internet came up with a new way of thinking about network design. The network layer went up to provide only simple, flexible, connectionless, best-effort delivery of datagram services.
The network sends packets without first establishing a connection. Each packet (i.e., IP datagram) is sent independently of the packets before and after it (not numbered).
The network layer does not provide quality of service commitments. That is, the packets transmitted are subject to error, loss, duplication and out-of-sequence (out-of-order arrival at the end point), and of course there is no guarantee of a time frame for the transmission of the packets.
- Delivering to the best of our ability
Since transport networks do not provide end-to-end reliable transmission services, this allows routers in the network to be made relatively simple and inexpensive (compared to switches in telecommunication networks).
If communication between processes in the host (i.e., end system) needs to be reliable, then the transportation layer in the host of the network is responsible for reliable delivery (including error handling, flow control, etc.)
The benefits of using this design idea are: the cost of the network is greatly reduced, the operation is flexible and can be adapted to a variety of applications.
The fact that the Internet has grown to the size it is today is a testament to the correctness of adopting this design thinking in the first place.
Aspects of comparison | VCS | datagram service |
---|---|---|
reasoning | Reliable communication should be ensured by the network | Reliable communication should be guaranteed by the user host |
Connection Establishment | must have | unnecessary |
destination address | Used only during the connection establishment phase, using a short virtual circuit number per packet | Each grouping has the full address of the end point, i.e. the IP address |
Forwarding of packets | Packets belonging to the same virtual circuit are forwarded according to the same route | Each group looks up the forwarding table independently for forwarding |
When a node fails | All virtual circuits through the faulty node are inoperative | Failed nodes may lose packets and some routes may change |
Order of grouping | Always reaches the end of the line in the order in which it was sent | The order of arrival at the finish line is not necessarily in the order in which they were sent. |
End-to-end error handling and flow control | Can be handled by the network or by the user's host | Responsible by the user's host |
2. Internet Protocol IP
The Internet Protocol IP is one of the two primary protocols in the TCP/IP system. There are three other protocols used in conjunction with the IP protocol.
- Address Resolution Protocol (ARP)
- InterNetwork Control Message Protocol ICMP (Internet Control Message Protocol)
- Internet Group Management Protocol (IGMP)
2.1 Virtual Internet
How do you connect heterogeneous networks to each other?
As a general concept, intermediate devices are used to connect networks to each other. Depending on the level at which the intermediary device is located, there are four different types of intermediary devices as follows.
- The intermediate device used at the physical layer is calledRepeater。
- The intermediate device used at the data link layer is called a(network) bridgemaybeBridgeas well asSwitches。
- The intermediate device used at the network layer is calledRouter。
- Intermediate devices used above the network layer are calledGateway. Connecting two incompatible systems with a gateway requires protocol conversion at a high level.
The significance of virtual interconnection networks:
- The so-called virtual interconnection network is also known as logical interconnection network, which means that the interconnection of a variety of physical network heterogeneity is objective, but we use the IP protocol can make the performance of these networks from the user looks as if a unified network.
- A virtual interconnected network using the IP protocol can be abbreviated as an IP network.
- The benefits of using a virtual interconnected network are:: When hosts on the Internet communicate, it is as if they are communicating on a single network, without seeing the heterogeneous details of each specific network that is interconnected.
- If the TCP protocol is used in the upper layer of this worldwide IP network, then it is now the Internet.
2.2 IP Address
In the TCP/IP system, IP address is one of the most basic concepts. A device connected to the Internet cannot communicate with other devices on the network without an IP address.
-
IP address and its representation
-
Classification of IP addresses
-
Uncategorized Addressing CIDR
Classless Inter-Domain Routing (CIDR) is a technique used to aggregate and allocate IP addresses, which effectively solves the problem of insufficient address space in IPv4 by changing the traditional way of allocating IP addresses.The introduction of CIDR breaks the classification based on classes and introduces the variable-length subnet mask ( VLSM) concept, which uses the prefix length to represent the number of bits in the network portion of an IP address, thus allocating IP addresses more flexibly and realizing efficient use of address space.
CIDR uses a slash followed by a number to indicate prefix length. For example.192.168.0.0/16
Indicates that the first 16 bits are the network portion and the remaining bits are the host portion. This representation allows you to quickly determine which network the IP address belongs to.
2.3 IP address and MAC address
From a hierarchical perspective, a MAC address is an address used at the data link layer, while an IP address is an address used at the network layer and above, and is a logical address (IP addresses are referred to as logical addresses because they are implemented in software).
- Only IP datagrams are visible on the Internet at the IP layer abstraction. The source and destination addresses are always IP1 and IP2, respectively, and the IP address of the intermediate router does not appear at the beginning of the IP datagram.
- The router forwards only based on the IP address of the destination and ignores the source IP address.
- At the link layer of the LAN, IP datagrams are encapsulated in MAC frames. the source and destination addresses in the header of a MAC frame change as the frame travels across different networks.
- The IP-layer abstraction of the Internet shields the lower layers from differences in the MAC address system and uses a uniform IP address to research communications.
2.4 Address Resolution Protocol ARP
Address Resolution Protocol (ARP) is a network layer protocol used to resolve IP addresses at the network layer into MAC addresses at the data link layer.ARP works in local area networks (LANs), especially in environments that use Ethernet technology.
When a device needs to send data to another device on the same LAN, it first needs to know the MAC address of the target device. the workflow of ARP is roughly as follows:
- consult (a document etc): The sending device (which we'll call Host A) checks its own ARP cache table to see if the MAC address corresponding to the destination IP address already exists.
- publicize: If there is no entry in the ARP cache table for the target IP address, Host A sends an ARP request broadcast packet to all devices on the LAN. This broadcast packet contains Host A's IP address and MAC address, as well as the IP address it wants to resolve (the IP address of the target device).
- responsive: All devices on the LAN receive this ARP request, but only the device that has the IP address specified in the request (which we will call Host B) sends an ARP response packet to Host A.
- Updating the cache: When Host A receives an ARP response, it adds Host B's IP address and MAC address to its own ARP cache table and uses this MAC address for subsequent data transfers.
- data transmission: Once the MAC address of the target device is obtained, Host A can send the data frame to Host B over Ethernet.
The ARP protocol is stateless, meaning that it does not maintain any state information, and address resolution is required before each data transmission. entries in the ARP cache table usually have a time to live (TTL), and a new ARP lookup is required after expiration. This ensures that devices in the network are able to update their information when their IP address or MAC address changes.
2.5 Format of IP datagrams
IP datagram (Internet Protocol datagram) is the core of the network layer, which is used to transmit data across the network.IP datagram consists of two parts: the IP header and the data (payload), where the data portion can be any type of network layer data such as TCP, UDP, or other protocols' data.
- Version
- lengths: 4 digits
- functionality: Specifies the IP protocol version, which is 4 for IPv4 and 6 for IPv6.
- Internet Header Length (IHL)
- lengths: 4 digits
- functionality: Specifies the length of the IP header in 32-bit words (a 32-bit word equals 4 bytes). The minimum value is 5 (i.e. 20 bytes) because the minimum length of the IP header is 20 bytes.
- Type of Service (ToS)
- lengths: 8-bit
- functionality: Used to specify the quality of service for datagrams, such as priority, delay, throughput, and so on.
- Total Length
- lengths: 16-bit
- functionality: Specifies the length of the entire IP datagram, including header and data, in bytes. The maximum length is 65535 bytes.
- Identification
- lengths: 16-bit
- functionality: Identifies each datagram sent by the host and is used for datagram reorganization.
- Flags
- lengths: 3 digits
- functionality: Controls and identifies the segmentation of the datagram. One of the bits is MF (More Fragments), which indicates whether there are more fragments after it.
- Fragment Offset
- lengths: 13th place
- functionality: Indicates the relative position of the current segment in the original datagram.
- Time to Live (TTL)
- lengths: 8-bit
- functionality: Specifies the maximum number of routers that a datagram can pass through in the network. For each router it passes through, the TTL is reduced by 1. When the TTL is 0, the datagram is discarded.
- Protocol
- lengths: 8-bit
- functionality: Specifies which high-level protocol the carried data should be uploaded to, e.g., 6 for TCP and 17 for UDP.
- Header Checksum
- lengths: 16-bit
- functionality: Used to detect if the header information is in error during transmission.
- Source IP Address (Source Address)
- lengths: 32-bit
- functionality: IP address of the device sending the datagram.
- Destination Address
- lengths: 32-bit
- functionality: IP address of the device receiving the datagram.
- Options
- lengths: Variable
- functionality: For functions such as network testing, debugging or security.
- Padding
- lengths: Variable
- functionality: Make sure the entire header is a multiple of a 32-bit word.
- Data
- lengths: Variable
- functionality: The actual data transferred, which can be TCP, UDP or other protocols.
clarification
- Minimum IP header length is 20 bytes, when there are no options. If options are included, the header length may be longer, but will not exceed 60 bytes.
- first checksumOnly the header is covered, not the data part.
- options (as in computer software settings)Fields are optional and are used to support network testing, debugging, security, and other functions.
- Data sectionThis can be any type of network layer data whose protocol is specified in the Protocol field.
The design of IP datagrams allows it to flexibly transmit data in complex network environments while ensuring data integrity and correctness through a variety of fields.
layer packet forwarding process
Layer P packet forwarding is the fundamental process of data transmission in Internet Protocol (IP) networks. This process involves encapsulating data into IP packets and transmitting them from the source node to the destination node in the network.
3.1 Endpoint-based forwarding
Endpoint-based forwarding is when a router or switch decides how to forward packets based on their destination IP address. The following are the basic steps of packet forwarding at the IP layer:
-
data encapsulation: At the sender's end, the raw data is divided into smaller data units called packets or packets. Each packet is encapsulated with an IP header that contains information such as the source IP address and destination IP address.
-
routing: When a packet arrives at a router, the router looks at the destination IP address of the packet and determines the next hop address based on its internal routing table. The routing table contains information about the paths to reach different networks or hosts.
-
Forwarding decisions: The router uses the Longest Prefix Match principle to find the entry in the routing table that best matches the destination IP address. This usually means selecting the route with the longest network prefix (i.e., the most specific network address).
-
packet forwarding: Once the next-hop address is determined, the router forwards the packet to the next router or directly to the destination host.
-
Repeat process: This process is repeated at each router in the network until the packet reaches its final destination.
-
data reorganization: After the destination host receives all the packets, it reassembles them according to the sequence number in the packet to recover the original data.
-
Confirmation and retransmission: If a packet is lost or corrupted during transmission, the destination host sends an acknowledgement message to the sender, who then retransmits the lost packet.
3.2 Longest Prefix Matching
Longest Prefix Match (LPM) is an algorithm used in network routers to determine the path of packet forwarding. When a router receives an IP packet, it needs to decide which next hop to send the packet to based on the destination IP address of the packet. The longest prefix matching algorithm accomplishes this decision by following steps:
-
Find Routing Table: A router first looks for an entry in its routing table that matches the destination IP address. Each entry in the routing table usually contains a destination network address and a next-hop address.
-
prefix length: Every network address has a prefix length, which indicates the number of bits in the address that are used to identify the network. For example, an address with a prefix length of 24 means that the first 24 bits of the IP address are used to identify the network.
-
longest match: The router will try to find the routing table entry with the longest prefix that matches the destination IP address. This means that the router looks for the network prefix that most accurately matches the destination IP address.
-
Select Next Jump: Once the longest matching entry is found, the router forwards the packet using the next hop address specified by that entry.
-
default route: If no matching entry is found in the routing table, the router may use a default route (also known as a default gateway) to forward the packet. Default routes are typically used for destinations that are not explicitly listed in the routing table.
The advantage of the longest prefix matching algorithm is that it provides an efficient and scalable way to handle large amounts of routing information. It allows routers to quickly find the most appropriate route in complex routing tables, thus ensuring that packets are forwarded correctly and efficiently.
In summary, the packet forwarding algorithm can be summarized as follows (assuming that the forwarding table is arranged according to the length of the prefix, placing the longer prefixes in front).
(1) Extract the IP address D (i.e., the destination address) of the destination host from the first part of the received packet.
(2) If you find a specific host route (the destination address is D), forward the packet in accordance with the next hop of this route; otherwise, start checking from the next line in the forwarding table (that is, the line with the longest prefix), and execute (3).
(3) AND the subnet mask of this line with the destination address D bit by bit. If the result of the operation matches the prefix of this line, then the search is finished, and it is processed in accordance with the "next hop" (either delivered to the destination host on this network, or sent to the next-hop router through the specified interface). Otherwise, if there is a next line in the forwarding table, the next line is checked and (3) is executed again. Otherwise, execute (4).
(4) If there is a default route in the forwarding table, the packet is transmitted to the specified default router according to the specified interface; otherwise, an error in forwarding the packet is reported.
4. InterNetwork Control Message Protocol ICMP
Internet Control Message Protocol (ICMP) is an auxiliary protocol at the network layer that is used to pass control messages between IP hosts, routers.ICMP messages are used to provide feedback about network communications, to help diagnose network problems, and for network configuration and maintenance.
The main functions of ICMP include:
- false: ICMP can send an error report message to the sender when an IP packet is not reachable to its destination, or when there is an error in processing the packet. For example, destination unreachable, time exceeded, parameter problem, etc.
- Showback Requests and Showback Answers: ICMP allows echo request messages (often called "pings") to be sent to check the reachability of a network connection. When the receiver receives the request, it sends an echo reply message indicating that the request was received and that the network connection is open.
- redirects: When a router finds that the routing of a packet is not optimal, it can send an ICMP redirect message to the sender suggesting that another router be used as the next hop.
- Timestamp request and response: ICMP can be used to obtain timestamp information on network devices to help synchronize clocks in the network.
- Address Mask Request and Response: In some network configurations, ICMP can be used to get or set a host's subnet mask.
ICMP messages are usually encapsulated in IP packets, but they are not transport layer protocol data; they are network layer control information.The ICMP Message Type and Code fields are used to distinguish between different types of ICMP messages.
ICMP is an important tool for network diagnostics and is commonly used:
- Detecting network connectivity (e.g., using the ping command)
- Diagnose network problems (e.g., routing issues, network misconfiguration, etc.)
- Network monitoring and maintenance
5.IPV6
5.1 Basic IPV6 initialization
characterization | descriptive |
---|---|
Larger address space | IPv6 increases addresses from IPv4's 32 bits to 128 bits, increasing the address space by a factor of 2^128 |
Extended Address Hierarchy | Due to the large address space, it can be divided into more levels |
Flexible header format | IPv6 defines a number of optional extension prefixes to improve router processing efficiency |
Improved Options | IPv6 datagrams can contain new options with a fixed header length and options placed in the payload |
Allow for continued expansion of the agreement | Supporting technological development and the emergence of new applications |
Plug and play support (auto-configuration) | IPv6 does not require the use of DHCP |
Support for pre-allocation of resources | Supports applications that require guaranteed bandwidth and latency, such as real-time video. |
IPv6 header alignment | The header has been changed to 8-byte alignment, while the IPv4 header is 4-byte alignment |
An IPv6 datagram consists of two main parts, the base header and the payload that follows. The payload is also known as the net load. The payload allows for zero or more extension headers, followed by the data portion. Note, however, that all extension headers are not part of the base header of an IPv6 datagram. | |
Compared to IPv4, IPv6 makes the following changes to certain fields in the header.
- The first length field has been eliminated because it has a fixed first length (40 bytes).
- The Service Type field has been eliminated because the Priority and Flow Label Number fields implement the functionality of the Service Type field.
- The total length field has been eliminated in favor of the payload length field.
- Eliminated the logo, flag, and slice offset fields, as these functions are already included in the slice extension header Renamed the TTL, field to the hop limit field, but serves the same purpose (more consistency in name and purpose).
- The agreement field is eliminated in favor of the next first field.
- The checksum field has been eliminated, which speeds up the processing of datagrams by the router. We know that at the data link layer frames with errors are discarded if detected. At the transport layer, when using UDP, user datagrams are discarded if errors are detected. When TCP is used, the packet segments with detected errors are retransmitted until they are correctly delivered to the destination process. Therefore, error detection at the network layer can be streamlined.
- The option field has been eliminated in favor of an extension header for option functionality.
5.2 IPV6 addresses
In general, the destination address of an IPv6 datagram can be one of the following three basic types of addresses:
typology | descriptive |
---|---|
Unicast | With traditional peer-to-peer communication, each datagram is sent to only one specific destination. |
Multicast | One-point-to-multipoint communication where datagrams are sent to each of a group of computers. instead of adopting the terminology of broadcasting, IPv6 views broadcasting as a special case of multicasting. |
Anycast | A type of IPv6 addition where the end point is a group of computers, but the datagram is delivered to only one of them, usually the closest one according to a routing algorithm. |
An IPv6 address consists of 128 bits, usually represented as eight groups of four hexadecimal digits, each group separated by a colon (:). This representation provides a compact and easy-to-read format. Below are some rules and examples of how IPv6 addresses are represented: |
-
basic expression:
- An IPv6 address is represented by eight sets of 4-bit hexadecimal numbers, for example:
2001:0db8:85a3:0000:0000:8a2e:0370:7334
。
- An IPv6 address is represented by eight sets of 4-bit hexadecimal numbers, for example:
-
zero compression:
- If a hexadecimal number contains one or more consecutive zeros, a double colon (::) may be used instead to simplify the representation. However, the double colon should be used only once in the entire address to avoid ambiguity. Example:
-
2001:0db8:85a3:0000:0000:8a2e:0370:7334
This can be simplified as2001:db8:85a3:0:0:8a2e:370:7334
。 - This is further simplified as
2001:db8:85a3::8a2e:370:7334
。
-
- If a hexadecimal number contains one or more consecutive zeros, a double colon (::) may be used instead to simplify the representation. However, the double colon should be used only once in the entire address to avoid ambiguity. Example:
-
IPv4 compatibility and IPv4 mapped addresses:
- IPv6 addresses can contain an IPv4 address for compatibility with IPv4 networks. This address format is known as
::ffff:
begins, followed by the IPv4 address. For example, the IPv4 address192.0.2.128
The representation in IPv6 is::ffff:192.0.2.128
。
- IPv6 addresses can contain an IPv4 address for compatibility with IPv4 networks. This address format is known as
The following is a breakdown of common IPv6 addresses:
Address Type | address block prefix | CIDR notation for prefixes |
---|---|---|
Unspecified address | 00..0 (128 bits) | ::/128 |
loopback address | 00..1 (128 bits) | ::1/128 |
multicast address | 11111111 | FF00::/8 |
Local site unicast address | 1111111011 | FEC0::/10 |
local link unicast address | 1111111010 | FE80::/10 |
Global Unicast Address | (sth. or sb) else |
The following is a brief explanation of several common addresses listed in the table:
- Unspecified address: This is a 16-byte all zeros address that can be abbreviated as two colons ":::". This address cannot be used as a destination address, but can only be used as a source address for a host, provided that the host has not been configured to a standard IP address. This is the only address of this type.
-
loopback address: The IPv6 loopback address is
0:0:0:0:0:0:0:1
, which can be abbreviated as::1
. It serves the same purpose as an IPv4 loopback address. This type of address is also the only one of its kind. - multicast address: The function is the same as for IPv4. This type of address accounts for 1/256 of the total number of IPv6 addresses.
- Unicast address of this site: Some organizations have internal networks that use the TCP/IP protocol but are not connected to the Internet. Hosts connected to such an internal network can all communicate using such local site addresses, but cannot communicate with other hosts on the Internet. This type of address accounts for 1/1024 of the total number of IPv6 addresses and is used in the same way as IPv4 dedicated addresses.
- local link unicast address: Such addresses are used on a single link. A local link address is automatically generated when a node is IPv6 enabled. This special address is used when a packet needs to be sent to a device on a single link and you do not want the packet to be forwarded outside the scope of this link. Such addresses account for 1/1024 of the total number of IPv6 addresses.
- Global Unicast Address: This class of unicast addresses for IPv6 is the most used class. According to the recommendations of RFC4291, the division of IPv6 unicast addresses is very flexible and can be any of the ones shown in Figure 4-34. This means that the entire 128 bits can be used as the address of a node, or n bits can be used as a subnet prefix, and the remaining (128-n) bits can be used as the interface identifier (equivalent to the IPv4 host number). Of course it can also be divided into three levels, using the n bits as the global routing prefix, the m bits as the local prefix, and the remaining bits as the interface identifier.
5.3 Transition from IPv4 to IPv6
Dual stack and tunneling are the two main transition technologies used in the transition from IPv4 to IPv6. The following is a brief description of these two technologies:
5.3.1 Dual Protocol Stack (Dual Stack)
A dual protocol stack is a network configuration in which devices, network nodes or network links are capable of handling both IPv4 and IPv6 protocols. This means that these devices or links can support both IPv4 and IPv6 communication.
vantage:
- Provides a straightforward way to support both IPv4 and IPv6, very useful for use during the transition.
- Allow native connections to IPv4 and IPv6 networks.
drawbacks:
- Requires double the configuration and management as two different protocols need to be maintained.
- Implementation may be costly as it requires more memory and processing power.
- Running a dual stack network requires additional staff training.
- Running IPv6 on an existing IPv4 infrastructure may require additional hardware changes (e.g., routing information base and forwarding information base memory).
5.3.2 Tunneling
Tunneling involves encapsulating IPv6 packets within IPv4 packets in order to transmit IPv6 traffic over an IPv4 network infrastructure. This approach allows IPv6 packets to be transmitted over an IPv4 network without upgrading the entire network infrastructure.
vantage:
- Allowing the use of IPv6 in IPv4 networks provides flexibility for IPv6 deployment.
- It is possible to start using IPv6 without upgrading the entire network infrastructure.
drawbacks:
- Tunneling may rely on public IPv4 addresses, and NAT may cause problems.
- Tunneling may require additional complexity to be maintained in the network infrastructure, e.g., 6rd requires ISPs to maintain 6rd border trunks, which may add to the complexity of the network.
6. Routing protocols for the Internet
6.1 Hierarchical routing protocols
internal gateway protocol | External Gateway Protocol |
---|---|
Routing protocols used within an autonomous system, mainly RIP, OSRF | Routing protocols used between different autonomous systems, mainly BGP-4 |
6.2 Interior Gateway Protocol RIP
6.2.1 Preferred questions to be answered
With whom to exchange information | What information is being exchanged? | When to exchange information |
---|---|---|
Exchange information only with neighboring routers | Currently this router knows all the information | Exchange of information at fixed intervals, about 30s |
6.2.2 Distance vector algorithm
Basic Concepts of Distance Vector Algorithms
The core idea of the distance vector algorithm is that each router periodically sends its own routing table (which contains the distances to each network) to its direct neighboring routers. The term "distance" usually refers to the number of routers passed through, which is also known as the "hop count".
How does it work?
- initialization: Each router has a routing table containing directly connected networks and their corresponding "distances". For directly connected networks, the distance is 0; for all other networks, the distance is infinity.
- information exchange: Each router broadcasts its routing table to neighboring routers at regular intervals (usually 30 seconds).
- Updating the routing table: When a router receives a routing table from a neighboring router, it updates its own routing table based on the Distance Vector Algorithm. The update rule is: if a network can be reached through the new route, and the total "distance" (number of hops) of the new route is smaller than the record in the current routing table, then the distance to the network and the next-hop router will be updated.
- Avoiding loops: In order to prevent routing loops (where a packet is forever cycling through several routers, unable to find an exit), the RIP protocol has a "maximum distance" concept. If the distance of a route exceeds 15 hops (RIP v1), the route is considered unreachable.
Suppose there is a simple network containing 4 routers A, B, C, and D, and 4 networks Net1, Net2, Net3, and Net4.
- A is directly connected to Net1 and B
- B is directly connected to A, C and D
- C is directly connected to B and Net2
- D is directly connected to B and Net3
- initialization phase:
- Routing table for A: Net1(0), Net2(∞), Net3(∞), Net4(∞)
- Routing table for B: Net1(1), Net2(∞), Net3(∞), Net4(∞)
- Routing table for C: Net1(∞), Net2(0), Net3(∞), Net4(∞)
- Routing table for D: Net1(∞), Net2(∞), Net3(0), Net4(∞)
- Exchange and update:
- Assuming that B receives A's routing table to update its own (Net1 distance is 0 because of direct connectivity)
- C receives B's routing table and updates Net1's distance to 1 (reaching Net1 through B)
- D ditto for updating Net1 with a distance of 1 (reaching Net1 through B)
- Repeat the process: At regular intervals, routers update each other's routing tables until the network is stable and each router knows the shortest path to each network.
6.3 Interior Gateway Protocol OSRP
With whom to exchange information | What information is being exchanged? | When to exchange information |
---|---|---|
Send a message to all routers in this autonomous system | Link status of all routers adjacent to this router | The link changes or a considerable amount of time. |
6.4 External Gateway Protocol BGP
6.4.1 What is BGP and how does it differ from RIP and OSRP?
BGP(Border Gateway Protocol) It is an external gateway protocol for the internet, mainly used to exchange routing information between different autonomous systems (AS). It is one of the backbone protocols of the internet and is particularly suitable for large-scale networks.
characterization | Border Gateway Protocol | RIP | OSPF |
---|---|---|---|
scope of action | External Gateway Protocol (EGP) for use between different autonomous systems | Interior Gateway Protocol (IGP) for use within a single autonomous system | Interior Gateway Protocol (IGP) for use within a single autonomous system |
routing algorithm | Path vector algorithms, based on paths, policies and attributes | Distance vector algorithm, up to 15 hops | Link state algorithm by calculating link cost |
stability | Suitable for large-scale networks, capable of handling large amounts of routing information | Suitable for small networks with good stability | Suitable for medium to large networks, can converge quickly |
network size | Internet level | Small and medium-sized networks | Medium and large networks |
6.4.2 Differences between EBGP and IBGP
characterization | EBGP(External BGP) | IBGP(Internal BGP) |
---|---|---|
use | Route exchange between different autonomous systems | Routing exchanges within the same autonomous system |
connection method | Usually directly connected, the AS number propagates | Routers within the same AS that can no longer forward the |
Default TTL value | 1 (must be directly connected) | 255 (multiple hops allowed) |
routing propagation | Ability to propagate routes to other EBGP neighbors | EBGP routes are not propagated between IBGP routers |
6.4.3 Based on routing vectors
characterization | clarification |
---|---|
Route Records | BGP records the AS paths through which routes are routed to ensure route transparency |
Avoiding loops | BGP avoids routing loops by detecting AS numbers in AS paths |
routing | Optimization based on attributes of the route (e.g., AS path, next hop, etc.) |
Selection Steps | Prioritize locally generated routes, shortest AS paths, optimal attributes, etc. |
6.5 Router Components
6.5.1 Router Architecture
A router is a specialized computer with multiple input ports and multiple output ports whose task is to forward packets. A packet received from one of the router's input ports is forwarded from one of the router's appropriate output ports to the next-hop router in accordance with the destination (i.e., the destination network) to which the packet is destined. The next-hop router handles the packet in this same way until the packet reaches its destination. The forwarding of packets by routers is precisely the main job of the network layer.
6.5.2 Exchange structure
The switching fabric is the key building block of a router [KURO17]. It is this switching fabric that moves packets from an input port to some suitable output port.
7. Virtual Private Network VPN and Network Address Translation NAT
7.1 Virtual Private Network VPN
-
What is a VPN?
A VPN (Virtual Private Network) is a technology that creates a secure, encrypted private network over a public network (such as the Internet) to ensure the security and privacy of data as it travels between two or more devices. It ensures the security and privacy of data in transit by creating an encrypted "tunnel" between two or more devices.VPNs are widely used to improve network security, protect user privacy, and access restricted content. -
What are the functions of a VPN?
- encrypted communications
- Hide IP address
- Bypassing geographic restrictions and censorship
- remote access
- Avoid tracking and monitoring
-
Three types of dedicated address blocks
address range | subnet mask | Number of addresses |
---|---|---|
10.0.0.0 to 10.255.255.255 | 255.0.0.0 (/8) | 16,777,216 addresses |
172.16.0.0 to 172.31.255.255 | 255.240.0.0 (/12) | 1,048,576 addresses |
192.168.0.0 to 192.168.255.255 | 255.255.0.0 (/16) | 65,536 addresses |
-
Implementing Virtual Private Networks with Tunneling
-
data encapsulation: At premises A, data is sent from source address 125.1.2.3 to destination address 194.4.5.6. The data is first encapsulated in an external datagram whose source address is external address 10.1.0.0 at premises A and whose destination address is external address 10.2.0.0 at premises B. The data is then encapsulated in an external datagram whose source address is external address 10.1.0.0 at premises A, and whose destination address is external address 10.2.0.0 at premises B.
-
tunnel transmission: Encapsulated data is transmitted over the Internet. During transmission, the data maintains its encapsulated state, ensuring the security and integrity of the data.
-
data decapsulation: When the data arrives at Place B, it is first decapsulated to extract the original datagram. The data is then sent to its final destination 194.4.5.6.
-
7.2 Network Address Translation NAT
-
address translation: When a device in an internal network (private network) needs to communicate with an external network (e.g., the Internet), a NAT device (usually a router or firewall) translates the private IP address of the internal device into a public IP address. This public IP address can be the public IP address of the router, or one of a set of public IP addresses configured on the router.
-
port mapping: Since multiple internal devices may need to share a public IP address, NAT distinguishes packets from different internal devices by using different port numbers. This allows packets to be correctly routed to the correct internal device even if multiple devices use the same public IP address.
-
packet processing: When a packet returns from an external network, the NAT device forwards the packet back to the correct internal device based on the port number. This allows internal devices to communicate with the external network even if they do not have a public IP address.
This is an example of a NAPT (Network Address Port Translation) address translation table.NAPT is a networking technology used to share a public IP address among multiple devices on a private network so that they can access the Internet. This table shows how a packet's source IP address and port number are translated as it passes through a NAPT device.
The form includes:
- orientations: The flow of packets can be from the private network to the Internet or from the Internet to the private network.
- field: The type of IP address and port number being converted, either source IP address and TCP source port, or destination IP address and TCP destination port.
- Original IP address and port number: The IP address and port number of the packet before conversion.
- Converted IP address and port number: The IP address and port number to which the packet is translated after passing through the NAPT device.
Specifically, this table shows the following conversions:
-
Sent from the private network to the Internet:
- 192.168.0.3:30000 converted to 172.38.1.5:40001
- 192.168.0.4:30000 converted to 172.38.1.5:40002
-
Sent from the Internet to the private network:
- 172.38.1.5:40001 converted to 192.168.0.3:30000
- 172.38.1.5:40002 converted to 192.168.0.4:30000
This translation allows multiple devices with different private IP addresses and port numbers to communicate with the Internet through a public IP address (in this case 172.38.1.5). When the packet is returned, the NAPT device converts the packet's port number back to the original private IP address and port number according to the translation table, ensuring that the data is returned correctly to the device that sent it.