1 Introduction

Mobile molecular communication is a growing field that explores the use of molecules as carriers of information in mobile environments, often utilizing biological systems. Unlike traditional wireless communication methods that use electromagnetic waves, molecular communication relies on the exchange of molecules to transmit data between nanoscale devices. Mobile molecular communication finds applications in various fields, including healthcare, environmental monitoring, and nanotechnology. In healthcare, it can be used for targeted drug delivery or monitoring biological processes at the cellular level. In environmental monitoring, it can detect pollutants or monitor soil conditions. For example, densely populated networks of bacteria are explored with capabilities for disease monitoring and treatment in minute areas of the human body [1]. The study introduces a modeling method to understand the dynamics of these populous bacterial communities and assesses their effectiveness in diagnostics and drug delivery. This approach is instrumental in identifying design trade-offs for dense bacterial networks, aiding in the creation of predictable and reliable synthetic multicellular systems. Additionally, a nanosensor coordination strategy is examined for efficiently targeting deep-seated areas [2]. These areas are typically remote from nanosensors' main patrol routes, such as blood vessels, and rely heavily on natural diffusion, which is often inefficient. This strategy, inspired by bacterial communication and mobility, involves a decentralized method where a few nanosensors detecting a distant target can recruit others. This research offers a potential breakthrough in cancer treatment, particularly in targeting the central necrotic core of tumors, where therapeutic agents are usually ineffective. The paper then presents a mobile molecular communication model using a leader–follower–amplifier system for cooperative drug delivery [3]. This model segments system functionalities among three types of bio-nanomachines: leaders, followers, and amplifiers. It introduces an adaptive threshold detection algorithm, tailored for binary signaling in bio-nanomachines, to address challenges like intersymbol interference and the energy constraints of these nanomachines [4]. Furthermore, a derivative-based detection method is proposed, leveraging the shorter peak time and faster vanishing tail of the channel impulse response's (CIR) derivative compared to the CIR itself [5]. This method demonstrates superior performance in high data rate scenarios, where traditional detection schemes falter due to the short symbol interval. The research also investigates a demodulation scheme for mobile receivers in a three-dimensional environment with drift [6]. It proposes solutions for intersymbol interference (ISI), bit alignment, and an adaptive threshold for accurate demodulation. Moreover, two distance estimation methods based on the concentration sensed by the receiver nanomachine (RN) are proposed [7].

The contribution of this study is the hybrid model created. In this hybrid model, firstly, datasets consisting of mobile receivers and receivers are prepared in the 3D environment. Secondly, features are extracted from the receiver and transmitter molecules together with the strengths of CNN & LSTM. Finally, with machine learning algorithms, the diffusion constant, which greatly affects the number of molecules sent from the receiver to the transmitter, and the distance between the receiver and the transmitter are estimated.

2 Related Work

Research in mobile molecular communication is ongoing, with scientists exploring novel techniques to improve communication efficiency, range, and reliability. This includes developing advanced nanoscale devices for molecule release and detection, as well as designing sophisticated algorithms for communication and information processing. The methods estimate distance through the measurement of either concentration peak timing or the energy of received concentration. Experiments are performed to assess the precision and robustness of these techniques against noise in the diffusion channel. Additionally, the article explores the estimation of channel parameters within a channel characterized by an inverse Gaussian distribution [8], providing an understanding of how to estimate propagation distance, medium speed, and diffusion coefficient. It further introduces an iterative method for estimating maximum likelihood of the localization of nanomachines, considering noise dependent on the signal and intersymbol interference (ISI) [9]. The research outlines conditions for unique localizability of the transmitting nanomachine (TN) and the bounds of the proposed estimator. Furthermore, the document introduces a framework for depicting channels that change over time in systems of diffusive molecular communication [10]. This considers a fluid setting in which nanomachines, acting as both transmitters and receivers, experience Brownian motion. The study also explores a system of mobile molecular communication influenced by drift, emphasizing the transfer of information between nanomachines via both direct and relay-supported routes [11]. A three-dimensional diffusive mobile molecular communication system in an unbounded environment is considered, deriving a closed-form expression for the expected hitting rate in such a scenario [12]. The fundamental concepts of various learning methodologies, including supervised, unsupervised, and reinforcement learning, are established, examining their adoption in mobile and wireless communication [13]. The paper discusses the potential of machine learning in meeting 5G network requirements, highlighting specific use cases and evaluating their impact and limitations. A comprehensive survey of machine learning applications in IoT wireless communications, particularly in ad hoc networking, is provided [14]. This includes an extensive background on machine learning techniques and an examination of machine learning in IoT across different protocol layers, along with discussions on hardware implementation feasibility. The study proposes a concentration-encoded molecular communication system using a modulation scheme called concentration position-shift keying (CPSK) [15]. Moreover, the paper delves into an end-to-end learning method for signal recovery in a mathematical multiple-input--multiple-output (MIMO) molecular communication (MC) system with drift, based on a Kullback–Leibler divergence (KLD) evolutionary generative adversarial network (EGAN) [16]. This method undergoes offline training using both real sampled signals and synthetic signals produced by the KLD EGAN and is subsequently utilized for real-time signal recovery. Additionally, it introduces a proof of concept for using a Convolutional Neural Network (CNN) to demodulate signals via concentration shift keying. This concept is assessed through experimental data, and its performance is compared to that of a traditional learning method [17]. The study also investigates a molecular communication system with intersymbol interference [18], demonstrating the efficacy of a receiver based on artificial neural networks trained on empirical data. Additionally, artificial neural networks are utilized to model the received signal for a spherical transmitter and a perfectly absorbing receiver [19]. To address the challenge of substantial, varying attenuation affecting optical signal transmission through water bodies, a modified CNN model is proposed for data recovery in underwater optical wireless communication [20]. Lastly, the paper discusses a deep learning-based autoencoder approach for designing a new drug source and target for molecular communication networks (MCN) under white Gaussian noise [21]. This approach aims to develop a robust mechanism for future healthcare applications, mapping MCN to molecular signaling and communication found in and around the human body. [22] introduces a drug delivery system utilizing mobile molecular communication (MMC) with a transmitter monitoring drug concentration and instructing the receiver for delivery in the extracellular fluid (ECF). It proposes two detection methods, DAD and DED, to mitigate noise and ISI, transmitting Manchester-coded bits via modified concentration shift keying (MCSK) and employing an adaptive threshold technique at the receiver for signal estimation, distance estimation, and ISI mitigation, validated through particle-based simulations showing low bit error rate (BER) and promising outcomes. [23] addresses challenges in mobile molecular communication (MC) systems caused by time-varying channel impulse response due to nanomachine mobility, proposing a novel non-coherent detection method based on energy differences between adjacent symbols, designed for mobile scenarios and capable of handling intersymbol interference (ISI) without channel state information (CSI). Simulation studies demonstrate the method's superior performance in bit error rate (BER), particularly in high-velocity short-distance mobile MC systems, suggesting its potential to mitigate nanomachine mobility challenges and enhance system performance. [24] delves into mobile molecular multiple-input--multiple-output (MIMO) communication employing bionanosensors as both transmitters and receivers, investigating the stochastic movement-induced time-varying channel impulse response (CIR) using Brownian simulators and deriving an average bit error rate (BER) expression. It formulates a multivariable optimization problem to minimize BER by optimizing the number of molecules released by each transmitter within specified bounds, introducing a novel deep neural network (DNN) algorithm to efficiently solve this problem, demonstrating improved runtime and BER compared to traditional genetic algorithms, achieving near-optimal solutions similar to exhaustive search methods. [25] introduces a new approach employing a convolutional neural network (CNN) architecture inspired by the success of machine learning in decision-making. Specifically designed for a molecular multiple-input–single-output setup, this approach aims to mitigate the negative impacts of molecular interference. Comparative analysis against index modulation and symbol-by-symbol maximum likelihood estimation reveals superior performance of the proposed method. The study in [26] introduces a molecular multiple-input--multiple-output (MIMO) channel model that features spherical transmitters and receivers equipped with partially absorbing ligand receptors, characterized by four distinctive parameters. It applies a supervised learning algorithm for the accurate estimation of molecule counts within the reception area, achieving consistent outcomes as evaluated by the root mean square error (RMSE) metric. These estimations provide valuable insights into ligand–receptor binding statistics, effectively addressing issues of intersymbol interference (ISI) and molecular interference. Notably, the application of convolutional and recurrent neural network (CNN & RNN) strategies surpasses the effectiveness of traditional threshold-based detection methods. Specifically, the CNN-based approach significantly improves the mean bit error rate (BER) performance, tripling its efficiency. Furthermore, the significance of feature optimization or selection is highlighted in numerous studies as a key determinant of performance [27,28,29]. The research presented in [30] investigates the use of deep learning (DL) algorithms for differentiating between normal and abnormal BBI traffic, providing dynamic and scalable approaches to feature engineering. A comprehensive validation process revealed that a hybrid ensemble of convolutional and recurrent networks (CNN + LSTM) achieved a high accuracy rate of about ~ 93.51%, outperforming other deep and shallow models. This hybrid DL approach facilitated automatic extraction of both static and dynamic features from BBI data, thereby obviating the necessity for manual feature selection and improving the accuracy of predictions. The findings advocate for the integration of the most effective classifier into conventional intrusion detection frameworks as well as into advanced non-Von Neumann architectures to enable real-time detection of anomalies.

3 System Model

In this research, our attention is centered on molecular communication via diffusion (MCvD) systems, where molecules act as signal carriers for transmitting information between nano- or micro-sized transmitters (Tx) and receivers (Rx) through diffusion. The motion of these molecules within the diffusion medium is modeled on the principles of Brownian motion, a concept that is also applied to the movement of Tx and Rx in this environment. Our model simulates the movement of carrier molecules by breaking down the simulation period into small intervals or time steps. During each of these time intervals, a random movement is introduced in each of the three spatial dimensions, allowing the molecules to traverse a three-dimensional space. Based on this dynamic framework, the total displacement (∆x) of the molecule, as well as that of Tx and Rx (referred to as nanomachines), within an n-dimensional space during a given time step (∆t) is calculated. This approach provides a detailed understanding of the spatial behavior of these entities within the MCvD system [31, 32].

$$N\left(\upmu , {\sigma }^{2}\right),$$
(1)
$$\left({x}_{i},{y}_{i},{z}_{i}\right)=\left({x}_{i-1},{y}_{i-1},{z}_{i-1}\right)+\left({\Delta x}_{i},{\Delta y}_{i},\Delta {z}_{i}\right),$$
(2)
$$\left({\Delta x}_{i},{\Delta y}_{i},\Delta {z}_{i}\right)=N\left(0, 2D\Delta t\right)\quad for\quad i=\text{1,2},3\dots ..,$$
(3)
$$\Delta x={(\Delta x}_{1}+{\Delta x}_{2}+\dots \dots {\Delta x}_{i}),$$
(4)

In this context, the terms, \(\left({x}_{i},{y}_{i},{z}_{i}\right)\) and \({\Delta x}_{i}\) denote the location and displacement of the nanomachines in the nth dimension, respectively. The symbol ∆t refers to the time step, while D represents the diffusion coefficient. The term N(μ,σ2) describes a Gaussian (Normal) distribution with a mean (µ) and a variance (σ2). The movement of molecules from the Tx to the receiver Rx follows the principles of this Gaussian distribution as described. Additionally, the error function (erf), typically used in digital communication to analyze errors during information transfer from a transmitter to a receiver, is also considered relevant for assessing errors in the motion of molecules within a diffusion environment. This error function can be derived from the stated normal distribution probability density function in the following manner:

$$P\left(x\right)=\frac{1}{\sigma \sqrt{2\pi }}{e}^{- \frac{{(x-m)}^{2}}{2{\sigma }^{2}}},$$
(5)

For the standard normal distribution, the probability density function is specified with a standard deviation (σ) set to 1 and a mean (m) of 0. When the transformations z = (x—m) / σ and dz = dx / σ are implemented within the standard normal distribution function, the resulting probability density function P(x) is derived as follows:

$$P\left(x\right)dx= \frac{1}{\sqrt{2\pi }}{e}^{- \frac{{z}^{2}}{2}dz},$$
(6)

And the probability function representing the normal distribution along the z-axis starting from 0 can be derived as follows:

$$\emptyset \left( z \right) = \frac{1}{{\sqrt {2\pi } }}\mathop \smallint \limits_{0}^{z} e^{{ - { }\frac{{x^{2} }}{2}dx}} = \frac{1}{2}erf\left( {\frac{z}{\sqrt 2 }} \right)$$
(7)

By applying Eq. (7), one can derive the error function, erf(.), and the complementary error function, erfc(.), in the following manner:

$$\mathit{erf}\left(z\right)=\frac{2}{\sqrt{\pi }}{\int }_{0}^{z}{e}^{- {x}^{2}dx},$$
(8)
$$\mathit{erf}c\left(z\right)=1-\mathit{erf}\left(z\right),$$
(9)
$$\mathit{erf}c\left(z\right)=\frac{2}{\sqrt{\pi }}{\int }_{z}^{\infty }{e}^{- {x}^{2}dx}.$$
(10)

Guo and their team have observed that molecules traversing the channel toward the receiver (Rx) are absorbed either through chemical reactions or directly by the receptors. The initial instance when molecules reach the receptors is termed the first successful collision. The mathematical expression for calculating the likelihood of this first successful collision of a molecule released at time t, both in one-dimensional and three-dimensional spaces, is given as follows:

$${f}_{hit}^{1D}\left(t\right)=erfc\left(\frac{d}{\sqrt{4Dt}}\right)=\frac{d}{\sqrt{4\pi D{t}^{3}}}{e}^{-\frac{{d}^{2}}{4Dt}},$$
(11)
$${f}_{hit}^{3D}\left(t\right)=\frac{{r}_{r}}{d+{r}_{r}} erfc\left(\frac{d}{\sqrt{4Dt}}\right)=\frac{{r}_{r}}{d+{r}_{r}}\frac{d}{\sqrt{4\pi D{t}^{3}}}{e}^{-\frac{{d}^{2}}{4Dt}},$$
(12)

wheere \({r}_{r}\) and d signify the receiver's radius and the separation between the transmitter and the receiver's surface, correspondingly. The rate at which molecules collide with the receiver by time t is determined by integrating Eq. (12) over time. The likelihood of a molecule encountering the receiver is influenced by the receiver's size, the diffusion rate, and their mutual distance. The current work evaluates the proposed MCs framework by examining individual mobility rates (diffusion rates) for both Tx and Rx (represented by Drx and Dtx), along with the variable d, to the count of molecules received by the model. Every analysis acknowledges the presence of receptors on the receiver. A molecule that arrives at the receiver but does not engage with any receptor is not included in the count, as per reference [33].

3.1 Proposed Mobile Molecular Communication (MMC) Model

Molecular communication channels are generally categorized into two types [28, 34]. The first type involves channels characterized by Brownian motion, where molecules move in response to concentration gradients in a purely diffusive environment, allowing molecular passage solely between two distinct areas [35]. The second type encompasses flow-based diffusion channels, in which molecular positioning is influenced by both fluid flow and diffusion. In this research, the focus is on the pure diffusion channel approach for the movement of nanomachines (NMs) within a fluid medium. The movement of these information-bearing molecules in the channel and their capability for information transmission is exclusively facilitated through molecular communication methods. Importantly, the mobility of the NMs can impact the rate at which information molecules are received by the NM receiver. Consequently, exploring the mobilities of NMs and their influence on molecule reception rates is a key aspect of this study [36]. The molecular communication (MC) model proposed here incorporates a point transmitter, a spherical receiver equipped with receptors, and carrier molecules serving as the medium of information transfer between the transmitter and receiver. Initially, the receiver is situated at the origin of a three-dimensional space (0, 0, 0), while the transmitter is placed at a random distance 'd' from the receiver within this 3D environment. In an attempt to mirror real biological systems, the positions of both the receiver and transmitter are adjusted periodically; the receiver's position changes with each time step, and the transmitter's position varies with each bit duration. This model assumes that both the transmitter and receiver are immersed in a fluid, infinite liquid diffusion environment, allowing the mobile nanomachines to move unrestrictedly in all directions. Molecules are released following Brownian motion and eventually reach the spherical receiver. This receiver, with a radius rs, utilizes its receptors to capture the incoming information molecules, as illustrated in Fig. 1. A successful reception occurs when a molecule collides with a receptor on the receiver's surface. Molecules that enter the receiver without interacting with any receptors are not considered received [33]. Additionally, the proposed model does not account for potential collisions between nanomachines. Using Eq. (13), the total (cumulative) number of molecules captured by a fully absorbing spherical receiver is calculated. This equation outlines the chances of the receiver taking in a molecule within the diffusion context, omitting the receptors, at any given time t:

Fig. 1
figure 1

Designed model

$${F}_{hit}\left(t\right)=\frac{{r}_{r}}{{r}_{0}}erfc\left(\frac{d}{\sqrt{4Dt}}\right),$$
(13)

where \({r}_{0}\) represents the span separating the center of the transmitter from the receiver and t is the duration elapsed since the molecule's discharge (release) [37]. However, in our sophisticated model that accounts for receptors, the receiver's molecule absorption likelihood is modified, leading to the formulation of Eqs. (14) and (15) from the base of Eq. (13).

$${x}_{1}=\left(\frac{{nr}_{s}+{\pi r}_{r}}{\pi {r}_{r}^{2}}\right),$$
(14)
$$\begin{aligned}{F}_{hit}^{{r}_{s,n}}\left(t\right)&=\frac{{r}_{r}}{{r}_{0}}\frac{{r}_{s}n}{{r}_{s}n+{\pi r}_{r}}(1+\text{erf}\left[\frac{{r}_{r}-{r}_{0}}{\sqrt{4Dt}}\right]\\ & \quad -\text{exp}\left[\left({r}_{0}-{r}_{r}\right)\left({x}_{1}\right)+Dt\Bigg({{x}_{1})}^{2}\right]\\ & \qquad *erfc\left[\frac{{r}_{0}-{r}_{r}+2Dt\left({x}_{1}\right)}{\sqrt{4Dt}}\right]\Bigg).\end{aligned}$$
(15)

Mobility is a further aspect considered in our model for nanomachines. While Eq. (15) initially applies to immobile nanomachines, it can be adapted for the dynamic version. In this scenario, Eq. (16) is computed across a range of values, subsequently arriving at the mean of \({F}_{hit}^{{r}_{s,n}}\) (t). The number of molecules received in the interval between \({t}_{1}\) and \({t}_{2}\) is shown as follows:

$${F}_{hit}^{{r}_{s,n}}\left({t}_{1},{t}_{2}\right)={F}_{hit}^{{r}_{s,n}}\left({t}_{2}\right)-{F}_{hit}^{{r}_{s,n}}\left({t}_{1}\right).$$
(16)
Algorithm 1
figure a

Procedure for Simulating the Mobile Molecular Communication (MC) Model.


Algorithm 1 provides a framework for simulating MMC between transmitter and receiver devices. Depending on the specific application and environmental conditions, the algorithm can be extended and customized with additional features and optimizations. Following the guidelines in Algorithm 1, the parameters of the molecular communication MMC are configured to optimize the uptake of molecules, focusing mainly on the diffusion constant and the spatial separation between the transmitter and receiver. In other words, Algorithm 1 is continually and automatically invoked to calculate the number of molecules taken for these parameters. The steps of the algorithmic structure are given sequentially.

4 CNN and LSTM models

In this study, the diffusion constant and the distance between the transmitter and receiver, which are of great importance in the molecular communication system, are also estimated using mobile transmitters and receivers. The proposed model consists of a hybrid of CNNs and LSTM. Hybrid CNN and LSTM model is widely used in many fields [29, 38]. After setting parameters and preparing the dataset with the designed simulator, features are extracted using CNN and LSTM.

4.1 Convolutional Neural Network

The CNN model is technically structured with several layers, including convolution, pooling, fully connected layers, and a classification layer [39]. The initial layer, convolution, is responsible for feature extraction from an input image. This is achieved by applying a filter—the convolution process—to the input image to create a feature map. Common filters used in this process include those for edge detection, blurring, and sharpening, and they are typically smaller in height and width than the input image. The convolution formula is presented in Eq. (17), where f represents the input image and h denotes the kernel. The resulting matrix's row and column indices are labeled m and n.

$$G\left[m,n\right]=\left(f*h\right)\left[m,n\right]=\sum_{j}\sum_{k}h\left[j,k\right]f[m-j,n-k]$$
(17)

Subsequent to each convolution step, an activation function is employed. In deep networks, the Rectified Linear Unit (ReLU) is frequently used for this purpose, introducing non-linearity to the model. The ReLU function is detailed in Eq. (18)

$${\text{ReLU}}\left( {\text{x}} \right) \, = {\text{ max}}\left( {{\text{x}},0} \right)$$
(18)

The pooling layer, a different fundamental component of pre-trained deep networks, serves to reduce the spatial size of the image post-convolution, thus expediting computational processes [40]. The fully connected layers play a crucial role in image recognition and classification within deep networks. These layers take the output from previous layers, flatten it, and convert it into a singular vector, preparing it for the next processing stage. In these layers, feature inputs are processed, and weights are adjusted to accurately predict labels. The final stage is the output layer, which predicts probabilities for each label. The Softmax function, commonly used in this layer, is outlined in Eq. (19).

$$\text{Softmax}{(x)}_{j}=\frac{{e}^{xi}}{\sum_{n=1}^{N}{e}^{{x}_{n}}} , j=1\dots .N$$
(19)

4.2 LSTM Model

Long Short-Term Memory, a distinct model of the Recurrent Neural Network methodology for analyzing time series data, emerged in the latter part of the 1990s [41]. Typically, with the Recurrent Neural Network technique, each segment of incoming data is scrutinized iteratively, considering the preceding outcome's value. Although this architecture is claimed to learn by considering information from previous time intervals, it has been stated that this is not possible due to the problem of gradient vanishing/exploding [42, 43]. LSTM architecture, capable of remembering long-term information, has been developed to overcome this problem. Typically, the architecture of Long Short-Term Memory (LSTM) includes three distinct layers: the forget layer, input layer, and output layer [44, 45]. Within the LSTM framework, the initial step involves determining the information to be discarded, utilizing the input data Xt and the previous output ℎt − 1. This decision-making process occurs in the forget layer (ft), as described by Eq. (20), where the sigmoid function is employed as the activation function.

$$ft\, = \,(Wf,x\, * \,Xt\, + \,Wf,h\, * \,ht\, - \,{1}\, + \,bf)$$
(20)

In the second phase, the input layer, which will determine the new information, comes into play and first updates the information with the sigmoid function by employing Eq. (21). Next, the candidate data, which will contribute to creating new information, are identified using Eq. (22) with the tanh function.

$$it = (Wi,x * Xt + Wi,h * ht - {1} + bi)$$
(21)
$$\tilde{c}t = \tan h(Wc,x * Xt + Wc,h * ht - {1} + bc)$$
(22)

New information is created by Eq. (23).

$$Ct\, = \,Ct\, - \,{1}\, * \,ft\, + \,it\, * \,C\tilde{t}$$
(23)

Finally, the output data are obtained in the output layer using Eq. (24) and (25).

$$ot\, = \,(Wo,x\, * \,Xt\, + \,Wo,h\, * \,ht\, - \,{1}\, + \,bo)$$
(24)
$$ht = ot * {\text{tan}}h(Ct)$$
(25)

The above-described process continues repeatedly. The model learns the weight parameters (W) and bias parameters (b) to reduce the discrepancy between the actual (real) training values (or targets) and the output values generated by the LSTM.

4.3 Designed CNN and LSTM Model

Initially, the features gathered from the samples in the dataset were passed through the designed CNN. Then, the features obtained from the CNN were inputted into the LSTM. Additionally, the same experiments will be conducted separately using CNN and LSTM. One of the important factors affecting the performance of CNN and LSTM is the number of layers and filters [29, 46,47,48,49]. The architecture of the constructed CNN includes one input layer, two convolutional layers, two pooling layers, two densely connected layers, and a single-output layer, making up a total of six distinct layers. The initial convolutional layer is equipped with 128 filters, while the subsequent convolutional layer contains 64 filters. ReLU will be used as the activation function. Also, after each convolution and ReLU operation, maximum pooling of 2 × 1 size will be performed. After the convolution layers, the data were passed through the LSTM layer. The designed CNN and LSTM models are given in Fig. 1.

4.4 Classification

Classification is performed with Linear Support Vector Machine (L-SVM), Quadratic Support Vector Machine (Q-SVM), Cubic Support Vector Machine (C-SVM), Random Forest, and K-Nearest Neighbor (K-NN).

L-SVM: It is a machine learning algorithm used to classify data points or perform regression analysis. L-SVM is suitable for linearly separable datasets. The goal is to create a hyperplane between classes.

Q-SVM: It is an extended version of SVM for handling data sets that are not linearly separable. It uses a feature space extended to include the square of features to handle nonlinear relationships.

C-SVM: It is similar to Q-SVM but extends the features into cubic terms to handle nonlinear relationships.

Random Forest: It is an ensemble learning method created by combining a series of decision trees. Each tree is trained using random sampling and random feature selection. The result is obtained by averaging the predictions from the trees.

K-NN: It is a classification or regression algorithm. To classify or predict a data point, it uses the average of the labels of the k data points closest to it. This method relies on a measure of similarity between data points.

4.5 Dataset

In the recommended molecular communication (MMC) framework, the trajectory of molecules that transmit signals is derived from the theory of normal distribution, as described by Eqs. (14), across a three-dimensional expanse. Additionally, it is considered that the error function (erf), which is used to analyze errors during information transfer from transmitter to receiver as in digital communication, is also suitable for evaluating errors in the movement of molecules in a diffusion environment. The event where molecules released from the transmitter reach the receiver for the first time is called the first successful collision. Equation (12) is used to calculate the probability of the first successful collision of a molecule released at time t in three-dimensional space with the receiver. Ultimately, Eq. (14) presents the rate at which molecules released from the transmitter arrive at the receiver, incorporating the presence of receptors on the receiver, as derived using Eq. (12). Two different datasets were obtained using the proposed model. The first dataset is obtained for four different values of the diffusion constant representing the motion of the transmitter and receiver in a three-dimensional plane. The second dataset is obtained for the distance value between the transmitter and receiver, which significantly affects the number of molecules received. For this dataset, four different distance values were obtained. In the first dataset, the diffusion constant of the receiver and transmitter is defined as input, while in the second dataset, the distance between the receiver and transmitter is defined as input. The ratio of molecules received by the receiver is specified as output in both datasets. The data obtained from the datasets have not been published online and will be shared upon request from the responsible author. Two datasets are prepared for the study. These datasets and classes are explained in detail in Sect. 3.2. The first dataset is prepared for estimating the diffusion coefficient, consisting of 20,000 samples and four classes. These classes are Drx = 0-Dtx = 0, Drx = 79.4-Dtx = 0, Drx = 0-Dtx = 79.4, and Drx = 79.4-Dtx = 79.4. The second dataset is prepared for estimating the distance between the receiver and sender molecules, consisting of 20,000 samples and four classes: d = 5, d = 10, d = 15, and d = 20. The distribution of the prepared datasets and class labels is given in Table 1.

Table 1 Distribution of the dataset

4.6 Evaluation Metrics

The classification performances of the models were calculated based on accuracy, precision, recall, and f1-score. The formulas used to calculate these criteria are given below. Here, TP stands for true positive, TN for true negative, FP for false positive, and FN for false negative.

$${\text{Accuracy}}\text{=}\frac{\left|{\text{TP}}\right|\text{+}\left|{\text{TN}}\right|}{\left|{\text{TP}}\right|+\left|{\text{TN}}\right|+\left|{\text{FP}}\right|\text{+}\left|{\text{TN}}\right|}$$
(26)
$${\text{Precision}}\text{=}\frac{\left|{\text{TP}}\right|}{\left|{\text{TP}}\right|+\left|{\text{FP}}\right|}$$
(27)
$${\text{Recall}}\text{=}\frac{\left|{\text{TP}}\right|}{\left|{\text{TP}}\right|\text{+}\left|{\text{FN}}\right|}$$
(28)
$$\text{F1} - {\text{score}}\text{=}\frac{2{\text{PrecisionRecall}}}{\text{Precision+Recall}}$$
(29)

5 Results

5.1 MMC Results

This research presents a novel MMC model designed to increase the reception of Molecular Messages (MMs) at the receiver. In this model, the transmitter (T), receiver (R), and carrier molecules (MM) are all capable of moving within a fluid environment. This marks a departure from earlier studies, as it permits the independent adjustment of the mobility of T and R based on varying diffusion coefficient (D) values. The model's effectiveness is evaluated by examining the mobilities of T and R, as well as the distance (d) between them. Specifically, the study investigates the impact of varying distances between the mobile T and R components. The simulation outcomes, depicted in Figs. 2, 3, 4, and 5, illustrate how the fraction of received molecules diminishes as the distance between T and R increases, using Drx = Dtx = 79.4 μm2/s for different d values. Furthermore, Figs. 2, 3, 4, and 5 also explore the model's behavior for various Dtx and Drx values, keeping d fixed at 5 μm. These values represent the mobility levels of T and R; for instance, Drx = 0 indicates a stationary state. This part of the study examines the scenarios where either T or R is stationary while the other is mobile, as well as cases where both are mobile with different mobility rates (Drx, Dtx). The investigation aims to understand the implications of varying mobility combinations on the efficiency of molecular message transmission.

Fig. 2
figure 2

Fraction of received molecules versus time for 4 different diffusion constant values of Tx and Rx when d = 5 um

Fig. 3
figure 3

Fraction of received molecules versus time for 4 different diffusion constant values of Tx and Rx when d = 10 um

Fig. 4
figure 4

Fraction of received molecules versus time for 4 different diffusion constant values of Tx and Rx when d = 15 um

Fig. 5
figure 5

Fraction of received molecules versus time for 4 different diffusion constant values of Tx and Rx when d = 20 um

Fraction of received molecules versus time for the distance (at t = 0 s) between R and T is equal to 5, 10, 15, and 20 um as shown in Fig. 2, 3, 4 and 5, respectively. Fraction of received molecules represents division of number of received molecules at receiver to number of iterations. 5-bit sequences are used for this proposed system model to show interference between bits and how bit duration affects system. The highest fraction of received molecule values are obtained in Fig. 3 for d = 5 um as expected because we know that distance between T and R is one of the important parameters and affect communication quality. The lowest fraction of received molecules values are obtained in Fig. 6 for d = 20 um. Almost same results are obtained for Dtx = 79.4 μm2/s, Drx = 79.4 μm2/s and Dtx = 0 μm2/s, Drx = 79.4 μm2/s values; this shows that mobility of T does not affect the model output as shown in Fig. 3. However, mobility of R affects the model output well as shown in Fig. 3 for Dtx = 79.4 μm2/s, Drx = 0 μm2/s and Dtx = 0 μm2/s, Drx = 0 μm2/s values. The figures illustrate that a higher fraction of molecules is received when the receiver (Rx) has greater mobility (Drx = 79.4 μm2/s). When the mobility of the receiver (Rx) is low (Drx = 0 μm2/s), the rate at which molecules are received is at its minimum. This is since an increase in the diffusion constant results in greater movement of both the transmitter and receiver at each time step.

Fig. 6
figure 6

Confusion matrix of the best classification results with L-SVM a Dataset-I (diffusion coefficient) b Dataset II (distance)

After fraction of received molecules is obtained for different diffusion constants of Tx and Rx and distance between Tx and Rx, then these two important parameters are classified using CNN and LSTM methods in the following part.

5.2 Classification of Diffusion Constant and Distance Between Tx and Rx

For the estimation of system and environmental parameters like diffusion coefficient and the distance between mobile transmitters and receivers, various experiments were conducted using features extracted from CNN and LSTM with different classifiers. All experiments were conducted on a computer with an Intel Core i5 CPU, 2.9 GHz, 32 GB RAM, and 1 Nvidia GTX 4050 Ti GPU. The model weights were randomly initialized with a fixed learning rate of 0.001. Cross-entropy and mean square root loss functions were used for training the LSTM models. The datasets were divided for testing and training using the tenfold cross-validation method. SVM, Random Forest, and K-NN were used as classifiers. The reason for using these classifiers is that these classifiers use less memory and provide high accuracy in small-dimensional data sets, as they use a sub-set of training points in the decision stage. There are generally 4%-5% differences between the results obtained from these classifiers. The reason for these differences is that the samples in the dataset are randomly separated for testing and training, and especially the fact that SVM works better on our datasets than other classifiers. Experiment results were given with metrics such as accuracy, precision, recall, and f1-score. Table 2 presents the results obtained for both datasets using L-SVM and different feature vectors. For the classification of diffusion coefficients with CNN & LSTM feature vectors, the highest accuracy rate was 87.63%, the highest precision rate was 87.00%, the highest recall value was 87.37%, and the highest f1-score value was 87.13%. For estimating the distance between transmitter and receiver by employing CNN & LSTM feature vectors, the highest accuracy rate was 87.97%, the highest precision rate was 87.96%, the highest recall value was 86.10%, and the highest f1-score value was 88.00%. Figure 6 shows the confusion matrices for the best classification results obtained from L-SVM and CNN & LSTM hybrid feature vectors for both datasets separately. Confusion matrix is a matrix that shows the relationship between actual and predicted classes. This matrix contains four different values: True Positive (TP), True Negative (TN), False Positive (FP), and False Negative (FN).

Table 2 Results obtained from L-SVM and different feature vectors

TP represents the number of examples that the model correctly classified as positive, TN represents the number of examples that the model correctly classified as negative, FP represents the number of examples that the model incorrectly classified as positive, and FN represents the number of examples that the model incorrectly classified as negative. The labels on the Y-axis in the confusion matrices represent the actual class or label values. This refers to the actual classes of samples in the test dataset. That is, each row represents the actual class. The labels on the x-axis represent the predicted class or label values. Each column represents the model's predictions for a class.

Table 3 presents the results obtained for both datasets using Q-SVM and different feature vectors. For the classification of diffusion coefficients with CNN & LSTM feature vectors, the highest accuracy rate was 86.21%, the highest precision rate was 87.76%, the highest recall value was 88.04%, and the highest f1-score value was 88.14%. For estimating the distance between transmitter and receiver by employing CNN & LSTM feature vectors, the highest accuracy rate was 87.21%, the highest precision rate was 88.23%, the highest recall value was 88.31%, and the highest f1-score value was 87.64%. Figure 7 shows the confusion matrices for the best classification results obtained from Q-SVM and CNN & LSTM hybrid feature vectors for both datasets separately.

Table 3 Results obtained from Q-SVM and different feature vectors
Fig. 7
figure 7

Confusion matrix of the best classification results with Q-SVM a Dataset-I (diffusion coefficient) b Dataset II (distance)

Table 4 presents the results obtained for both datasets using C-SVM and different feature vectors. For the classification of diffusion coefficients with CNN & LSTM feature vectors, the highest accuracy rate was 87.04%, the highest precision rate was 87.38%, the highest recall value was 87.02%, and the highest f1-score value was 87.69%. For estimating the distance between transmitter and receiver by employing CNN & LSTM feature vectors, the highest accuracy rate was 88.09%, the highest precision rate was 87.41%, the highest recall value was 88.58%, and the highest f1-score value was 88.41%. Figure 8 shows the confusion matrices for the best classification results obtained from C-SVM and CNN & LSTM hybrid feature vectors for both datasets separately.

Table 4 Results obtained from C-SVM and different feature vectors
Fig. 8
figure 8

Confusion matrix of the best classification results with C-SVM a Dataset-I (diffusion coefficient) b Dataset II (distance)

In Table 5, the results obtained for both datasets using Random Forest and different feature vectors are presented. For the classification of diffusion coefficients using CNN & LSTM feature vectors, the highest accuracy rate was 87.10%, the highest precision rate was 86.53%, the highest recall value was 87.95%, and the highest f1-score value was 87.95%. For estimating the distance between the transmitter and receiver using CNN & LSTM feature vectors, the highest accuracy rate was 87.40%, the highest precision rate was 87.21%, the highest recall value was 87.13%, and the highest f1-score value was 88.30%. Figure 9 shows the confusion matrices for the best classification results obtained from Random Forest and CNN & LSTM hybrid feature vectors for both datasets separately.

Table 5 Results obtained from Random Forest and different feature vectors
Fig. 9
figure 9

Confusion matrix of the best classification results with Random Forest a Dataset-I (diffusion coefficient) b Dataset II (distance)

Table 6 presents the results obtained for both datasets using K-NN and different feature vectors. The number of nearest neighbors for K-NN was selected as 5. For the classification of diffusion coefficients with CNN & LSTM feature vectors, the highest accuracy rate was 86.03%, the highest precision rate was 84.86%, the highest recall value was 85.73%, and the highest f1-score value was 86.02%. For estimating the distance between transmitter and receiver by employing CNN & LSTM feature vectors, the highest accuracy rate was 85.84%, the highest precision rate was 86.07%, the highest recall value was 86.49%, and the highest f1-score value was 85.96%. Figure 10 shows the confusion matrices for the best classification results obtained from K-NN and CNN & LSTM hybrid feature vectors for both datasets separately.

Table 6 Results obtained from K-NN and different feature vectors
Fig. 10
figure 10

Confusion matrix of the best classification results with K-NN a Dataset-I (diffusion coefficient) b Dataset II (distance)

6 Conclusion

In this study, we present an advanced model of MMC, where both the Tx and Rx, along with MM, are mobile within a fluid environment. Our goal is to increase the likelihood of MMs reaching the receiver efficiently. This approach stands out from previous research by allowing both the Tx and Rx to move, with their mobility adjusted based on different diffusion coefficients (D values). The receiver's position is continuously updated, while the transmitter's position changes with each bit interval during simulation. Incorporating a receptor adds a realistic touch, resembling biological cell behavior closely. Our findings reveal that using 5 bits, molecule reception rates are higher when Tx and Rx exhibit the highest D values. Despite a greater average distance between Tx and Rx in mobile systems, reception rates increase due to more receivers being in proximity to Tx, thereby enhancing communication quality. Future improvements will focus on developing more dynamic and biologically inspired systems, considering factors like precise drift velocity, blood vessel branching, and the impact of blood molecules. Additionally, integrating deep neural networks for accurate Tx and Rx position estimation is anticipated, leading to a dynamic model with reduced signal-to-interference ratios and improved molecule reception probabilities. We achieved an 87.68% accuracy rate for diffusion coefficient estimation using the designed deep CNN & LSTM model, and an 88.09% accuracy rate for estimating the distance between transmitter and receiver.