Before you head out to the local junkyard looking for a compatible transmission, I would either performance and OBD diagnostic. The reason for my recommendation is that I don’t believe you have a transmission problem. It sounds to me as if it could be a sensor that has failed or is failing. I would start with the anti-knock filter since you say the transmission is knocking, it would seem to me to be best bet.
You can tell that this is a mechanical problem rather than a transmission issue because it is located in a specific gear, rather than affecting the tranny as a whole. Indeed, that is one of the strongest telltales that the issue is mechanical. If it were a transmission problem or a problem within the transmission (honestly two different ideas, for example, if it is a transmission problem, the tranny then it would be failing in more than one gear. Further, the transmission would likely be exhibiting problems such as slipping in all gears; there might be problems with transmission electronics such as the MAP sensor failing to do its job, turning your pickup’s performance into poor capability, and more.) If it is a problem within the transmission then it would be exhibiting other problems. For example, if it were a problem with the input shaft then you would likely have a pickup with very loud noises coming from that area as the input shaft complained that it had a problem very pointedly.
Believe me when I tell you it’s to your advantage if you take your pickup into a local full-service transmission shop with NIASE-certified technicians. They will quickly isolate the problem from which your pickup is suffering and report out on it. I would be willing to bet you a large cup of iced coffee you will find that the OBD report shows lots of 07XX errors which, by the way, are for various systems within the transmission. Let me know what happens, please.