In this paper, the authors use SPI calculus to analyze the demand loading code protocol of active network. The security flaw of being replay attack in this protocol is found. Model of active network is different from the tradition network. Since the model of active network is compute-storage-forward, and the model of tradition network is storage-forward. The replay attack would make the unexpected result for active network and letdown the performance and efficiency of active node. In order to prevent the replay attack, the authors amend the protocol and enhance the capacity for preventing replay attack.