A simple BGP setup example with two nodes peering with each other.
#include "ns3/core-module.h"
#include "ns3/csma-module.h"
#include "ns3/applications-module.h"
#include "ns3/internet-module.h"
#include "ns3/bgp.h"
#include "ns3/ptr.h"
int main () {
NodeContainer n;
n.Create(2);
InternetStackHelper internet;
internet.Install(n);
CsmaHelper csma;
NetDeviceContainer d = csma.Install(n);
Ipv4AddressHelper ipv4;
ipv4.SetBase("10.0.0.0", "255.255.255.0");
Ipv4InterfaceContainer i = ipv4.Assign(d);
Ptr<Bgp> bgp_app_1 = CreateObject<Bgp>();
bgp_app_1->SetAttribute("RouterID", Ipv4AddressValue(i.GetAddress(0)));
bgp_app_1->SetAttribute("LibbgpLogLevel", EnumValue(libbgp::DEBUG));
bgp_app_1->AddPeer(bgp_app_1_peer);
n.Get(0)->AddApplication(bgp_app_1);
Ptr<Bgp> bgp_app_2 = CreateObject<Bgp>();
bgp_app_2->SetAttribute("RouterID", Ipv4AddressValue(i.GetAddress(1)));
bgp_app_2->AddRoute(Ipv4Address("10.1.0.0"), Ipv4Mask("/24"), i.GetAddress(1));
bgp_app_2->AddPeer(bgp_app_2_peer);
n.Get(1)->AddApplication(bgp_app_2);
bgp_app_1->SetStopTime(Seconds(100));
bgp_app_2->SetStopTime(Seconds(100));
Simulator::Run();
Simulator::Stop(Seconds(100));
Simulator::Destroy();
return 0;
}