Abstract : Delay tolerant Networks (DTNs) leverage the mobility of relay nodes to compensate for lack of persistent connectivity. In order to decrease message delivery delay, the information to be transmitted can be replicated in the network. For general packet arrivals at the source and two-hop routing, we derive performance analysis of replication-based routing policies and study their optimization. In particular, we find out the conditions for optimality in terms of probability of successful delivery and mean delay and devise optimal policies, so-called piecewise threshold policies. We account for linear block-codes as well as rateless random linear coding to efficiently generate redundancy, as well as for an energy constraint in the optimization. We numerically assess the higher efficiency of piecewise threshold policies compared with other policies by developing heuristic optimization of the thresholds for all flavors of coding considered.