Computer network microclassroom notes collation

Notes are also posted on github github.com/BloothOfYou…

4.1 Overview of the network layer

Introduction to the

  • The main task of the network layer is to realize network interconnection, and then realize the transmission of data packets among different networks

If these heterogeneous networks N1~N7 only need their own internal communication, they only need to implement their own physical layer and data link layer

However, if we want to interconnect these heterogeneous networks to form a larger Internet, we need to implement network layer device router

Sometimes, for the sake of simplicity, instead of drawing these networks, N1 to N7, you can think of them as links

  • To implement network layer tasks, the following main problems need to be solved:

    • What services the network layer provides to the transport layer (” Reliable transport “or” unreliable transport “)

    Lesson at the data link layer to deliver reliable transmission, details you can see there’s notes: the network layer of the following packet loss and packet disorder, grouping repeat transmission errors take measures to make the recipients can accept the sender sends the data correctly, is the reliable transmission, on the contrary, if doesn’t take any measures, it is not reliable transport

    • Network layer addressing problem

    • Routing problem

    When a router receives data, what does it use to decide which of its interfaces to forward the packet to?

    Depending on the destination address of the packet and the routing table in the router

    But in practice, how does a router know about these routing records?

    • Manual configuration is performed by users or network administrators. This method is only applicable to small-scale Networks where the network topology does not change

    • The other is to implement a variety of routing protocols, by the router to implement the routing algorithm specified in the routing protocol, and automatically obtain the route in the routing table record, this method is more suitable for large scale and network topology often change large Internet

Supplementary network layer (Internet layer) In addition to IP protocol, there are address resolution protocol ARP, Internet Control message protocol ICMP, and Internet group management protocol IGMP

conclusion

4.2 Two services provided by the network layer

  • In the field of computer networks, there has been a long debate about what services the network layer should provide to the transport layer (” connection-oriented “or” connectionless “).

  • The essence of the debate is: who should be responsible for reliable delivery in computer communications? Is it the network or the end system?

Connection-oriented virtual circuit services

One view: Make the network responsible for reliable delivery

  • In this view, the successful experience of telecommunications networks should be used to make networks responsible for reliable delivery, and computer networks should imitate telecommunications networks by using connection-oriented communications.

  • Before communication, a Virtual Circuit is established to ensure all network resources required for communication between the two parties.

  • If the network protocol of reliable transmission is used again, the packets sent can arrive at the destination in sequence without error, without loss or repetition.

All packets sent by a sender to a receiver are transmitted along the same virtual circuit

  • A virtual circuit indicates that this is only a logical connection along which packets are sent in a store-and-forward fashion, rather than actually establishing a physical connection.

  • Note that circuit-switched telephone communication is preceded by the establishment of a real connection.

  • So packet-switched virtual connections are similar to circuit-switched connections, but not identical

Connectionless datagram service

Another view: the network provides datagram services

  • The pioneers of the Internet put forward a brand new idea of network design.

  • The network layer up only provides simple, flexible, connectionless, best-effort datagram services.

  • The network does not need to establish a connection before sending packets. Each packet (that is, an IP datagram) is sent independently of the packet before and after it (it is not numbered).

  • The network layer offers no quality-of-service promises. That is, packets transmitted may be wrong, lost, repeated and out of order (not reaching the destination in order), and of course there is no guarantee of the time of packet transmission.

Packets sent by a sender to a receiver may travel along different paths

Do your best to deliver

  • If communication between processes in the host (that is, the end system) needs to be reliable, then the transport layer in the host of the network is responsible for reliable delivery (including error handling, flow control, and so on).

  • The advantages of adopting this design idea are: the cost of the network is greatly reduced, the operation mode is flexible, and it can adapt to a variety of applications.

  • The Internet can develop to today’s scale, fully proved the original use of this design idea is correct.

Virtual circuit service versus datagram service

** Aspects of comparison ** ** Virtual service ** ** Datagram service **
Thinking of * * * * ** Reliable communication should be guaranteed by the network ** ** Reliable communication shall be guaranteed by the user host **
** Connection setup ** ** must have ** ** doesn’t need **
** Destination address ** ** is used only during the connection establishment phase, and each group uses a short virtual circuit number ** ** Each group has the complete address of the end **
** Group forwarding ** ** Packets belonging to the same virtual circuit are forwarded by the same route ** ** Each group independently selects a route for forwarding **
** When a node fails ** ** All virtual circuits that pass through the failed node will not work ** ** Failed nodes may lose groups and some routes may change **
** Order of grouping ** ** always reaches the destination ** in the order it is sent ** Does not necessarily arrive at the destination in the order it is sent **
** End-to-end error handling and flow control ** ** can be the responsibility of the network or the user host ** The user host is responsible for **

4.3, IPv4

An overview of the

IPv4 address compiled by category

Introduction to the

  • Each type of address consists of two fixed-length fields, one of which is the network number net-ID, which identifies the network to which the host (or router) is connected, and the other is the host number host-ID, which identifies the host (or router).

  • The host number must be unique within the network range indicated by the network number preceding it.

  • Thus, an IP address is unique across the entire Internet.

Class A address

A class B address

Class C address

practice

conclusion

IP address assignment range

A special IP address that is not generally used

Some important features of IP addresses

(1) IP address is a hierarchical address structure. The advantages of having two levels are:

  • First, the IP address management organization only assigns network numbers when assigning IP addresses, and the remaining host numbers are assigned by the entity that obtains the network numbers. This facilitates IP address management.

  • Second, the router forwards packets only according to the network number connected to the destination host (regardless of the destination host number), which can greatly reduce the number of items in the routing table, thus reducing the storage space occupied by the routing table.

(2) An IP address is actually an interface that identifies a host (or router) and a link.

  • When a host is connected to two networks at the same time, the host must have two corresponding IP addresses and the network ID of the host must be different. This type of host is called a multihomed host.

  • Because a router should be connected to at least two networks (so that it can forward IP datagrams from one network to another), a router should have at least two different IP addresses.

(3) Several Lans connected by transponders or Bridges are still one network, so they all have the same network number net-ID.

(4) All networks assigned net-ID are equal, whether they are lans with a small scope or Wans that may cover a large geographical area.

IPv4 address of a subnet

Why subnets

In the early days of ARPANET, IP addresses weren’t designed properly:

  • IP address space utilization is sometimes low.

  • Assigning a network number to each physical network causes the routing table to become too large and thus deteriorates network performance.

  • The IP addresses of the two tiers are not flexible.

If you want to divide the original network into three independent networks

So I wonder if I can borrow part of the host number as the subnet number

But how do we and the computer know how many bits of the host number in the classification address are used as subnet numbers if the subnet number part is not marked in the graph?

So here comes the tool for dividing subnets: the subnet mask

  • Since 1985, a “subnet number field” has been added to the IP address, so that a two-tier IP address becomes a three-tier IP address.

  • This practice is called subnetting.

  • Subnets have become the official standard protocol of the Internet.

How to Divide a subnet

The basic idea

  • Subnets are a purely internal matter. The unit is still represented as a network without subnets.

  • The number of bits is borrowed from the host number as the subnet id, and the number of bits is reduced from the host number host-id.

  • If an IP packet is sent from another network to a host in the unit, the router connected to the unit’s network is found first according to the destination network number of the IP packet net-ID.

  • After receiving the IP packet, the router finds the destination subnet according to the destination network id net-id and subnet id subnet-id.

  • Finally, IP datagrams are delivered directly to the destination host.

The network is still one after being divided into three subnets

  • advantages

    1. Reduces IP address waste

    2. Make network organization more flexible

    3. Easier to maintain and manage

  • Subnets are a purely internal matter, transparent to the external network, which is still represented as a network without subnets.

Subnet mask

(IP address) AND (subnet mask) = Network address

For example,

Example 1

Example 2

Default subnet mask

conclusion

  • A subnet mask is an important property of a network or subnet.

  • When a router exchanges routing information with its neighbor routers, it must tell the neighbor routers the subnet mask of its own network (or subnet).

  • Each item in the router’s routing table must give the subnet mask of the network as well as the destination network address.

  • If a router is connected to two subnets, it has two network addresses and two subnet masks.

Classified-unaddressed IPv4 address

Why unclassified addressing

Select Classless Inter-domain Routing (CIDR).

The most important feature of CIDR

  • CIDR uses network-prefixes of various lengths to replace network and subnet numbers in classified addresses.

  • IP addresses have moved from three-level addressing (using subnet masks) back to two-level addressing.

How do I use unclassified addressing

For example,

Route aggregation (Constructing hypernet)

conclusion

Planning IPv4 addresses

Given an IPv4 address, how to divide it into several smaller address blocks and allocate these address blocks to different networks on the Internet, so that IPv4 addresses can be assigned to hosts and router interfaces on each network

Fixed Length Subnet Mask FLSM

The IPv4 address of a subnet is a fixed-length subnet mask

For example,

Through the analysis of the above steps, 5 subnets can be selected from 1 and 8 and assigned to N1 and N5 in the left figure

If a fixed-length subnet mask is used, only 2^ N subnets can be divided, where N is the number of bits borrowed from the host number as the subnet number. The same number of IP addresses are allocated to each subnet

However, the number of IP addresses allocated to each subnet is the same, which is not flexible and leads to IP address waste

Variable Length Subnet Mask (VLSM)

Classified-unaddressed IPv4 is a variable-length subnet mask

For example,

4.4 Process of sending and forwarding IP datagrams

For example,

How does the source host know whether the destination host is on the same network as it, and whether it is delivered directly or indirectly?

You can obtain the destination network address through logical operations on the destination IP address and the subnet mask of the source IP address

  • If the destination network address is the same as the source network address, it is in the same network and belongs to direct delivery

  • If the destination network address and source network address are different, they are not in the same network and are delivered indirectly to the default gateway of the network where the host resides (router – as shown in the following figure). The default gateway helps forward the packets

How does host C know router R exists?

In order for the host in the local network to communicate with the host in other networks, the user must specify the interface of a router in the local network for the router to help forward. The specified router is also called the default gateway

For example. The IP address of router interface 0, 192.168.0.128, serves as the default gateway of the left network

Host A will transmit the IP datagram to its default gateway, which is router interface 0 shown in the figure

How does a router forward IP datagrams after receiving them?

  • Check IP datagram header for error:

    • If an error occurs, the IP packet is discarded and advertised to the source host

    • If no error occurs, the system forwards the packet

  • Find a matching entry in the routing table based on the destination address of the IP datagram:

    • If a matching entry is found, it is forwarded to the surprise indicated in the entry

    • If not, the datagram is discarded and the source host is notified

Assuming there is no error in the IP datagram header, the router extracts the values of each address field in the IP datagram header

The router then forwards the IP datagram through table lookup

Detailed routing entry examination, the destination address and route entry in the address mask to the logical network address and operation purpose, and then compared with routing entry purpose in the network, if the same, the routing is the routing entry is matching items, according to it the next instruction, shown in the figure is the interface 1 forwarding the IP datagram

Routers isolate broadcast domains

4.5 Static route configuration and routing loop problems it may cause

concept

Multiple case examples

Static Route Configuration

For example,

The default route

For example,

The default route can be matched by all networks, but the route matching has a priority. The default route has the lowest priority

Host-specific routing

For example,

Sometimes we can add a specific host routing entry to the router for a particular host

It is used by network administrators to manage and test networks

Multiple routes are optional. The most specific route is matched

Static routes are incorrectly configured, causing routing loops

For example,

Assume that the third directory in R2’s routing table is configured with an incorrect next hop

This causes a routing loop between R2 and R3

Aggregation of nonexistent networks resulting in routing loops

For example,

normal

An error condition

The solution

The next hop of the blackhole route is NULl0, which is the virtual interface inside the router. IP packets entering this interface are discarded

Network faults cause routing loops

For example,

The solution

Add the failed network as a blackhole route

The hypothesis. The faulty network was restored after some time

R1 in turn automatically obtains the route entry for the direct network of its interface 0

The black hole network for this network will automatically fail

If it breaks down again

The network takes effect in the black hole network

conclusion

4.6. Routing protocol

An overview of the

Key features of routing protocols used on the Internet

The Internet uses a hierarchical routing protocol

  • Autonomous system (AS) : A group of routers managed by a single technology that use an intra-AS routing protocol and common metrics to determine the routes grouped within the AS and an inter-AS routing protocol to determine the routes grouped among ass.

Route selection between aS is called interzone route selection, and route selection within as is called intra-zone route selection

Interzone routing uses EGP, a routing protocol

Intra-zone routing uses IGP, a routing protocol of this category

The name of a gateway protocol can be called a routing protocol

Common routing protocols

The basic structure of a router

A router is a dedicated computer with multiple input ports and output ports, whose task is to forward packets

Router architecture can be divided into two major parts:

1. Packet forwarding

It consists of three parts

  • Exchange structure

  • A set of input ports:

    Signals enter the router from an input port

    The physical layer converts the signal into a bit stream and sends it to the data link layer for processing

    The data link layer recognizes the frame from the bit stream, removes the frame header and the frame tail, and sends it to the network layer for processing

    If the packet sent to the network layer is an ordinary data packet to be forwarded

    Table lookup forwarding is performed based on the destination address in the packet header

    If no matching forwarding entry is found, the packet is discarded. Otherwise, the packet is forwarded according to the port indicated in the matching entry

  • A set of output ports

    The network layer updates the values of certain fields in the data packet header, for example, by reducing the lifetime of the data packet by 1, and then sends it to the data link layer for encapsulation

    The data link layer encapsulates the data into frames and sends them to the physical layer for processing

    The physical layer treats the frame as a bit stream and converts it into the corresponding electrical signal for transmission

Each port of the router will also have input and output buffers

  • The input buffer is used to hold new packets that have entered the router but have not had time to process them

  • The output buffer is used to hold packets that have been processed but have not been sent in time

Router ports generally have input and output functions. These examples distinguish input and output ports to better demonstrate the basic routing process

2. Route selection

  • The core component of the routing part is the routing processor, whose task is based on the routing protocol used. Periodically interact routing information with other routers to update the routing table

    If the network layer packet sent to the input port is a routing packet for exchanging routing information between routers, this packet is sent to a routing selection processor

    The routing processor updates its routing table based on the contents of the packet

    Routing processors also periodically send routing information they know to other routers

Routing information protocol RIP

Basic RIP working process

For example,

Update rules of RIP routing entries

For example 1

The next entry in router C’s table to each destination network is marked as a question mark, which can be understood as router D does not need to care about these contents of Router C

Assume that the interval for sending RIP update packets of router C expires, router C encapsulates routing information in its routing table into RIP update packets and sends them to Router D

If Router C can reach these networks, it means that router C’s neighboring routers can also reach them, but the distance is 1 larger than that of Router C. Therefore, router D updates its routing table according to the comparison of distances

For example 2

RIP has the problem of slow propagation of bad news

The solution

However, these methods cannot completely solve the problem of “slow propagation of bad news”, which is the essential decision of distance vector

conclusion

Advantages and disadvantages of RIP

Advantages:

  1. Simple implementation and low overhead.

Disadvantages:

  1. RIP limits the size of the network. The maximum distance it can use is 15 (16 indicates unreachable).

  2. The routing information exchanged between routers is the complete routing table in routers, so the overhead increases as the network size increases.

  3. “Bad news travels slowly,” making the update process take too long to converge.

Open shortest Path Priority OSPF

Open Shortest Path First (OSPF)

Note: OSPF is just the name of a protocol. It does not mean that other routing protocols are not shortest path first.

concept

Greeting (Hello) groups

The value of the protocol number field in the IP packet header is 89, indicating that the data payload of the IP packet is OSPF packet

The LINK state Advertisement LSA was sent. Procedure

Flooding is a bit like broadcasting, coming in from one interface and going out from all the other interfaces

Link-state database synchronization

The SPF algorithm is used to calculate the shortest path between each router and other routers

There are five OSPF group types

OSPF basic working process

OSPF establishes router neighbor relationships on the multipoint access network

If no other mechanism is used, a large number of multicast groupings will result

If the DR fails, the BDR replaces the DR

To enable OSPF to apply to large-scale networks, OSPF divides an AS into several smaller areas, called areas.

  • In the AS, all routers use OSPF. OSPF divides the AS into four smaller areas

  • Each region has a 32-bit region identifier

  • The area identifier must be 0 for the trunk area, which is used to connect to other areas

  • The area identifier of other areas cannot be 0 and different

  • Each area should not contain more than 200 routers

  • The advantage of zoning is that the use of flooding to exchange link-state information is limited to each zone rather than the autonomous system, thus reducing traffic over the entire network

conclusion

Border Gateway protocol BGP

The Border Gateway Protocol (BGP) is a Protocol used by routers of different ass to exchange routing information

conclusion

Protocol for directly encapsulating RIP, OSPF, and BGP packets

4.7. Header format of IPv4 datagram

The function of each field

  • An IP datagram consists of a header and data.

  • The first part of the header is a fixed length of 20 bytes, which all IP datagrams must have.

  • After the fixed section in the header are optional fields of variable length.

Each row in the figure consists of 32 bits (that is, 4 bytes). Each cell is called a field or field, and each field or combination of fields is used to express the related functions of the IP protocol

The header of an IP datagram must be a multiple of 4 bytes

Because the first of the length of the optional fields ranging from 1 byte to 40 bytes, so, when the fixed part of 20 bytes plus 1 to 40 bytes length of variable section, will cause the first length is not a 4-byte integer times, with the values of all zeros corresponding bytes, fill the fields to ensure that the IP datagram header length is 4 bytes integer times

Fragment IPv4 datagrams

Now assume that the IP datagrams of Shard 2 need to be shard as they pass through some network

conclusion

4.8. Internet Control Message Protocol, ICMP

concept

ICMP is not a high-level protocol (it looks like it is, since ICMP packets are packaged as part of the IP datagram), but rather an IP layer protocol

ICMP Packet format

ICMP Error report packet

Out of reach

Source point inhibition

For more than

Parameters of the problem

Changing routes (redirection)

ICMP error report packets should not be sent

ICMP Application Examples

PING (Packet InterNet Groper)

Tracing routes (Traceroute)

The implementation principle of the tracert command

conclusion

4.9 Virtual private Network VPN and NAT

Virtual Private Network (VPN)

  • Due to the shortage of IP addresses, the number of IP addresses that an organization can apply for is often much smaller than the number of hosts that the organization has.

  • Given that the Internet is not very secure, it is not necessary for all hosts in an organization to be connected to an external Internet.

  • Assuming that computers within an organization communicate using TCP/IP, the organization can, in principle, assign IP addresses to those computers that are used only within the organization.

This is IANA’s website looking at the allocation of special addresses in the IPv4 address space

The address marked in pink is a private address that does not require application and can be freely allocated

Private addresses can only be used for internal communication within an organization, not for communication with hosts on the Internet

A private address can only be used as a local address, not a global address

All routers on the Internet do not forward IP datagrams whose destination address is private

Local address and global address

  • Local address — An IP address that is used only within an organization can be assigned by the organization itself without applying to the Internet management authority.

  • Global Address — The unique IP address in the world must be applied to the Internet management authority.

  • Problem: A local address used internally may overlap with an IP address on the Internet, causing address ambiguity.

Therefore, departments A and B need at least one router with A valid global IP address so that their private networks can communicate over the public Internet

Data transfer from Department A to Department B

Datagrams sent between hosts in two private networks are over the public Internet but have the effect of being sent over the organization’s private network

Datagrams may pass through multiple networks and routers on the Internet, but logically R1 and R2 appear to be a straight-through point-to-point link

Therefore, it is also called IP tunneling technology

Network Address Translation (NAT)

For example,

How can a host using a private address communicate with a host using a global IP address on the Internet?

This requires the installation of NAT software on a router that has a private network connected to the Internet

A router with dedicated NAT software is called a NAT router

It has at least one valid external global IP address

In this way, all hosts using private addresses translate their private addresses into global IP addresses on the NAT router when communicating with the external world

Suppose a host using a private address wants to send IP datagrams to another host on the Internet using a global IP address

This host on the Internet sends back datagrams to the source host

When two hosts using private addresses in the private network want to send data reports to another host using global addresses on the Internet, two records are generated in the NAT table of the NAT router to record the mapping between the two private addresses and global addresses respectively

There is a problem with this basic transformation

The solution

Many of the home routers we use today are NART routers

Can an extranet host initiate communication between an Intranet host and an extranet host first?

no

conclusion