|
| 1 | += Multipeer Replicator |
| 2 | +ifdef::show_edition[:page-edition: Enterprise Edition] |
| 3 | +:description: MultipeerReplicator is a peer-to-peer replicator that can advertise its presence, discover other peers, establish connections, and replicate data with those peers. |
| 4 | + |
| 5 | +:source-language: Java |
| 6 | + |
| 7 | +:source-language: Kotlin |
| 8 | + |
| 9 | +[abstract] |
| 10 | +{description} |
| 11 | + |
| 12 | + |
| 13 | +TIP: Multipeer Replication is currently available for use over IP networks. |
| 14 | +If you are working with a bluetooth network, you will need to use Couchbase Lite's xref::p2psync-websocket.adoc[Active-Passive peer-to-peer]. |
| 15 | + |
| 16 | +[#introduction] |
| 17 | +== Introduction |
| 18 | +// tag::introduction-full[] |
| 19 | +// tag::introduction[] |
| 20 | +Couchbase Lite's Peer-to-Peer synchronization solution offers secure storage and bidirectional data synchronization between edge devices without needing a centralized cloud-based control point. |
| 21 | +Multipeer Replicator |
| 22 | +// end::introduction[] |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +== Prerequisites |
| 27 | + |
| 28 | +=== Transport and Peer Discovery Protocol |
| 29 | + |
| 30 | +MultipeerReplicator supports Wi-Fi transport, using DNS-SD (also known as Bonjour) for peer discovery. |
| 31 | + Peers must be connected to the same Wi-Fi network to discover and establish connections with one another. |
| 32 | + |
| 33 | +=== Supported Platforms |
| 34 | + |
| 35 | +For Android, the minimum API level is API 35, based on the availability of required DNS-SD features for peer discovery and mesh network construction—such as support for subtypes, and the ability to publish and subscribe to service information. |
| 36 | + |
| 37 | + |
| 38 | +== Overview |
| 39 | + |
| 40 | +The MultipeerReplicator automatically advertises its presence, discovers other peers, |
| 41 | +and establishes connections for data replication with peers that share the same group identifier defined by the application. |
| 42 | + |
| 43 | +To maintain optimal connectivity, efficient data transport, and balanced workloads, the MultipeerReplicator forms a dynamic mesh network among peers in the same group. |
| 44 | +It avoids redundant direct connections, evenly distributes connections across peers, and optimizes communication paths. |
| 45 | +The mesh network continuously adapts as peers join or leave. |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +== Configuration |
| 51 | + |
| 52 | +.Configuration for creating a MultipeerReplicator |
| 53 | +[source,java] |
| 54 | +---- |
| 55 | +public struct MultipeerReplicatorConfiguration { |
| 56 | + /// Identifier for discovering and connecting peers. |
| 57 | + public let peerGroupID: String |
| 58 | + |
| 59 | + /// Peer identity. |
| 60 | + /// @Note The identity’s certificate must be both server and client certificate. |
| 61 | + public let identity: TLSIdentity |
| 62 | +
|
| 63 | +
|
| 64 | + /// Peer authenticator. |
| 65 | + public let authenticator: MultipeerAuthenticator |
| 66 | +
|
| 67 | +
|
| 68 | + /// Collections to replicate. |
| 69 | + public let collections: [MultipeerCollectionConfiguration] |
| 70 | +
|
| 71 | +
|
| 72 | + /// Initialize the configuration with a peer group identifier, identity, |
| 73 | + /// authenticator and collections. |
| 74 | + public init(peerGroupID: String, |
| 75 | + identity: TLSIdentity, |
| 76 | + authenticator: MultipeerCertificateAuthenticator, |
| 77 | + collections: [MultipeerCollectionConfiguration]) |
| 78 | +} |
| 79 | +---- |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | +TIP: In version 3.3.0, the recommended maximum number of peers in a mesh network is approximately 15. |
| 86 | + |
| 87 | + |
0 commit comments