What Is Internet Peering
The Internet is made up of a vast number of different networks. These networks all have devices inside of them. These networks also communicate with each other, allowing the device inside one network to communicate with a device in another network. One method of communication between networks is through Internet peering.
When networks connect to one another they are telling each other that they have a "path" to reach certain IP addresses. A network will tell another network "hey, I know how to get to these certain devices".
This is all done through the BGP protocol. BGP is the just protocol, or language, that networks use to communicate with each other. When two routers talk to one another, it is usually using BGP.
Every device on a network has an IP address. An IP address is an identification number for that device. So if a network contains a device with an IP address of 188.8.131.52, then it can use BGP to tell other networks "Hey, I know how to reach 184.108.40.206. If you have packets that need to get to 220.127.116.11, you can send them to me!"
Again, the was networks tell this to each other is through BGP.
So when networks peer with each other they take a list of all (or some) of the IP addresses inside of their own network and "announce" them to their peer network. The peer network then hears these announcements and knows how to reach the devices inside the first network.
The second network does the same thing. It announces the IPs inside of its own network to its peers allowing them to send traffic directly to that network to reach those IP addresses.
The main thing to remember is that Internet peering is the sharing of a networks own IP address space. Peering is different from IP transit. With IP transit, the upstream provides all of the IP paths that it knows. This includes the IP addresses inside its own network, but also the IP addresses of other networks. Essentially, IP transit means that a network is claiming to know how to reach everywhere on the Internet.
Peering is much more limited. Peering is only sharing devices within a single network. This is often stated to be a network's own devices and the devices of their direct customers.
If a network is a customer of a larger network, that larger network can consider the smaller network to be within the larger network. So when the larger network peers with someone, it includes the IPs of the smaller network.
Network Peering Agreements
There are different types of peering agreements. Some are "settlement free", which means that neither party pays the other. These are common among networks that are of similar size. These settlement free peering agreements allow two equally sized networks to reach the devices within each others network without having to pay a third party.
Many networks have a minimum traffic ratio that must be met for them to peer with another network. This is usually a measure of fairness, so that one larger network is not providing a free resource for a smaller network. The smaller network gets access to all of the devices in the larger network, but the larger network gets almost nothing in return.
Other networks have paid peering agreements. This is when two networks peer with each other, but one network provides some kind of payment to the other network. It depends on the situation, but there are certainly times when it is worth while for a network to pay another network to peer.
With paid peering, the technological aspects are still the same as with free peering. Even though money is being exchanged, this is still only the exchange of IP addresses within each network, and not IP transit where the whole Internet would be provided.
Sometimes peering is free, but one only one of the networks pays for all the infrastructure costs, such as the cross connect fees used to pay to connect the two networks. Other times the networks split the infrastructure costs.
The main reason to peer with other networks is to save money. Peering is often free. IP transit is often paid for. If your routers can send traffic to a peering port, which is free, then you do not need to buy as much bandwidth from your IP transit provider. This saves you money.
Peering allows networks to avoid using their paid upstream.
Sometimes there are other strategic reasons for networks to peer with one another. There may be mutual benefits that do not involve saving upstream costs, but these are network specific.