The Nikon D40 does not by itself support the AWS, Advanced Wireless System, as a Master or Commander unit.
If you want the SB-900 off camera wit the iTTL using a cord then you need an SC-17/28/29 TTL.
If you want to use Nikon's AWS system, then you can use the SU-800 Commander or the SB-700/800/900 Commander/Master controller. The Commander mode controls and triggers remote units but can not provide any illumination. The Master unit not only controls the remote units but also adds illumination to the shot. The Nikon AWS system uses IR, Infra Red, light for communication of control codes from the Master/Commander unit to the remote units. This method requires clear line of sight between the Master/Commander unit and the remote units. The system can also fail in bright light. Since IR can be reflected, sometimes a blocked unit may work but not reliably. The SU-800/SB-800/900 can control 3 remote groups. The SB-700 only controls 2 remote groups.
There is the radiopopper system has a transmitter unit that converts the Nikon AWS codes to RF and transmits those codes to a receiver. The receiver takes the RF signal and converts it back to IR light and emits the light to the remote sensor.
PockeWizard has an RF system that replaces the Nikon AWS code with a special PW system. The PW system can be used with the SB-400/600/800/900 units but currently not the SB-700.
There are also simple RF trigger that just trigger the flash with no other control
Without knowing how you intend to use the remote units, it is hard to tell you exactly which system will work for you. And it is possible no one system will meet all of your needs.