As far as I know we are using routing protocols to achieve Layer 3 connectivity, I am confused with the fact that BGP works over TCP which is L4. How can L4/TCP be established without prior L3 connectivity?
Tcp – How does BGP work over TCP
bgpinternetlayer3layer4tcp
Related Solutions
I would give an answer of "no, but it is remarkably similar."
Here's some history and a largely complete explanation.
Circuits 101
Information networks can route traffic, basically, in terms of circuit switching or in terms of packet switching. Circuit switching offers many more guarantees than packet switching, but this comes at a cost, and so circuit switched networks can't degrade gracefully. The classic circuit-switched network is the PSTN, and a virtual circuit would be something like a DS0 on the PSTN.
A DS0 basically works as part of a bundle of connections, usually in a DS1. In a DS1, you will have a bundle of DS0's which are transmitted together, frame-by frame in time-division manner, so each DS0 is guaranteed a specific bandwidth, timeliness, etc. by the underlying network transport.
Another way to look at this is that a physical circuit would be something like a cat6 cable running between two terminals. You can send data back and forth over the wires at guaranteed speeds, and no other communications are going to interfere with that. Indeed the early telephone networks worked by connecting physical circuits (that is copper wires) using manual or electromechanical switches. As this was computerized, the circuits were virtualized and digital (as opposed to analog) information was sent down wires on a time division basis again with a circuit reserving a slot in the time division schedule.
What this means is that circuit switching is more about bandwidth reservation than it is about routing. The former leads to the latter. I.e. a circuit reserves bandwidth for the entire connection.
Why TCP Connections are not Virtual Circuits
TCP/IP is fully packet-switched. It makes no provisions for virtual circuits. This is why things like QoS are often necessary when trunking VOIP (a virtual circuit has built-in QoS guarantees). You have no guarantee that all packets will be routed alike. They may not come through in the same order. They may not come through in a timely manner (from a connection-oriented perspective). So you can't really build virtual circuits per se on top of a packet switched protocol like IP.
TCP comes somewhat close and in fact can work as a somewhat imperfect substitute. It offers as many of the guarantees as it can. This is why, when implemented on TCP/IP, H.323 uses TCP connections instead of the virtual circuits the protocol prefers.
But TCP connections still aren't circuits, because they don't reserve bandwidth during connection on every switch between the two nodes.
Of course TCP connections are more than just datagrams. They include routing information (as does UDP) but they also include the accounting information necessary to reconstruct the stream on the other side in order.
The Answer
Both TCP and UDP are datagram protocols. They send a packet of data with routing information to routers with none of the guarantees of that a circuit offers. TCP offers a subset of guarantees on the end points of what a circuit would offer by adding accounting information to allow the end points to handle errors and a series of data in order, but it is only a subset. Of datagram protocols, TCP is the closest thing one will find to a virtual circuit but it is still conceptually and operationally very different.
There are multiple ways to do this.
The other ASes could be sending a default route, or the router in AS100 could just have a default route configured.
The other ASes could just advertise their own routes through BGP.
The other ASes could advertise full BGP routes to AS100.
BGP has many factors which could play into the decision of which way to switch traffic destined to another AS. This is the subject of entire books, and it is beyond the scope of this site. It is far more complicated than IGP routing protocols, and it may involve many steps to determine the best path. Often is just boils down to how many AS hops away it is to get to the other AS.
You may be confused about the role of iBGP. The distinction of iBGP and eBGP is whether or not the neighbor is in the same AS. An AS will almost always have more routers than just the routers connecting to other ASes. The routers internal to the AS would have the same AS number as their neighbors, so they would use iBGP.
It would also be a huge discussion about how design within an AS. Again, you could have default routes, full or partial routing tables, a combination, etc., or a mix of IGP and iBGP (which is involved because you could use a full-mesh, route reflectors, confederations, etc.).
What BGP neighbors send each other can be controlled. It could be full routing tables, or it could be whatever the AS owner decides is appropriate. there is no one answer to this question.
Best Answer
TCP/IP sockets establish an end-to-end connection through the network, between two specifically addressed end points. BGP uses TCP/IP to communicate between routers (any devices exchanging routing information.) The information exchanged is used by the BGP peers, to better choose the way they choose where to send, (aka, next-hop) packets that they need to transmit.
At the very edges of the Internet, things are easy; "everything is this way," towards your Internet provider. More in the middle, a router might have multiple choices. So it uses TCP/IP to move BGP traffic amongst its routing neighbors. The BGP information then tells the router which paths to prefer when there are multiple ways for a packet to get where it's going.
The end points (e.g. web browsers) and the routers are speaking TCP/IP. But the routers are using TCP/IP, (BGP communications composed of TCP/IP packets) to talk about what to do with the other TCP/IP packets they need to route.