Hereby, we have highlighted the process that is deployed to transmit the information among the devices through IoT. The clear depiction of data transmission among IoT is delivered through the below mentioned steps.
Ns3 Code to Send Information between IoT Devices
Most significantly, Ns3 is deployed to perform the data or information transmission among the IoT nodes through the utilization of two protocols such as UDP and TCP. For instance, we have highlighted the sample code to send information among IoT devices in the following.
TypeId tid1 = TypeId::LookupByName ("ns3::UdpSocketFactory");
recvSink1->Bind (local1);recvSink1->SetRecvCallback (MakeCallback (&ReceivePacket));
Ptr source = Socket::CreateSocket (c.Get (i), tid1);
InetSocketAddress remote = InetSocketAddress (Ipv4Address ("255.255.255.255"), 80);
source->SetAllowBroadcast (true);source->Connect (remote);
OnOffHelper onoff ("ns3::TcpSocketFactory", Address ());
onoff.SetAttribute ("DataRate", DataRateValue (dataRate));
onoff.SetAttribute ("PacketSize", UintegerValue (packetSize));
ApplicationContainer IoTApp = onoff.Install (c);
IoTApp.Start (Seconds (0.10)); IoTApp.Stop (Seconds (5.0));
Cooja Code to Send Information between IoT Devices
As an additional note, we have highlighted the data transmission process using Cooja among the IoT nodes through the deployment of TCP socket and UDP socket. In addition, we have highlighted the sample code to send data based on length.
int len = MIN(s->output_data_max_seg, uip_mss());
if(s->output_senddata_len > 0) {
len = MIN(s->output_senddata_len, len);
s->output_data_send_nxt = len;
uip_send(s->output_data_ptr, len);
}
That’s it, through the above mentioned protocols, we have transmitted the data among IoT devices and if you have any queries you can contact us.