As sensors in a network are mostly homogeneous in software and hardware, a captured sensor can easily expose its code and data to attackers and further threaten the whole network. To increase the survivability of a sensor network, code diversification has been shown to be an effective solution. However, disseminating many diversified code images is very costly in current network reprogramming systems, as it does not take advantage of the epidemic propagation of network reprogramming. New mechanisms need to be studied for integrating code diversification with network reprogramming. This paper proposes an efficient code diversification scheme for network reprogramming in sensor networks. The scheme uses Deluge to disseminate code images of sensor applications that carry diversification information and allows sensors to randomize the layout of their own executables. Such diversification can defeat a wide range of attacks that exploit the knowledge of code layout, as no sensors have the s...