The difference between old-school telephony and this (for this aspect only) is that calls are delivered from your ITSP to your PBX through a trunk. The trunk has no concept of what is being delivered - it’s just the IP address/tunnel to and from your ITSP. The second difference is that inbound calling and outbound calling are almost entirely unrelated. You can have a trunk that is “inbound” only, or “outbound” only. The differentiator is what you and your provider as set up.
In my case, for example, all of my inbound calls come in on a trunk from “ITSP A” but I have two outbound trunks that I use for “other” stuff. My ITSP A trunk also has outbound capabilities, but they’re unrelated. One of my outbound trunks is there specifically to call my cell phone (so I can call myself if my primary trunk goes down).
In broad strokes, the first hurdle is that, in VOIP, the terms DID and CID are not interchangeable like they were on a T1. The DID is the In-dial number that is being sent to your PBX. It’s part of the payload that establishes the call. Your ITSP is sending you the call because the DID matched your account, hence delivered VFR-direct to your PBX. The trunk has almost nothing to do with your DID, except that calls to your DID are sent through a trunk. Asterisk takes the call and determines the DID, then uses that information to route the call for you.
Caller ID (or CID) is a two-piece set. On an Inbound call, the CID is the number that called you, and you can route calls based on CID in your Inbound Route. In POTS, this was the information that was delivered between the first and second ring. On an Outbound call, you set the Caller ID your system is using. It might be your DID, or it could be a number from a caller that gets routed “off” your PBX to a remote phone. This split functionality is part of many people’s confusion because the CID used to be managed by the Telco.
So, while DID and CID would seem to be related, they aren’t, with one exception. To obfuscate the problem with CID even more, your provider may force you to use an assigned Caller ID - which is one of your DIDs in the form
<XXXYYYZZZZ> "YourNameHere>"
If your ITSP allows “foreign” CID, you can send almost anything down the line to be picked up by remote phones or extensions.
So - trunk is the pipe through which your calls travel.
DID is always the number being called in your PBX. It is always one of your numbers.
CID is either the CID of the person calling you (for all inbound calls) or your CID (for most outbound calls).
Trunks do not care about CID, unless you force one. Trunks do care about “destination numbers” which (if you want to get confusing) is like a DID to someone else’s PBX. I always avoid using that model, because it doesn’t help. For outbound calls, you will be using “dialed number” which the trunk can massage to meet the specific requirements of your ITSP. Once again, the trunk is only the conduit for your call.
Inbound and Outbound routes are how you select which trunk will be used (if you have more than one) and can also do things like forcing a specific caller ID for an emergency call (for example). Most people have two or three outbound routes - these take the dialed number, tune it (add or remove ‘1’ as a prefix, add area code for 7-digit numbers, etc.) and get it ready to the trunk.
Summary on this point: Inbound routes are searched by DID, CID, neither, or both for a match to send a call in a direction. This can be an IVR, Voicemail, an announcement, or a “hang up” (as examples). An inbound route without a DID or a CID is called an “any/any” or “default” route, since the blank DID and CID match anything.
An outbound route uses the Dialed Number to do basically the same thing. The number is selected and optionally modified to be sent to a trunk. Once a trunk is selected, it can also manipulate the outbound dialed number to match the specifics of the trunk selected.
That’s way more than you probably need to start, but hopefully one of the ways I explained it might help. 