0% found this document useful (0 votes)
4 views3 pages

Q1

The document describes a simulation of peer-to-peer communication between a client and a server using the Point-to-Point protocol in NS3. It includes code for setting up a network topology with two nodes, configuring the network parameters, and running a UDP echo server and client. The simulation can be visualized using NetAnim and packet parameters can be analyzed through an ASCII trace file.

Uploaded by

rightpathhero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

Q1

The document describes a simulation of peer-to-peer communication between a client and a server using the Point-to-Point protocol in NS3. It includes code for setting up a network topology with two nodes, configuring the network parameters, and running a UDP echo server and client. The simulation can be visualized using NetAnim and packet parameters can be analyzed through an ASCII trace file.

Uploaded by

rightpathhero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Q1}Simulate peer-to-peer communica on between a client and a server using Point-to-

Point protocol. Apply NetAnim so ware to demonstrate the scenario graphically. Analyze
packet parameters by crea ng trace file using Ascii trace metrics.

CODE:

#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applica ons-module.h"

// Default Network Topology


//
// 10.1.1.0
// n0 -------------- n1
// point-to-point
//

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("FirstScriptExample");
int
main (int argc, char *argv[])
{
CommandLine cmd (__FILE__);
cmd.Parse (argc, argv);

Time::SetResolu on (Time::NS);
LogComponentEnable ("UdpEchoClientApplica on", LOG_LEVEL_INFO);
LogComponentEnable ("UdpEchoServerApplica on", LOG_LEVEL_INFO);

NodeContainer nodes; nodes.Create


(2);

PointToPointHelper pointToPoint; pointToPoint.SetDeviceA ribute


("DataRate", StringValue ("5Mbps"));
pointToPoint.SetChannelA ribute ("Delay", StringValue ("2ms"));
NetDeviceContainer devices; devices
= pointToPoint.Install (nodes);

InternetStackHelper stack; stack.Install


(nodes);

Ipv4AddressHelper address; address.SetBase


("10.1.1.0", "255.255.255.0");

Ipv4InterfaceContainer interfaces = address.Assign (devices);

UdpEchoServerHelper echoServer (9);

Applica onContainer serverApps = echoServer.Install (nodes.Get (1)); serverApps.Start


(Seconds (1.0)); serverApps.Stop (Seconds (10.0));

UdpEchoClientHelper echoClient (interfaces.GetAddress (1), 9);


echoClient.SetA ribute ("MaxPackets", UintegerValue (1)); echoClient.SetA
ribute ("Interval", TimeValue (Seconds (1.0))); echoClient.SetA ribute
("PacketSize", UintegerValue (1024));

Applica onContainer clientApps = echoClient.Install (nodes.Get (0)); clientApps.Start


(Seconds (2.0)); clientApps.Stop (Seconds (10.0)); Simulator::Run ();
Simulator::Destroy (); return 0;
}

OUTPUT:

You might also like