## 2 Related Work  
One of the most popular code dissemination protocols in WSNs is Deluge [19], which is the de facto standard [1; 4; 5; 10; 12; 13] and has already been implemented in TinyOS. As shown in Figure 0(a), Deluge splits the code image into fixed-size pages, each of which is then divided into fixed-size packets for pipelining and spatial multiplexing. Deluge uses a three-way handshake to transmit these packets for reliable delivery. The sender first broadcasts an advertisement (ADV) which includes the current version of the code image and page information. Upon receiving the ADV, the receiver sends a request (REQ) back to the sender for the specific page. The sender then begins to transmit data packets (DATAs) for the requested page. If the receiver does not receive all packets within the page successfully, it asks the sender for lost packets by sending a REQ indicating the specific lost packets within the page. Figure 0(b) shows the operation of Deluge. Even though Deluge itself supports fixed-size packets only and does not take security into account, most of non-secure and secure code dissemination protocols are built on the basis of Deluge. To enhance the energy efficiency, a few works on dynamic packet size control have been introduced in the field of WSNs. There is definitely a tradeoff between using large-size packets in the good channel condition to reduce the header overhead and using small-size packets in the bad channel condition to reduce packet error rates (PER). DPLC [15] is an iterative algorithm to find an optimal packet size using the lightweight and accurate link estimation method. ECD [16] adapts the packet size depending on the 1-hop link quality for efficient code dissemination. Plena [17] is a packet size adaptation scheme using error estimating codes for WSNs. All of these schemes significantly conserve energy by adapting the packet size to the link quality. By integrating these schemes with existing code dissemination protocols such as Deluge, we can build an adaptive code dissemination scheme which dynamically adjusts the packet size depending on the link quality, thereby reducing the energy consumption. As it will be clarified in Section 3, our goal is to provide source authentication for these new kinds of code dissemination schemes where the packet size can be different in each hop. Source authentication in WSNs has been addressed by \(\upmu\)TESLA [14] and digital signatures. \(\upmu\)TESLA provides source authentication by using a one-way key chain and a delayed key disclosure technique. Since the BS only knows the current key which is disclosed after broadcasting messages, the receivers can assure that the messages are from the real BS by verifying the one-way key as \(h(K_{i+1})=K_{i}\) where \(K_{i}\) and \(K_{i+1}\) are a previous key and a current key, respectively. \(\upmu\)TELSA is very efficient since it only performs symmetric key cryptographic operations. However, \(\upmu\)TESLA have a critical shortcoming that it must buffer all messages until the key is distributed, thus it is subject to DoS attacks which fill the buffer of the receiver by flooding it with false messages. Furthermore, since the intermediate nodes do not know the key, they cannot adjust the packet size which means that \(\upmu\)TESLA only supports fixed-size packets in each hop. Digital signatures provide source authentication by simply signing each message with the private key of the BS. The receivers can assure the authenticity by verifying the received message with the public key of the BS. In contrast to \(\upmu\)TESLA, digital signatures provide immediate authentication, thus they are strong to DoS attacks since there is no need to buffer messages. However, digital signatures are still heavy to resource-constrained sensor nodes even though [PERSON] et al. [20] showed that public-key cryptography (PKC) is feasible on the sensor node by using elliptic curve cryptography (ECC).