Keywords

1 Introduction

The anatomy of the human body consists of tens of trillions of cells, which need to communicate with each other to respond to any stimulus produced by any organ [1]. In this context, one of the main advances in engineering applied to medicine is molecular communications (MCs). This type of communications seeks to place a transmitting nanomachine and a receiving nanomachine inside the human body (see Fig. 1) [2]. The nanomachines could collect and exchange information using the same methods employed by the body at the microscopic level, such as diffusion (through molecules), motor proteins (through vesicles), or bacterial motility (through bacteria) [3].

Fig. 1.
figure 1

Molecular communication scheme [2].

MCs are fundamental in the near future for personalized medicine [4, 5]. In this way, diseases could prevented by monitoring health in real time and highly effective treatments could carried out [6]. In turn, it will be possible to counteract a virus or bacteria before it gains strength, thanks to the sensing given by the nano-sensors.

According to [3], the research in MCs is divided into fundamental research, technology development and technology demonstration. Fundamental research (the most developed area) comprises the theoretical basis of MCs. On the other hand, technology development is the current area where researchers are focused. Technological development encompasses various activities such as physical layer signals, MAC layer protocols, chemical reactions and coding, and transmitting and receiving hardware. Finally, technology demonstration involves the design and fabrication of prototypes.

Due to the high costs involved in experimentation in MCs, research work in these sub-areas is completely theoretical and relies on simulation models for the analysis, design and optimization of mathematical or analytical models [7]. The most commonly used simulators in MCs are NanoNs, MUCIN, N3Sim, dMCS, BINS, nanoNS3 and BNsim [3].

Currently, there is no implementation of a diffusion-based propagation model in NS-3. The closest work found in the literature is a simulation with a bacterial propagation model [8]. The main advantage of implementing an MC module in NS-3 lies in complementing the physical layer with higher layers of communication; this would allow establishing a complete simulation of MCs between two nano-nodes. Table 1 shows a comparison between the different MC simulators with their main features.

Table 1. Comparison between the different simulators of MCs [3].

In general, researchers do not adhere to a common framework and this hinders the integration of research. For this reason, the IEEE proposes the 1906.1-2015 standard as a recommended practice for the nanoscale and the MC framework [9].

The standard proposes a reference model for standardization of MCs to facilitate the integration in future research. As a complement, the standard provides a NS-3 module for MCs between a transmitting nano-node and a receiving nano-node. This simulation model is limited to transmitting a message, as long as the transmission rate does not exceed the channel capacity. Moreover, it works in an idealistic way, because no communication channel with losses or molecular motion is implemented. That is, it is assumed that all molecules reach the receiver and that there is no collision between them in their trajectory.

Fig. 2.
figure 2

Simulator architecture in NS-3 [9].

2 Design and Implementation

The simulator developed in NS-3 is based on the P1906 module. Substantial modifications were made to this module. The module initially contained only a general architecture of the MCs, consisting only by the components depicted in Fig. 2.

  1. a)

    Component 0: Message Carrier

    The carrier contains and transports the information, in this case the molecules. An active carrier generates its own movement and a passive carrier propagates through the medium in which it is found.

  2. b)

    Component 1: Motion

    It defines the motion capability for component 0. The motion provides the force required, regardless of direction, to transport the information efficiently through the communication channel.

  3. c)

    Component 2: Field

    It defines the organized movement of component 1, i.e. it gives the direction to the carrier so that it can reach the destination.

  4. d)

    Component 3: Perturbation

    It provides the service of different carriers, as needed, to represent a signal. This is considered modulation.

  5. e)

    Component 4: Specificity

    It defines the reception of the targeted carriers of component 3, performs carrier detection or reception when it has reached the target, improves the carrier’s connectivity to its intended receiver, and helps measure the efficiency of carriers arriving at their receiver.

The implementation performed is presented in the schematic of Fig. 3.

Fig. 3.
figure 3

Programming scheme.

Application mol-example: In this file the simulator application is developed. The components of the P1906 module and the NS-3 are used here. It has been modified the application implemented in the file mol-example.cc. The following parameters have been defined for the simulation:

  • nodeDistance \(\rightarrow \) Distance between the transmitting node and the receiving node(s).

  • nbOfMol \(\rightarrow \) Number of molecules used by the transmitter to modulate a symbol.

  • pulseInterval \(\rightarrow \) Pulse width to transmit and sense a symbol.

  • diffusionCoefficient \(\rightarrow \) Diffusion coefficient of the medium.

  • driftVelocity \(\rightarrow \) Drift velocity of the medium.

  • driftAngle \(\rightarrow \) Drift angle of the medium.

  • timeStep \(\rightarrow \) Time interval between simulation steps.

  • receptionRadio \(\rightarrow \) Reception Radio.

  • motionFreeOrDrift \(\rightarrow \) Defines the type of diffusion: (0) an MC with free diffusion or (1) an MC with drift.

  • upLimitVein \(\rightarrow \) Upper limit of the vein.

  • lowLimitVein \(\rightarrow \) Lower limit of the vein.

The nodes and devices are created along with their related components. Then, the common component Motion and the Medium are created. For this application, a constant mobility model is considered. Next, the module’s Helpers are used to connect the whole system. Finally, the information packets are created and the function is used to send the message to the communication interface of the transmitting node.

CommunicationInterface: Implements the function to send the packet to the transmitting interface.

Transmitter Communication Interface: It receives the message carrier properly modulated by perturbation. Then, it calls the function P1906Medium::HandleTransmission to send the carrier together with the Field component to the medium, and finally, it starts the transmission.

Component Perturbation: Within the function creates the carrier and performs the on-off keying (OOK) modulation to the bit packet. For the bit 1, it modulates nbOfMol molecules; and for the bit 0, it modulates 0 molecules.

Field Component: It receives the speed and drift angle parameters from the application. This component sends the received parameters to the Medium component, which in turn sends them to the Motion component for use in the BM with drift.

Message Carrier Component: The carrier has attributes such as the pulse interval, the number of molecules that are used for modulation, the transmission duration time and a vector representing the modulation.

Medium Class: This is the most important class. This is the channel of the MCs. As shown in Fig. 2, it contains the Motion component and takes data from the Message Carrier, Perturbation and Field components.

Four main functions are implemented in the Medium: HandleTransmission, Transmission, HandleReception, and Verify. The functions first and second perform the transmission of the molecules through the channel; they execute the BM of the molecules with or without drift by calling to the Motion component; it performs the BM for the \(n_{0}\) molecules released by each bit, i.e., all molecules are released at \(t_0=0\) and at each \(\varDelta t\) they move one position; then, for each position traveled, it is verified whether or not each molecule has reached the receiver. The increments are generated in parallel.

The third function, HandleReception, is called by the function HandleTransmission to terminate the transmission. A call to the communication interface of the receiver is made inside HandleReception. With this, the Medium delivers the message. The fourth function, Verify, is an extension of the receiver that is used to verify at each time step whether or not the molecules reached the receiver.

Motion Component: This component contains the functions related to the movement of the molecules. First, there is the function ComputePropagationDelay, in charge of calculating the delay, the time when the mean concentration of molecules in the receiver is maximum. To calculate the delay, Fick’s second law (2-D) [Eq. (1)], is derived and the result is equaled to zero. From the resulting expression the time is cleared and Eq. (2) is obtained as follows

$$\begin{aligned} C = \frac{M}{4\pi Dt} e^\frac{-r^2}{4Dt} \end{aligned}$$
(1)
$$\begin{aligned} delay = \frac{r^2}{4D} \end{aligned}$$
(2)

where, r is the distance between the transmitter and the receiver, and D is the diffusion coefficient.

Second, there is the function ComputeRVGauss, responsible for calculating the Gaussian random variable for the BM using a normal distribution with \(\mu = 0\) and \(\sigma ^2 = 2\pi \) [see Eq. (3)]. Next, there are the functions BrownianMotion and BrownianMotionDrift, which perform the BM of the molecules in a medium without drift and in a medium with drift, respectively. Both functions take the random variable resulting from ComputeRVGauss to define the direction of motion at each step a molecule takes.

Initially, the function BrownianMotion calculates the random variable \(\theta \). Then, using Eqs. (4), it calculates the next position of the molecule:

$$\begin{aligned} f_x(x)=\frac{1}{2\pi }exp\left( -\frac{x^2}{4\pi }\right) \end{aligned}$$
(3)
$$\begin{aligned} \begin{aligned} x_{i} = x_{i-1} + \sqrt{4D\varDelta t}\cos \theta _{i}\\ y_{i} = y_{i-1} + \sqrt{4D\varDelta t}\sin \theta _{i} \end{aligned} \end{aligned}$$
(4)

where \(x_{i}\) is the current position, \(x_{i-1}\) is the previous position, D is the diffusion coefficient, \(\varDelta t\) is the time step of each movement and \(\theta _{i}\) is the random variable that determines the direction of that movement.

On the other hand, the function BrownianMotionDrift performs exactly the same process as in the function explained above, but it is obtained from the Field component, the velocity, and the drift angle [see Eq. (5)]:

$$\begin{aligned} \begin{aligned} x_{i} = x_{i-1} + \sqrt{4D\varDelta t}\cos \theta _{i} + v_{x}\varDelta t\\ y_{i} = y_{i-1} + \sqrt{4D\varDelta t}\sin \theta _{i} + v_{y}\varDelta t \end{aligned} \end{aligned}$$
(5)

where v is the drift velocity.

Fig. 4.
figure 4

Bounce of a molecule with the vein wall.

In collisions, elasticity is considered to be equal to 1 and friction is considered to be equal to 0. For this reason, collisions are completely elastic and the angle of reflection is the same as the angle of incidence. Furthermore, the distance traveled by the molecule is the same at each step. The proposed scheme is shown in Fig. 4. There are four possible cases:

  1. a)

    The molecule goes forward and hits the upper wall of the vein.

  2. b)

    The molecule goes backwards and hits the upper wall of the vein.

  3. c)

    The molecule goes forward and hits the lower wall of the vein.

  4. d)

    The molecule goes backwards and hits the lower wall of the vein.

Finally, the function CalculateReceivedMessageCarrier is part of this component, where the total number of molecules arriving in each bit is calculated, taking into account the intersymbol interference (ISI). This information is loaded into the carrier to be sent to the receiver.

Receive Communication Interface: This class implements the function HandleReception and is invoked by ns3::Medium to start the reception process. HandleReception uses the component Specificity to receive or not the message.

The demodulation is performed based on a threshold k of molecules. If the mean concentration of received molecules c(rt) at a time t within the interval \(T_{s}\) exceeds the threshold, the received symbol is \(s=1\), otherwise \(s=0\) [see Eq. (6)].

$$\begin{aligned} \begin{aligned} \text {If} \quad \quad c(r,t)\ge k \quad \quad \rightarrow \quad \quad s=1 \\ \text {If} \quad \quad c(r,t)< k \quad \quad \rightarrow \quad \quad s=0 \end{aligned} \end{aligned}$$
(6)

Specificity Component: It checks if the channel capacity is greater than the transmission rate. If it is fulfilled, reception and demodulation is performed, otherwise not. According to [10], the channel capacity is given by \(C_{channel}=1/T_m\); where, \(T_m\) is the minimum pulse width for smooth transmission.

On the other hand, in [10] it is also stated that the transmission rate for diffusive molecular communications is given by \(RB = 1/T_s\); where, \(T_s\) is the pulse width at which a symbol is transmitted. Then, the minimum condition that must be met for the message to be received correctly is given by \(C_{channel} \ge RB\). Finally, the simulator is available for free use at https://github.com/eddyzg7/nanoDMC.

3 Results

In this section, firstly the results obtained are compared with that of the research carried out in [11] for the sake of validation. Then, four simulation scenarios are defined: free BM and BM with drift in an unconstrained medium and, free BM and BM with drift in a constrained medium. The results of the simulations has been analyzed. Within each scenario, a scheme consisting of a transmitting nanomachine, a receiving nanomachine and a medium through which the molecules will propagate is proposed. Depending on the bit to be sent, the nanotransmitter will release a certain number of molecules into the medium, so that through the BM they propagate and reach the receiver, where the information is demodulated based on a threshold.

3.1 Validation

To validate the simulator, the obtained results are compared with that of [11], which uses the N3Sim simulator. Table 2 compares the parameters used in [11] and the parameters that has been used in our simulations.

Table 2. Comparison of simulation parameters.

As shown in Table 2, there are parameters that are not considered in this simulator, such as the radius of the transmitter and the radius of the particle. Simulations were performed with the parameters shown in Table 2.

The result is illustrated in Fig. 5, where two curves are observed. The orange line is the mean concentration of molecules obtained by the simulator. The blue line is the analytical mean concentration of molecules established by Eq. (1).

Fig. 5.
figure 5

Mean concentration of molecules in the receiver.

It is observed that both curves are similar. The amplitude value is adjusted during the whole simulation time, and the maximum mean concentration in both cases is equal. Furthermore, the correlation between both curves has been calculated to be 88%. The implementation performed considers that the molecules are released simultaneously; this generates a pulse similar to a Dirac delta function \(\delta (k)\), with small pulse width.

On the other hand, Fig. 6 illustrates the results obtained by [11]. The blue line represents the analytical result obtained with Fick’s second law [Eq. (1)]. Each red dot is the mean concentration obtained in the receiver per unit time. If the results of Fig. 5 are compared with that of Fig. 6, it can be observed that the results are quite similar.

Fig. 6.
figure 6

Mean concentration of molecules in the receiver obtained by [11].

From this comparison, it is concluded that the results are validated, since they coincide with the mathematical model defined by Fick’s Law, and with the results obtained in the research [11].

3.2 Simulation Scenarios and Analysis

Table 3 indicates the simulation parameters. The simulation is performed for a free and drifting BM. Note that enough number of simulations were conducted to validate the results statistically.

The variable motionFreeOrDrift, varies between the values BROWNIANMOTION and BROWNIANMOTIONDRIFT, depending on whether it is simulated in a free or drifting BM, respectively. The variables upLimitVein and lowLimitVein are used only in a bounded medium.

Table 3. Simulation parameters.

a) Free Brownian motion

As an example, Fig. 7 illustrates the movement of one molecule that is emitted by the transmitter and reaches the receiver. The distance between the transmitter and receiver is 26 \(\upmu \)m. The black and green circles represent the transmitter and receiver nanomachines, respectively. Due to the free motion, the molecule moves randomly over the medium, i.e., it has no direction. For this reason, the molecule is delayed in reaching the receiver, as it makes a few turns before entering the receiving area.

Fig. 7.
figure 7

Free BM of a molecule that reaches the receiver.

Each molecule released by the transmitter has a different behavior. A set of molecules is needed to transmit a bit; this set of molecules is know as a pulse. Figure 8 depicts the train of pulses arriving at the receiver. These pulses represent the bit stream sent. The receiver demodulates the information based on the threshold. The molecules that arrive for the bits with a value of 0 are the result of the ISI, but since the amplitude is not large enough, they can be considered as white noise.

Fig. 8.
figure 8

Pulse train (11011001) arriving at the receiver.

b) Brownian motion with drift

The movement of one molecule is represented in Fig. 9 in a similar way as free BM was represented, using the same parameters except for the drift. At this scenario, the molecule is being influenced by the blood flow which gives it direction, and thus arrives faster at the receiver.

Fig. 9.
figure 9

BM with derivatization of a molecule that reaches the receiver.

Figure 10 illustrates the train of pulses received for the complete transmission of the message. The pulses are clearly defined for a bit 1 and a bit 0 with the drift. In contrast to the free BM (see Fig. 8), the mean concentration curve is more sharply defined due to the decrease in random noise in the drifted BM. It is shown that a more significant number of molecules arrive.

Fig. 10.
figure 10

Pulse train (11011001) arriving at the receiver.

Fig. 11.
figure 11

Free BM of a molecule reaching the receiver, bounded by the walls of the arterioles.

c) Free brownian motion bounded by the width of the medium

In addition to the implementation of the diffusive propagation model in NS-3, a medium bounded by blood vessel walls has been proposed. This medium limits the movement of the molecules. When the medium is large enough with respect to the size of the nanomachines, it can be considered as an infinite plane; however, when the sizes are comparable, the medium limits the motion of the molecules. The implemented model is detailed in Sect. 2. According to [12], the diameter of a small artery called an arteriole is 100 \(\upmu \)m. For this reason, a value of 50 \(\upmu \)m is placed at each boundary. In Fig. 11 the result of the free BM bounded by the walls of the arterioles is visualized.

The behavior of the molecule remains chaotic; however, by limiting the space through which it moves, the possibility of reaching the receiver increases. When the molecule reaches the arteriole wall, it collides elastically and takes a new direction until it stabilizes. The effect of the walls will be reflected in the increase of the mean concentration of molecules in the receiver.

Figure 12 depicts the number of molecules in the receiver over the time, for the transmission of an 8-bit stream. It can be seen that there is more interference between bits and the pulse amplitude has increased.

Fig. 12.
figure 12

Pulse train (11011001) at the receiver in a bounded medium for free BM.

d) Brownian motion with drift bounded by the width of the medium

For a BM with drift, Fig. 13 visualizes the simulation result of the movement of a molecule arriving at the receiver. In this case, the molecule does not touch the walls of the arterioles and reaches the receiver without so much travel in the medium. However, the behavior of each molecule is different. Therefore, other molecules will not reach the receiver as fast.

Fig. 13.
figure 13

BM derived from a molecule that reaches the receiver in a medium bounded by the walls of the arterioles.

For a complete transmission of a bit stream, one has the pulse train shown in Fig. 14. The results show well-defined pulses with minimal interference between bits; this result is characteristic of the BM with drift. In this case, the walls of the arterioles increase the amplitude of all received pulses.

Fig. 14.
figure 14

Pulse train (11011001) at the receiver for a BM with drift in a bounded medium.

4 Conclusions

A diffusive propagation model for MCs has been implemented in NS-3. Seven simulators have been found for MCs, but none use the IEEE 1906.1-2015 recommendation. In this work, the recommended standardization process is followed.

The results obtained from the simulations have been shown in Sect. 3. In each scenario, the motion of a particle and the received pulse train of the whole message are analyzed. The results show that the BM with drift is characterized by less chaotic motion and high particle concentration at the receiver due to steering by the medium flow. The pulses at the receiver are better defined and have little interference from molecules. On the other hand, the free BM is characterized by higher randomness in the movements, fewer molecules in the receiver, and higher noise due to delayed molecules.

In the third and fourth scenarios analyzed, the medium is bounded by the walls of an arteriole. For a bounded free BM, the results show that the number of molecules in the receiver increases considerably, as does the noise. On the other hand, for a BM with bounded drift, the mean concentration increases twice as much as in the previous case. The pulses are more defined, and there is less noise due to loose molecules.

In this work, inter-symbol interference was implemented. In this case, ISI is conceived as the effect produced by the molecules of a bit that do not reach the receiver and remain free in the medium. The results show that the interference is higher for the bounded or unbounded free BM scenario. Since a flow does not orient the molecules, they remain in the medium and arrive bit by bit in a non-corresponding bit time. To decrease this effect, one can use different modulations or consider a lifetime for the molecules. However, in most cases, it implies a more complex transmitter design, contrary to what is sought in MCs.

In general, BM with drift is the most realistic scenario, since it is logical that applications in the bio-medicine field are developed in fluid environments such as blood. However, in this work a one-way communication has been considered because in a bidirectional one, the negative effects of the flow will cause some issues in the communication. This is a challenge that nanomachine designers will have to face.