Session 6. Wired LAN in ns-3

Slides:



Advertisements
Similar presentations
Data Link Layer B. Konkoth. PDU  Protocol Data Unit  A unit of data which is specified in a protocol of a given layer  Layer 5, 6, 7 – Data  Layer.
Advertisements

CCNA3: Switching Basics and Intermediate Routing v3.0 CISCO NETWORKING ACADEMY PROGRAM Switching Concepts Introduction to Ethernet/802.3 LANs Introduction.
12.1 Chapter 12 Multiple Access Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
5: DataLink Layer5-1 Data Link Layer r What is Data Link Layer? r Multiple access protocols r Ethernet.
CMPE 150- Introduction to Computer Networks 1 CMPE 150 Fall 2005 Lecture 17 Introduction to Computer Networks.
1 Link Layer Message M A B Problem: Given a message M at a node A consisting of several packets, how do you send the packets to a “neighbor” node B –Neighbor:
5-1 Data Link Layer r Today, we will study the data link layer… r This is the last layer in the network protocol stack we will study in this class…
5: DataLink Layer5-1 Link Layer – Error Detection/Correction and MAC.
5: DataLink Layer5-1 Chapter 5 Link Layer and LANs Computer Networking: A Top Down Approach Featuring the Internet, 3 rd edition. Jim Kurose, Keith Ross.
16 – CSMA/CD - ARP Network Layer4-1. 5: DataLink Layer5-2 CSMA (Carrier Sense Multiple Access) CSMA: listen before transmit: If channel sensed idle: transmit.
Lecture 16 Random Access protocols r A node transmits at random at full channel data rate R. r If two or more nodes “collide”, they retransmit at random.
Chapter 5 outline 5.1 Introduction and services
5: DataLink Layer5-1 Chapter 5 Link Layer and LANs Part 3: MAC Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley.
1 Computer Communication & Networks Lecture 12 Datalink Layer: Multiple Access Waleed Ejaz
Brierley 1 Module 4 Module 4 Introduction to LAN Switching.
1 Computer Communication & Networks Lecture 13 Datalink Layer: Local Area Network Waleed Ejaz
4-1 Last time □ Link layer overview ♦ Services ♦ Adapters □ Error detection and correction ♦ Parity check ♦ Internet checksum ♦ CRC □ PPP ♦ Byte stuffing.
LECTURE9 NET301. DYNAMIC MAC PROTOCOL: CONTENTION PROTOCOL Carrier Sense Multiple Access (CSMA): A protocol in which a node verifies the absence of other.
Chapter 5 Link Layer Computer Networking: A Top Down Approach 6 th edition Jim Kurose, Keith Ross Addison-Wesley March 2012 Link Layer multiple.
Network Layer4-1 Lower limit on the number of check bits r We want to design a code m with m message bits and r check bits Allowing all single errors to.
Medium Access Control NWEN302 Computer Network Design.
Link Layer: MAC Ilam University Dr. Mozafar Bag-Mohammadi.
Cisco 3 - Switching Perrine. J Page 16/4/2016 Chapter 4 Switches The performance of shared-medium Ethernet is affected by several factors: data frame broadcast.
4: DataLink Layer1 Multiple Access Links and Protocols Three types of “links”: r point-to-point (single wire, e.g. PPP, SLIP) r broadcast (shared wire.
Final Review Focus- Chapter 4: Network layer Chapter 5: Data link layer Notes: Physical layer Understand previous chapters covered in class. Final exam.
Multiple Access.
5: DataLink Layer 5a-1 Multiple Access protocol. 5: DataLink Layer 5a-2 Multiple Access Links and Protocols Three types of “links”: r point-to-point (single.
Data Link Layer. Useful References r Wireless Communications and Networks by William Stallings r Computer Networks (third edition) by Andrew Tanenbaum.
Link Layer MAC Dr. Mozafar Bag-Mohammadi University of Ilam.
LECTURE9 NET301 11/5/2015Lect 9 NET DYNAMIC MAC PROTOCOL: CONTENTION PROTOCOL Carrier Sense Multiple Access (CSMA): A protocol in which a node verifies.
Dohyung Kim Computer network lab,
EE 122: Lecture 6 Ion Stoica September 13, 2001 (* this talk is based in part on the on-line slides of J. Kurose & K. Rose)
CCNA3 Module 4 Brierley Module 4. CCNA3 Module 4 Brierley Topics LAN congestion and its effect on network performance Advantages of LAN segmentation in.
Carrier Sense Multiple Access Improve ALOHA by using carrier sense –Stations listen to the carrier before transmitting –If channel is busy, the station.
Network and Systems Laboratory nslab.ee.ntu.edu.tw Copyright © Wireless Sensor Networks: Zigbee Stack Polly Huang Department of Electrical.
5: DataLink Layer5-1 Link Layer r 5.1 Introduction and services r 5.2 Error detection and correction r 5.3Multiple access protocols r 5.4 Link-layer Addressing.
Example DLL Protocols 1. High-Level Data Link Control (HDLC).
Link Layer 5.1 Introduction and services
Part III. Data Link Layer
Chapter 12 Multiple Access.
Lab 7 – CSMA/CD (Data Link Layer Layer)
CT301 LECTURE 8.
Chapter 5 Link Layer and LANs
Sidevõrgud IRT 4060/ IRT 0020 vooruloeng 6 / 20. okt 2004
Node, Stacks, and Devices
Chapter 12 Multiple Access
Computer Communication Networks
Multiple Access Mahesh Jangid Assistant Professor JVW University.
CS 457 – Lecture 6 Ethernet Spring 2012.
Net301 lecture9 11/5/2015 Lect 9 NET301.
Data Link Issues Relates to Lab 2.
Services of DLL Framing Link access Reliable delivery
Multiple access.
Session 8. LTE in ns-3 박태준 Multimedia & Wireless Networking Laboratory, SNU
Session 3. Pcap 출력, animator 사용법 및 ns-3 기본 제공 어플리케이션
CS 457 – Lecture 7 Wireless Networks
Session 2. Logging과 Command Line Argument 사용법
Session 1. ns-3 기초 신연철 Multimedia & Wireless Networking Laboratory, SNU
Chapter 12 Local Area Networks
NS3-Basic 문준영.
Overview Jaringan Komputer (3)
Link Layer and LANs Not everyone is meant to make a difference. But for me, the choice to lead an ordinary life is no longer an option 5: DataLink Layer.
Data Communication Networks
Dr. Mozafar Bag-Mohammadi University of Ilam
7- chapter Seven Local Area Networks (LAN)
Chapter 12 Local Area Networks
Figure 3.1 Internet model.
Chapter 12 Local Area Networks
Link Layer: Multiple Access
Chapter 12 Media Access Control (MAC)
Presentation transcript:

Session 6. Wired LAN in ns-3 Seongwon Kim Multimedia & Wireless Networking Laboratory, SNU skim11@mwnl.snu.ac.kr

Contents Multiple Access Protocols ns-3 Structures – CSMA OnOff Application Switch / Bridge Simulation Example

Multiple Access Protocols

Multiple Access Protocols Single shared broadcast channel Two or more simultaneous transmissions by nodes Collision if node receives two or more signals at the same time Multiple Access Protocol Distributed algorithm that determines how nodes share channel, i.e., determines when node can transmit Communication about channel sharing must use channel itself! No out-of-band channel for coordination

Random Access Protocols When node has packet to send Transmit at full channel data rate R No a priori coordination among nodes Two or more transmitting nodes ➜ collision Random access MAC protocol specifies How to detect collisions & recover from collisions (e.g., via delayed retransmissions) Examples of random access MAC protocols Slotted ALOHA ALOHA CSMA, CSMA/CD, CSMA/CA

CSMA (Carrier Sense Multiple Access) CSMA: Listen before transmit If channel sensed idle, transmit entire frame If channel sensed busy, defer transmission Human analogy: Don’t interrupt others! CSMA/CD (Collision Detection) Collisions detected within short time Colliding transmissions aborted, reducing channel wastage Human analogy: Polite conversationalist Collision detection Easy in wired LANs: Measure signal strengths, compare transmitted & received signals Difficult in wireless LANs: Receiver shut off while transmitting

ns-3 Structures - CSMA

MAC Model in ns-3 NetDevice class OpenFlowSwitchNetDevice AlohaNoAckNetDevice BridgeNetDevice CsmaNetDevice EmuNetDevice LoopbackNetDevice LteNetDevice MeshPointDevice NonCommunicatingNetDevice OpenFlowSwitchNetDevice PointToPointNetDevice SimpleNetDevice TapBridge UanNetDevice VirtualNetDevice WifiNetDevice WimaxNetDevice

CSMA Model The ns-3 CSMA device models a simple bus network in the spirit of Ethernet The ns-3 CSMA device does not model collision detection, nor will any transmission in progress be "jammed” CSMA channel class A single busy flag is used to indicate if the channel is currently in use (IDLE, TRANSMITTING, PROPAGATING) It does not take into account the distances between stations or the speed of light to determine collisions

CSMA Channel Model No fixed limit for the number of devices connected to the channel DataRate and Delay can be configured There is no way to independently set DataRates of devices Three states IDLE, TRANSMITTING and PROPAGATING IDLE  TRANSMITTING  PROPAGATING  IDLE

CSMA Net Device Model (1/3) This object is accessible through the following paths with Config::Set and Config::Connect /NodeList/[i]/DeviceList/[i]/$ns3::CsmaNetDevice Device Attribute parameters Address: The MAC address of this device Initial value: ff:ff:ff:ff:ff:ff Mtu: The MAC-level Maximum Transmission Unit in byte Initial value: 1500 EncapsulationMode: The link-layer encapsulation type to use Underlying type: Dix|Llc Initial value: Dix

CSMA Net Device Model (2/3) Device Attribute parameters (cont.) SendEnable: Enable or disable the transmitter section of the device Initial value: true ReceiveEnable: Enable or disable the receiver section of the device ReceiveErrorModel: Receiver error model used to simulate packet loss TxQueue: A queue to use as the transmit queue in the device.

CSMA Net Device Model (3/3) TraceSources defined for this type MacTx MacTxDrop MacPromiscRx MacRx MacTxBackoff PhyTxBegin PhyTxEnd PhyTxDrop PhyRxEnd PhyRxDrop Sniffer PromiscSniffer

CSMA Topology CSMA Network topology

CSMA Node Creation P2P Node creation Csma Node creation NodeContainer p2pNodes; p2pNodes.Create (2); Csma Node creation NodeContainer csmaNodes; csmaNodes.Add (p2pNodes.Get (1)); csmaNodes.Create (nCsma);

NodeContainer Class Functions NodeContainer (Ptr< Node > node) NodeContainer (const NodeContainer &a, const NodeContainer &b) void Create (uint32_t n) Create n nodes and append pointers to them to the end of this NodeContainer void Add (NodeContainer other) Append the contents of another NodeContainer to the end of this container void Add (Ptr< Node > node) Append a single Ptr<Node> to this container Ptr< Node > Get (uint32_t i) const Get the Ptr<Node> stored in this container at a given index uint32_t GetN (void) const Get the number of Ptr<Node> stored in this container

Node vs. NodeContainer NodeContainer Node NodeContainer csmaNodes; Access to Node: csmaNodes.Get (i) This is useful when you want to modify not a individual node but entire nodes Node Ptr<Node> n0 = CreateObject<Node> (); Ptr<Node> n1 = CreateObject<Node> (); NodeContainer that contains both n0 and n1 NodeContainer csmaNodes (n0, n1); When you want to modify a specific node

CsmaHelper Build a set of CsmaNetDevice objects Channel attribute parameters DataRate: The transmission data rate to be provided to devices connected to the channel Underlying type: DataRate Initial value: 4294967295bps Delay: Transmission delay through the channel Underlying type: Time Initial value: 0ns Modify the device Attribute parameters CsmaHelper csma; csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps")); csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));

CSMA Device Creation Net device CsmaHelper class functions NetDeviceContainer csmaDevices; csmaDevices = csma.Install (csmaNodes); csmaDevices = csma.Install (NodeContainer (n0, n1)); CsmaHelper class functions NetDeviceContainer  Install (Ptr< Node > node) const Install (Ptr< Node > node, Ptr< CsmaChannel > channel) const Install (const NodeContainer &c) const Install (const NodeContainer &c, Ptr< CsmaChannel > channel) const

CSMA Simulation Code (1/5) #include "ns3/core-module.h“ #include "ns3/network-module.h“ #include “ns3/csma-module.h“ #include "ns3/internet-module.h“ #include "ns3/point-to-point-module.h“ #include "ns3/applications-module.h“ #include "ns3/ipv4-global-routing-helper-module.h“ using namespace ns3; NS_LOG_COMPONENT_DEFINE ("SecondScriptExample"); int main (int argc, char *argv[]) { bool verbose = true; uint32_t nCsma = 3; To determine whether the logging components are enabled or not

CSMA Simulation Code (2/5) commandLine cmd; cmd.AddValue ("nCsma", "Number of \"extra\" CSMA nodes/devices", nCsma); cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose); cmd.Parse (argc,argv); if (verbose) { LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO); } nCsma = nCsma == 0 ? 1 : nCsma; NodeContainer p2pNodes; p2pNodes.Create (2); NodeContainer csmaNodes; csmaNodes.Add (p2pNodes.Get (1)); csmaNodes.Create (nCsma); Seperated Node generation for p2p and csma Node container for csma includes p2p second node

CSMA Simulation Code (3/5) PointToPointHelper pointToPoint; pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); NetDeviceContainer p2pDevices; p2pDevices = pointToPoint.Install (p2pNodes); /* CSMA link configuration */ CsmaHelper csma; csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps")); csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560))); /* Install CSMA links on the CSMA nodes */ NetDeviceContainer csmaDevices; csmaDevices = csma.Install (csmaNodes); InternetStackHelper stack; stack.Install (p2pNodes.Get (0)); stack.Install (csmaNodes);

CSMA Simulation Code (4/5) 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); UdpEchoServerHelper echoServer (9); ApplicationContainer serverApps = echoServer.Install (csmaNodes.Get (nCsma)); serverApps.Start (Seconds (1.0)); serverApps.Stop (Seconds (10.0)); UdpEchoClientHelper echoClient (csmaInterfaces.GetAddress (nCsma), 9); echoClient.SetAttribute ("MaxPackets", UintegerValue (100)); echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.))); echoClient.SetAttribute ("PacketSize", UintegerValue (1024));

CSMA Simulation Code (5/5) ApplicationContainer clientApps = echoClient.Install (p2pNodes.Get (0)); clientApps.Start (Seconds (2.0)); clientApps.Stop (Seconds (10.0)); Ipv4GlobalRoutingHelper::PopulateRoutingTables (); pointToPoint.EnablePcapAll ("second"); csma.EnablePcap ("second", csmaDevices.Get (1), true); Simulator::Run (); Simulator::Destroy (); return 0; }

Switch / Bridge

Network Topology Simple topology with a switch

Node Creation and CsmaHelper NodeContainer for terminal nodes NodeContainer terminals; terminals.Create (4); NodeContainer for the SwitchNode NodeContainer csmaSwitch; csmaSwitch.Create (1); CsmaHelper CsmaHelper csma; csma.SetChannelAttribute ("DataRate", DataRateValue (5000000)); csma.SetChannelAttribute ("Delay", TimeValue (MilliSeconds (2)));

CSMA Link Creation CSMA links from each terminal to the switch NetDeviceContainer terminalDevices; NetDeviceContainer switchDevices; for (int i = 0; i < 4; i++) { NetDeviceContainer link = csma.Install (NodeContainer (terminals.Get (i), csmaSwitch)); terminalDevices.Add (link.Get (0)); switchDevices.Add (link.Get (1)); }

BridgeHelper Add capability to bridge multiple LAN segment Bridge NetDevice creation Ptr<Node> switchNode = csmaSwitch.Get (0); BridgeHelper bridge; bridge.Install (switchNode, switchDevices); BridgeHelper class function NetDeviceContainer  Install (Ptr< Node > node, NetDeviceContainer c)

Internet Stack and IP address InternetStackHelper internet; internet.Install (terminals); IP address assignment Ipv4AddressHelper ipv4; ipv4.SetBase ("10.1.1.0", "255.255.255.0"); ipv4.Assign (terminalDevices); IPv4AddressHelper class void  SetBase (Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1") Ipv4InterfaceContainer  Assign (const NetDeviceContainer &c)

Simulation Example

Simulation Example Csma link: DataRate 5 Mbps, Delay 10 us Flows Onoff Application Flow 1: n0->n1, UDP 5 Mbps, 1 – 10 s OnTime= OffTime= 1 s Flow 2: n3->n0, UDP 10 Mbps, 3 – 13s OnTime= 0.3 s, OffTime= 0.7 s

Simulation Example Code (1/6) #include <iostream> #include <fstream> #include "ns3/core-module.h" #include "ns3/network-module.h" #include "ns3/applications-module.h" #include "ns3/bridge-module.h" #include "ns3/csma-module.h" #include "ns3/internet-module.h" using namespace ns3; static void Rxtime (Ptr<const Packet> p, const Address &a) { static double bytes=0; bytes+=p->GetSize(); NS_LOG_UNCOND(Simulator::Now().GetSeconds() << "\t“ << bytes*8/1000000/(Simulator::Now().GetSeconds()-1)); }

Simulation Example Code (2/6) int main (int argc, char *argv[]) { CommandLine cmd; cmd.Parse (argc, argv); /* Create nodes */ NodeContainer terminals; terminals.Create (4); NodeContainer csmaSwitch; csmaSwitch.Create (1); /* Create links */ CsmaHelper csma; csma.SetChannelAttribute ("DataRate", DataRateValue (5000000)); csma.SetChannelAttribute ("Delay", TimeValue (MicroSeconds (10))); NetDeviceContainer terminalDevices; NetDeviceContainer switchDevices;

Simulation Example Code (3/6) /* Connect switch node and terminal node */ for (int i = 0; i < 4; i++) { NetDeviceContainer link = csma.Install (NodeContainer (terminals.Get(i), csmaSwitch)); terminalDevices.Add (link.Get (0)); switchDevices.Add (link.Get (1)); } Ptr<Node> switchNode = csmaSwitch.Get (0); BridgeHelper bridge; bridge.Install (switchNode, switchDevices); /* Install Internet stack and assign IP addresses */ InternetStackHelper internet; internet.Install (terminals); Ipv4AddressHelper ipv4; ipv4.SetBase ("10.1.1.0", "255.255.255.0"); ipv4.Assign (terminalDevices);

Simulation Example Code (4/6) Ipv4AddressHelper ipv4; ipv4.SetBase ("10.1.1.0", "255.255.255.0"); ipv4.Assign (terminalDevices); uint16_t port = 9; /* Implement OnOff application */ OnOffHelper onoff ("ns3::UdpSocketFactory", Address (InetSocketAddress (Ipv4Address ("10.1.1.2"), port))); onoff.SetAttribute ("OnTime", StringValue(“ns3::ConstantRandomVariable[Constant=1.0]”) ); onoff.SetAttribute ("OffTime", StringValue(“ns3::ConstantRandomVariable[Constant=1.0]”) ); onoff.SetAttribute ("DataRate", DataRateValue(5000000)); ApplicationContainer app = onoff.Install (terminals.Get (0)); app.Start (Seconds (1.0)); app.Stop (Seconds (10.0));

Simulation Example Code (5/6) // Create an optional packet sink to receive these packets PacketSinkHelper sink ("ns3::UdpSocketFactory", Address (InetSocketAddress (Ipv4Address::GetAny (), port))); app = sink.Install (terminals.Get (1)); app.Start (Seconds (1.0)); // Create a similar flow from n3 to n0, starting at time 1.1 seconds onoff.SetAttribute ("Remote", AddressValue (InetSocketAddress (Ipv4Address ("10.1.1.1"), port))); onoff.SetAttribute ("DataRate", DataRateValue(10000000)); onoff.SetAttribute ("OnTime", StringValue(“ns3::ConstantRandomVariable[Constant=0.3]”) ); onoff.SetAttribute ("OffTime", StringValue(“ns3::ConstantRandomVariable[Constant=0.7]”) ); app = onoff.Install (terminals.Get (3)); app.Start (Seconds (3.0)); app.Stop (Seconds (13.0));

Simulation Example Code (6/6) app = sink.Install (terminals.Get (0)); app.Start (Seconds (3.0)); app.Get(0)->TraceConnectWithoutContext("Rx", MakeCallback (&Rxtime)); /* Enable Pcap tracing */ csma.EnablePcapAll (“session4_ex2", false); Simulator::Stop(Seconds (15)); Simulator::Run (); Simulator::Destroy (); }

Simulation Example Result

In-class Assignment Using Switch Example code, make a complete code based on following topology Csma link: DataRate 5 Mbps, Delay 10 us Flows OnOff Application Flow 1: n0->n1, UDP 5 Mbps, 1 – 10 s (always on) Flow 2: n3->n0, UDP 10 Mbps, 3 – 13 s (always on) Draw(trace) throughput (moving average with window size 100) curves regarding both flows

In-class Assignment Result