24
Introduction NS-3 Tutorial C2 Conclusion DCCN Tutorial C2: Communication Between Devices Within LAN/WLAN Networks Pavel Masek, Jiri Hosek Brno University of Technology, Faculty of Electrical Engineering and Communication, Department of Telecommunication. [email protected], [email protected] November 23, 2016

DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Embed Size (px)

Citation preview

Page 1: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

DCCN Tutorial C2: Communication BetweenDevices Within LAN/WLAN Networks

Pavel Masek, Jiri Hosek

Brno University of Technology,Faculty of Electrical Engineering and Communication,

Department of Telecommunication.

[email protected], [email protected]

November 23, 2016

Page 2: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

WISLAB Research Group – http://www.wislab.cz

WISLAB - Wireless System Laboratory of Brno

Coordinated by Dr. HosekExperienced researchers and MSc. / Ph.D.students

Working with the up-to-date equipment

Nowadays, focused mainly on the IoT domainCommunication in 4G / 5G mobile networks

Intel US, Huawei, AT&T, TUT, IITIS, PFUR, SUAI

SmartHome Gateway

Telekom Austria Group

Wearables

Augmented reality, smart glasses

MTC Communication in NS-3

Member of well-known alliances AllSeen Alliance or HGi

Contributor to 3GPP standards and recommendations

Page 3: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

DCCN Tutorials: Agenda

Tutorial #1 [Wed 23.11.16] - Communicationbetween devices within LAN/WLAN networks

Tutorial #2 [Thu 24.11.16] - Implementation of 4G cellularcommunication within the SmartGrid ecosystem

Tutorial #3 [Fri 25.11.16] - Implementation of QoSmechanisms for Device-to-Device (D2D) communicationbetween mobile devices

Main goal

From basic network topology to advanced communicationmechanisms used in today’s IoT/M2M scenarios – utilizingNetwork Simulator 3 (NS-3) tool for timely use-cases

Page 4: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

Network Simulator 3 (NS-3) – https://www.nsnam.org

NS-3 is written in C++, with bindings available forPython

Simulation programs are C++ executables or Pythonprograms

NS-3 is a GNU GPLv2 licensed project

Mainly supported fro Linux/Unix, MacOS, and FreeBSD

Currently, port to Visual Studio is available

No backwards compatibility with NS-2

In comparison with other network simulators, oriented tocommand-line and Unix (no IDE provided instandard NS-3 framework)

Page 5: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

NS-3 Simulation Basics

Simulation time advances in discrete jumps from eventto event

C++ functions schedule events to occur at specificsimulation times

Several supporting libraries, not system-installed, can be inparallel to NS-3 (netAnim, pybindgen, etc.)

A simulation scheduler orders the event execution

Simulation::Run() gets it all started

Simulation stops at specific time or when events end

Page 6: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

Motivation – Why to Use NS-3?

You want to study network performance or protocoloperation in a controllable or scalable environment

You are comfortable writing C++ or Python code, andcombining NS-3 with other code

You like the idea of working on an active open sourceproject

NS-3 has the models you are looking for, or you canprovide / integrate what is missing

Well-known projects

LENA (LTE-EPC Network Simulator)DCE (Direct Code Execution)

Page 7: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

Created Virtual Machine for Development

Created as a VMware virtual machine (possible to runvia VMware Workstation/Player or VirtualBox)

Based on Ubuntu 14.04 LTS 32bit (Long Term Support)Possible to make ”Snapshoots”

Already pre-configured

Eclipse environment bounded with NS-3 (no need todevelop straightforward from the command line; possible touse advanced debugger)Visualization tools: NetAnim, FlowMonitor, PythonvisualizerTracing: Wireshark, trace files in NS-3, routing tables, etc.

As the utilized version, NS-3.23 was chosen – verifiedfunctionality, stable, already contains new syntax

Page 8: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

Created Virtual Machine for Development

Created as a VMware virtual machine (possible to runvia VMware Workstation/Player or VirtualBox)

Based on Ubuntu 14.04 LTS 32bit (Long Term Support)Possible to make ”Snapshoots”

Already pre-configured

Eclipse environment bounded with NS-3 (no need todevelop straightforward from the command line; possible touse advanced debugger)Visualization tools: NetAnim, FlowMonitor, PythonvisualizerTracing: Wireshark, trace files in NS-3, routing tables, etc.

As the utilized version, NS-3.23 was chosen – verifiedfunctionality, stable, already contains new syntax

Page 9: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

Created Virtual Machine – Eclipse with NS-3 project

Page 10: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

Network Scenario – LAN/WLAN communication

Default network topology implementing IEEE 802.11PHY and MAC models

Scalable for future projects (number of nodes, usedcommunication technologies, etc.)

Intended network topologyThree groups of nodes (P2P, CSMA/CD, WiFi(CSMA/CA))

n0 n1 n2 n3 n4

Point-to-point

LAN 10.1.2.0/24

10.1.1.0/24n5n6n7

* * **AP

Wi-Fi 10.1.3.0/24

Page 11: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

Tasks

1 Check structure of given code, understand to topologyhelpers, containers, nodes, etc

2 Run the prepared simulation scenario

3 View output files (tracing files) via tcpdump andWireshark

4 Try to change provided code (rebuild the scenario) andcheck the output files (e.g., change source anddestination nodes for data transmission, amount ofpayload, etc.)

Page 12: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

T1: Point-to-point (P2P) Link

NodeContainer p2pNodes;

p2pNodes.Create (2);

// ------------------------------

PointToPointHelper pointToPoint;

pointToPoint.SetDeviceAttribute ("DataRate",

StringValue ("5Mbps"));

pointToPoint.SetChannelAttribute ("Delay", StringValue

("2ms"));

// ------------------------------

NetDeviceContainer p2pDevices;

p2pDevices = pointToPoint.Install (p2pNodes);

Page 13: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

T1: CSMA/CD Ethernet

NodeContainer csmaNodes;

csmaNodes.Add (p2pNodes.Get (1));

csmaNodes.Create (nCsma);

// ------------------------------

CsmaHelper csma;

csma.SetChannelAttribute ("DataRate",

StringValue ("100 Mbps"));

csma.SetChannelAttribute ("Delay", TimeValue (

NanoSeconds (6560)));

// ------------------------------

NetDeviceContainer csmaDevices;

csmaDevices = csma.Install (csmaNodes);

Page 14: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

T1: CSMA/CA – WiFi

NodeContainer wifiStaNodes;

wifiStaNodes.Create (nWifi);

NodeContainer wifiApNode = p2pNodes.Get (0);

// ------------------------------

YansWifiChannelHelper channel = YansWifiChannelHelper

:: Default ();

YansWifiPhyHelper phy = YansWifiPhyHelper :: Default ();

// ------------------------------

phy.SetChannel (channel.Create ());

Page 15: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

T1: CSMA/CA – WiFi MAC Layer

NetDeviceContainer staDevices;

staDevices = wifi.Install (phy , mac , wifiStaNodes);

// ------------------------------

mac.SetType ("ns3:: ApWifiMac",

"Ssid", SsidValue (ssid));

// ------------------------------

NetDeviceContainer apDevices;

apDevices = wifi.Install (phy , mac , wifiApNode);

Page 16: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

T1: IP Configuration

Ipv4AddressHelper address;

// ------------------------------

address.SetBase ("10.1.1.0", "255.255.255.0");

Ipv4InterfaceContainer p2pInterfaces;

p2pInterfaces = address.Assign (p2pDevices);

// ------------------------------

address.SetBase ("10.1.2.0", "255.255.255.0");

Ipv4InterfaceContainer csmaInterfaces;

csmaInterfaces = address.Assign (csmaDevices);

// ------------------------------

address.SetBase ("10.1.3.0", "255.255.255.0");

address.Assign (staDevices);

address.Assign (apDevices);

Page 17: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

T1: ”Echo” Server

Location of echo server on the ”rightmost” node in thecreated network topology (CSMA/CD)

UDP service, port 9

UdpEchoServerHelper echoServer (9);

// ------------------------------

ApplicationContainer serverApps = echoServer.Install

(csmaNodes.Get (nCsma));

serverApps.Start (Seconds (1.0));

serverApps.Stop (Seconds (10.0));

// ------------------------------

Page 18: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

T1: ”Echo” Client

UdpEchoClientHelper echoClient (csmaInterfaces.

GetAddress (nCsma), 9);

echoClient.SetAttribute ("MaxPackets", UintegerValue

(1));

echoClient.SetAttribute ("Interval", TimeValue (

Seconds (1.0)));

echoClient.SetAttribute ("PacketSize", UintegerValue

(1024));

// ------------------------------

ApplicationContainer clientApps =

echoClient.Install (wifiStaNodes.Get (nWifi - 1));

clientApps.Start (Seconds (2.0));

clientApps.Stop (Seconds (10.0));

Page 19: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

T1: PCAP Tracing

pointToPoint.EnablePcapAll ("wlan_lan");

phy.EnablePcap ("wlan_lan", apDevices.Get (0));

csma.EnablePcap ("wlan_lan",csmaDevices.Get (0),true);

Pcap tracing started on both P2P nodes (CSMA/CA andCSMA/CD) – our backbone

Promiscuous mode configured on the WiFi (CSMA/CA)network

Page 20: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

T3: Captured Communication from ”Echo” Server

reading from file wlan_lan -1-1.pcap , link -type EN10MB

(Ethernet)

2.017837 ARP , Request who -has 10.1.2.4 (ff:ff:ff:ff:ff

:ff) tell 10.1.2.1 , length 50

2.017861 ARP , Reply 10.1.2.4 is-at 00:00:00:00:00:06 ,

length 50

2.017861 IP 10.1.3.3.49153 > 10.1.2.4.9: UDP , length

1024

2.022966 ARP , Request who -has 10.1.2.1 (ff:ff:ff:ff:ff

:ff) tell 10.1.2.4 , length 50

2.022966 ARP , Reply 10.1.2.1 is-at 00:00:00:00:00:03 ,

length 50

2.023072 IP 10.1.2.4.9 > 10.1.3.3.49153: UDP , length

1024

Page 21: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

T3: Captured Communication from ”Echo” Client

reading from file wlan_lan -1-1.pcap , link -type EN10MB

(Ethernet)

2.017837 ARP , Request who -has 10.1.2.4 (ff:ff:ff:ff:ff

:ff) tell 10.1.2.1 , length 50

2.017861 ARP , Reply 10.1.2.4 is-at 00:00:00:00:00:06 ,

length 50

2.017861 IP 10.1.3.3.49153 > 10.1.2.4.9: UDP , length

1024

2.022966 ARP , Request who -has 10.1.2.1 (ff:ff:ff:ff:ff

:ff) tell 10.1.2.4 , length 50

2.022966 ARP , Reply 10.1.2.1 is-at 00:00:00:00:00:03 ,

length 50

2.023072 IP 10.1.2.4.9 > 10.1.3.3.49153: UDP , length

1024

Page 22: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

T4: Possible Modifications (Individual Tasks)

1 Add number of WiFi nodes and change location of the”Echo” client node

2 Change number of transmitted data (payload)

3 Change total number of sent packets4 Check performed changes via Wireshark (pass: student)

Run terminal: sudo wiresharkOpen captured files

Page 23: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

Final Conclusion

We have got familiar with Network Simulator 3

Initial network topology created and simulated

Utilizing NS-3 structure (helpers, containers, etc.)Ready to be extended by other communication technologiesTracing of generated data traffic

Next time: Tutorial C4

Implementation of 4G (LTE) cellular communicationwithin the SmartGrid ecosystem

Page 24: DCCN 2016 - Tutorial 1 - Communication with LAN/WLAN

Introduction NS-3 Tutorial C2 Conclusion

Thank you for your attention.

Pavel Masek, Jiri Hosek

[email protected], [email protected]

Brno University of Technology,Faculty of Electrical Engineering and Communication,

Department of Telecommunication.