First, it is offset with all the money going in the other direction. So banks only need to balance the
net at the end of each day.
As for that net, when banks send/receive money from each other, they do not transact in shipments of cash, they transact with electronic money -- reserves. Bank A and Bank B have accounts at a reserve bank in their area. The reserve banks in turn are part of the Federal reserve system, networked together. Thus just as a deposit is a liability of a regular bank, a reserve is a special kind of deposit that is the liability of the reserve bank -- the central bank. And just as households are the deposit holders of regular banks, other banks are the deposit holders of the reserve bank.
Fun Fact 1: It is illegal for individuals to hold an account at the Federal Reserve. Only banks are allowed to do this. See https://www.federalreserve.gov/faqs/does-the-federal-reserve...
There has been a push to open this system up to more retail banking instead of forcing people to use private banks.
Fun Fact 2: Before the creation of the Federal Reserve System, private Reserve banks sprung up -- banks for banks. These banks were also called "clearinghouses" because banks would settle each other's liabilities there without the need for pairwise settlement (n is better than n(n+1)/2). Then when banking crisis hit, it obviously put great strain on the clearinghouse, which led to the creation of the Federal Reserve, to replace the private reserve banks. The Federal Reserve could not run out of money because its liabilities were legal tender. One of the most famous private reserve banks was the Suffolk Bank of Boston. See also https://en.wikipedia.org/wiki/Suffolk_System
Going back to our story, let's say the net is 1 million dollars on a given day. Then one bank transfers 1 million of dollars of reserves to the other bank, which just consists of the reserve bank marking up one account and marking down the other account.
What happens if Bank A doesn't have 1 million of reserves to spare? Well that depends on whether Bank A believes the situation is temporary or permanent. Banks hire liquidity management professionals for this reason. These are the people, like weathermen, that look at historical cash flow patterns and use statistics to try to minimize overall bank expenses. Cash pays no interest, but you pay a penalty if you need to borrow it. Reserves pay very little interest and you pay the same small penalty. So banks want to minimize holdings of both cash and reserves while maintaining smooth operation.
If the reserve shortfall is believed to be temporary, then Bank A borrows the reserves from other banks in the overnight market. That overnight interest rate is the rate that the Federal reserve targets.
Making sure that the entire banking system as a whole has enough reserves is the job of the Federal Reserve, which adds reserves to the banking system by purchasing bonds, and removes reserves by selling some of the bonds it purchased previously. Assuming the overall banking system has enough reserves, there will be some other bank in the system with excess reserves that is willing to lend to Bank A at the policy rate.
If the Bank believes the reserve deficiency is longer lasting, the bank can tap the longer term funding markets by selling more commercial paper, or a longer term bond, or it can sell off some marketable asset (point being to go short something). This is again the job of professionals that manage the overall position of the bank. By means of going short something of longer duration, the bank will increase inflow from some other bank (the bank that provides financial services for the purchaser of the asset), and so will increase its own reserve holdings back to the level required.
In the extreme case of some financial market disruption in which you can't sell assets to the private market, the bank could show up at the discount window of the Federal reserve and borrow money from the Fed, collateralized by some qualifying asset such as a government insured bond), and of course at a penalty rate. Again, banks want to avoid doing this but it's there as a last resort.
Bottom line, banks don't send each other trucks filled with cash in pairwise relationships, they centralize their deposits in a clearinghouse and that handles reserve management. None of this interbank settlement requires cash. Banks do not get cash from each other.
The use of vault cash is purely for purposes of customer demand. When a customer wants cash, the bank opens the vault. When the bank has excess cash, the bank sells some of the cash for reserves. When the bank has too little cash, it sells some of the reserves for cash. So banks can convert electronic reserves to physical cash, and that is where you get the trucks carrying cash from the government to the bank in a hub and spoke system rather than point to point.
Cash is used only outside the banking system, to provide currency to bank customers.