Recently, opportunistic networks are considered as one of the most attractive developments of ad hoc mobile networks (MANETs) that have emerged thanks to the development of intelligent devices. Due to the mobility-related instability of the paths between nodes and due to the limited buffer and energy resources, the ultimate objective of routing protocols in opportunistic networks is to enable the exchange of information between users. In such harsh environments, it is difficult to exactly pin down the services provided by these networks. To this end, we present in this paper a study on the performance analysis of six of the most popular routing protocols in opportunistic networks, namely, epidemic, PRoPHET, MaxProp, Spray and Wait, Spray and Focus, and Encounter-Based Routing (EBR). We firstly described these protocols and presented their algorithms. Thereafter, we carried out a comparative study of these protocols using exhaustive performance testing experiments with different numbers of nodes, traffic loads, message lifetime, and buffer size. The results of this investigation are with an important role in helping network designers to improve performance in such challenging networks.