Data Sync
Advanced Sync Concepts
Transports Overview
the ditto peer to peer network architecture supports both direct communication between small peers (device to device) and communication by way of a server ( docid\ k51z knujnm0ge8aqkhba ) that connects and transmits data between small peers (device to server to device) this dual approach provides flexibility — your app remains efficient in any network environment and you control when and what routes through a central server to enable all transports, call transportconfig enablepeertopeer() ; otherwise, enable them one by one (see docid\ zuw1dwpowaimbpntcb3z3 ) following are the various transports ditto uses to facilitate peer to peer communication across peers /#bluetooth low energy /#apple wireless direct link /#wi fi aware /#local area network /#websockets transport connections https //docs ditto live/ios/common/how it works/mesh network#types of transports ditto uses as many technologies as possible to communicate with other devices running your app these modes, such as bluetooth low energy (le) and local area network (lan), are called transports w hile many transport methods are set up automatically, others, such as websocket, if configured with the big peer, require manual configuration connections when an end user launches your app, the first thing they do is observe how quickly it syncs the latest information ditto understands this when sync begins, it uses all transports aggressively to locate and connect to multiple potential peers concurrently at the same time, the existing peers notice the newcomer’s arrival if capacity, they will also establish connections to the new device together these processes ensure that a new peer is integrated into the mesh as quickly as possible a mobile phone has a finite battery life; therefore, after the initial burst of activity, ditto must adapt to become more efficient each additional lan connection consumes more cpu time but also depletes radio energy bluetooth low energy (le) faces particularly stringent constraints — devices can only handle a few concurrent connections, and each connection initiation can take several seconds in larger meshes, ditto must strategically limit the number of interconnections and choose them wisely to optimize efficiency at the same time, ditto must not have too few connections; otherwise, islanding can occur islanding refers to the isolation of different groups of devices within the same network put another way, it's a scenario where different groups of devices, located in the same room, are connected in individual clusters — if there is no connection between those groups, they will not sync data d itto uses the following two techniques to prevent islanding, neither of which requires central coordination maintaining a reasonably dense mesh to minimize the likelihood of island formation implementing a random churn , where devices periodically change their connections to different peers this implementation ensures that even if an island forms, it is likely to be transient and only last a few seconds random churning refers to the process in which devices slowly change which peers they are connected to next, certain optimizations are possible for instance, improve the diversity of the mesh imagine that two peers are candidates for a bluetooth le connection; however, they only have the capacity for one if you are already connected to one of those peers through a wi fi connection, then the bluetooth le connection should be prioritized on the other peer to improve the diversity of the mesh now, let's consider the same scenario but with the capacity for two bluetooth low energy (le) connections in this case, we would establish connections with both available peers the bluetooth connection associated with the wi fi connection will remain inactive for the time being however, if the wi fi connection is lost in the future, ditto will seamlessly switch to the pre established bluetooth connection without any noticeable disruption for the user it might sound complex, but there's no need to worry all of these functionalities are integrated into ditto, and your app will handle them automatically you simply need to enable your transports, and ditto will optimize their usage seamlessly multiplexer https //docs ditto live/ios/common/how it works/mesh network#using bandwidth intelligently in smaller meshes, ditto creates multiple connections to the same peer using different transports while this approach may seem wasteful, it provides important performance benefits lower latency during the initial sync process since these transports race to establish a connection, with the first successful connection triggering sync ensures that large updates sync as quickly as possible by prioritizing the fastest available connection meanwhile, slower connections like bluetooth le, which have limited radio bandwidth, are preserved — remaining idle for peers in urgent need if the fastest connection is lost, whatever the next best option is ready to take over immediately, reducing or even eliminating the downtown when sync is interrupted the seamless switching between transports relies on a ditto component called the multiplexer currently, the multiplexer utilizes one transport at a time with failover capabilities however, in future versions, this feature will enable more complex scenarios, such as load balancing across multiple routes and handling lossy transports for more information, see the ditto blog post > https //ditto live/blog/the new network multiplexer bluetooth low energy ditto utilizes both traditional wi fi and bluetooth low energy (le) to maintain a continuous mesh network of transmission control protocol (tcp) connections bluetooth le technology forms low powered and high distance connections between devices, making it highly performant in offline scenarios when replicating small amounts of data in the event of a wi fi network disruption, such as a router getting disconnected, ditto does not automatically switch transports to establish an independent bluetooth le connection as a fallback instead, ditto actively works to maintain the previously established wi fi and bluetooth le connections performance the following distances, limitations, and capacities are approximations and vary depending on the bluetooth® firmware installed in the end user environment syncing large documents can significantly impact network performance caution is advised when handling large binary data, such as a high resolution image or video exceeding 50 megapixels; a deeply embedded document; or a large document instead of storing files exceeding 250kb directly within a document object, consider using an attachment instead of a map (see docid\ dya kkvzyftkiurwdb2o1 ) most devices manufactured during or after 2017 are equipped with bluetooth le version 5 0 bandwidth capacity discoverability range distance durability 20 kilobyte (kb) maximum per 1 second interval 30 to 60 meter maximum for v 4 0, 80 meter maximum for v 5 0, 130 meter maximum limitations bluetooth le performance declines in the following scenarios physical obstructions, radio signal attenuation, radio frequency congestion, among other environmental challenges large amounts of binary data such as high resolution image files or large document objects in addition, when ios devices establish a bluetooth le connection with android devices end users can view the connection from their device's ios bluetooth settings when your app is forced to close on the ios device, the bluetooth connection to the android device automatically terminates visibility of these ios to android bluetooth le connections in the ios settings is intended for informational purposes only they do not limit the number of bluetooth le devices that can connect to the mesh peer to peer wi fi the bandwidth capacity and distance limitation of peer to peer wi fi connections depend on the end user environment, as different devices and platforms support varying wi fi technologies the following table provides an overview of the wi fi technologies ditto supports, organized by platform platform ditto supported technology apple apple wireless direct link (awdl) android wi fi aware apple wireless direct link unlike bluetooth le, which enables peers to establish cross platform connections between devices, the apple wireless direct link (awdl) transport type can only be utilized to sync data between apple devices peers within an end user environment of the apple platform can use awdl for point to point communication, enabling extremely fast, high bandwidth sync for ios and macos devices this makes it highly performant when replicating large amounts of data such as high resolution videos and images or files performance awdl enabled mesh communication between apple based peers has significantly higher bandwidth when compared with bluetooth le, allowing for low latency, high speed data transfers bandwidth capacity discoverability range distance durability 5 ghz frequency range 1 gigabyte maximum per 8 second interval 30 to 60 meter maximum 35 meter maximum limitations with an average maximum range of 35 meters from point to point, awdl allows for shorter distances when compared to bluetooth le, which can be sustained for distances up to 130 meters wi fi aware wi fi aware technology is a new open standard that you can use to establish a mesh network connection between devices running on the windows or android platform performance wi fi aware, similar to awdl for the apple platform, offers significantly higher bandwidth compared to bluetooth le, allowing for low latency, high speed data transfers between android or windows devices the following specifications are approximations; the type of device and platform and network configurations ultimately determine range and performance bandwidth capacity discoverability range distance durability 2 4 to 5 ghz frequency range 1 gigabyte per 8 ‑ second interval 100 to 300 meter maximum 100 to 300 meter maximum limitations wi fi aware connections have a limited range of shorter distances compared to bluetooth le, which can be sustained for distances up to 130 meters local area network when devices are connected over the same wi fi access point or through other means like an ethernet cable, they can take advantage of a local area network ( lan ), if available, to communicate directly with each other without requiring internet access a lan is an interconnected network made up of devices that are physically near each other, such as a home, enterprise, or college campus to ensure that ditto’s discovery protocol is working effectively, it is important to disable the client isolation mode feature on the wi fi router or access point that you are using for the lan for instructions, see the official documentation provided by the manufacturer note that the exact name of the feature may vary depending on the manufacturer and the specific model of wi fi router or access point; however, the term “isolation” is commonly included in the feature name performance in general, lan based connections offer significantly higher bandwidth capacities compared to bluetooth le, allowing for low latency, high speed data transfers the following specifications are approximations; the quality of the network infrastructure, network configurations, and the amount of network traffic ultimately determine range and performance disabled by default, if you want devices located within the same lan to find and identify each other automatically, manually enable ip multicasting entitlement for each device (see /#optimizations ) bandwidth capacity discoverability range distance durability traditional lans 1 to 10 mbps maximum; higher for fiber optic lans 200 meter maximum 200 meter maximum limitations the following are common conditions that contribute to a decline in lan performance factor description network congestion when there is a high volume of network traffic, in which multiple devices utilize the lan at the same time, data transfer speeds and response times lag distance to the router or access point when devices are physically located far away from the router or access point, connections become unreliable or even unavailable altogether network security and privacy network infrastructure enabled with various security controls, such as the client isolation mode feature, may directly or indirectly affect performance (see /#security and privacy client isolation mode ) ios direct connections with desktop based apps by default, ios devices require the ip multicast entitlement to establish direct connections with desktop platforms, such as windows (see /#ios to desktop connections ) optimizations this section provides an overview of the different optimization strategies you can use to make the most out of your lan setup for instance, improve the overall responsiveness of your lan connection by minimizing bandwidth consumption and enhancing the reliability of your peer to peer lan connections optional discovery protocol ip multicasting ditto optionally offers an optimized discovery protocol that utilizes the user datagram protocol (udp) and employs internet protocol ( ip ) multicasting ip multicasting is a method of reducing traffic on the lan and optimizing performance of automatic device discovery disabled by default, if you want devices located within the same lan to find and identify each other automatically, manually enable ip multicasting entitlement before ios devices can establish a direct connection with desktop platforms over lan, the end user must grant permissions for more information, see ios to desktop lan connections security and privacy client isolation mode if network infrastructure is configured with client isolation mode enabled, devices are unable to discover each other and form a lan connection client isolation mode is a network security and privacy feature offered by most wi fi routers and access points that prevents devices on the same wi fi network from communicating directly to ensure that ditto’s discovery protocol is working effectively, it is important to disable the client isolation mode feature on the wi fi router or access point that you are using for the lan for instructions, see the official documentation provided by the manufacturer note that the exact name of the feature may vary depending on the manufacturer and the specific model of the wi fi router or access point; however, the term “isolation” is commonly included in the feature name ios to desktop connections apple requires ios device end users to grant permissions before a lan connection with desktop based devices can be established, such as an ios device connecting directly with a desktop app running on the windows operating system by default, ios devices can connect with other mobile devices of any platform for example, an ios device can connect directly with an android device over lan if you want your ios app to connect to desktop based apps over lan, request the multicast entitlement directly from apple, and then, once received, add the multicast entitlement to your ios app for instructions, see the official apple documentation > entitlements > https //developer apple com/documentation/bundleresources/entitlements/com apple developer networking multicast websockets small peers connect with the big peer by way of websocket connections supported on all devices, regardless of model and platform, the websocket communication protocol is the most commonly available transport protocol for realtime communication a websocket is a full duplex communication protocol that enables a long lived connection between small peers and the big peer communication is full duplex when the client and server can communicate in a bidirectional, back and forth manner allowing for low latency data exchange a connection is considered long lived when, once established, it remains open for an extended period referred to as the playground token , small peers use this passphrase to authenticate with the big peer once authenticated, the big peer issues a unique json web token (jwt) to establish and ensure the persistence of the connection between small peers and the big peer as long as the playground token remains active, your connection persists (see docid 061yvo55q5yrbtwj5bsxc ) lan based websocket connections unlike other transports for peer to peer communication, the websocket does not come with built in automatic device discovery capabilities so establishing a websocket connection between devices over lan, specify an ip/port for a lan based websocket connection (see docid\ zuw1dwpowaimbpntcb3z3 )