The invention discloses an optimal sampling frequency allocation method and an optimal sampling frequency allocation device of a wireless sensor network. According to the method, in the iteration process, a source node issues the data task information e<j>(t+1); a node j receives the data task information e<j>(t+1) form the source node, and in addition, beta (t<+>) is calculated; the node j judges whether the constraint condition is broken through or not according to the e<j>(t+1) and the beta (t<+>); if the constraint condition is broken through, the updating is carried out, the self link information is sent from the node j to the source node, and if the constraint condition is not broken through, the updating is not carried out; and the source node issues the data task information to a forwarding node of a routing path according to the link information. Through the iteration process, the utility function can be continually increased, when the increase trend of the network utility function approaches to zero, the algorithm completes the convergence, and the optimal solution is obtained. Only when the constraint condition is broken through, the source node and a target node can generate updating data packets, the updating is carried out, and the communication cost can be obviously reduced, so the expenditure of the whole iteration process is far smaller than that of the classical optimization algorithm.