Orthogonal Variable Spreading Factor (OVSF) CDMA code has the ability to support higher and variable data rates with a single code using one transceiver. A number of CDMA code assignment algorithms have been developed and studied for cellular wireless networks, however, little is known about the ad hoc wireless networks. In this paper, we propose several distributed CDMA/OVSF code assignment algorithms for wireless ad hoc networks modelled by unit disk graph (UDG). We first study how to assign CDMA/OVSF code such that the total throughput achieved is within a constant factor of the optimum. Then we give a distributed method such that the minimum rate achieved is within a constant factor of the minimum rate of any valid code assignment. A distributed method that can approximate both the minimum rate and total throughput is also presented. Finally, we present a post processing method to further improve these code assignments. All our methods use only O(n) total messages (each with O(lo...