한국기술교육대학교 컴퓨터공학부 한연희 교수 yhhan@kut.ac.kr 고려대학교...

Post on 28-Dec-2015

265 Views

Category:

Documents

15 Downloads

Preview:

Click to see full reader

TRANSCRIPT

한국기술교육대학교 컴퓨터공학부 한연희 교수yhhan@kut.ac.kr

고려대학교 컴퓨터학과 최현영neongas@korea.ac.kr

NS-2 를 이용한 최신 네트워크 시뮬레이션 단기강좌

2/51

What is NS3?◦ ns-3 is a discrete-event network simulator for

Internet systems intended to eventually replace the ns-2 simulator not backwards-compatible with ns-2 a free, open source software project organized

around research community development and maintenance

◦ Main Groups Univ. of Washington, Georgia Tech., Bucknell University

◦ Financial Support U.S. National Science Foundation & INRIA

3/51

Architecture◦ ns-2

simulator core: c++ and Otcl script: Otcl

◦ ns-3 simulator core: c++ script: c++ bindings with Python, but can run ns-3 without any

knowledge of Python

ns-3 is not an extension of ns-2

4/51

Current Release◦ ns-3.9 (August 20, 2010)

Monthly download count of ns-3 releases

5/51

Progress Report (1/2)

6/51

Progress Report (2/2)◦ ns3-3.9 (August 20, 2010)

Spectrum Modeling OFDM Underwater Acoustic Network WiFi patches for bugs, etc. See the page: http://www.nsnam.org/wiki/index.php/Ns-3.9

◦ ns3-3.10 (Current On-going Activity) Initial support for the 802.11g PHY Consolidate Wi-Fi MAC high functionality Energy model WiFi additions LTE support, etc. See the page: http://www.nsnam.org/wiki/index.php/Ns-3.10

7/51

Features◦ Alignment with real systems

sockets, device driver interfaces)◦ conforms to standard input/output formats so that other

tools can be reused. e.g., pcap trace output

◦ ns-3 is adding support for running implementation code e.g., Linux TCP code

◦ P2P link, shared link with CSMA.◦ Routing, ARP◦ A node can be equipped with multiple network

interfaces.◦ Support (nearly) complete IPv6◦ Can run real implementation of applications.◦ Wireless

WiFi WiMAX UMTS (PPP)

8/51

Still use ns-2 or move to ns-3?◦ ns-3 does not have all of the models that ns-2 currently

has.◦ ns-3 does have new capabilities such as handling

multiple interfaces, use of IP addressing, more detailed 802.11 models.

Well-documented◦ extensively documented API (doxygen):

9/51

Network Emulation

virtualmachin

e ns-3

virtualmachin

e

realmachin

e

ns-3

Testbed

Testbed

realmachin

e

ns-3

1) ns-3 interconnects virtual machines

2) testbeds interconnect ns-3 stacks

real machine

Added in ns-3.5 Added in ns-3.3

10/51

LOG: PCAP Trace File 1

11/51

LOG: PCAP Trace File 2

12/51

LMM (Localized Mobility Management)

Domain

MAG

LMA

Proxy Binding Update/Ack. (PBU/PBA)

Control messages exchanged by MAG to LMA to establish a binding between

MN-HoA and Proxy-CoA

Home Network

Proxy Care of Address (Proxy-CoA)The address of MAG

That will be the tunnel end-point

IP Tunnel IP-in-IP tunnel between LMA and MAG

MAG

LMA: Localized Mobility AgentMAG: Mobile Access Gateway

LMA Address (LMAA)

MN’ Home Address (MN-HoA) MN continues to use it as long as

it roams within a same domain

That will be the tunnel entry-point

MN’s Home Network (Topological Anchor Point)

MN’s Home Network Prefix (MN-HNP)CAFE:2:/64

movement

13/51

No Change to Host Stack IP Mobility handled by the network, and transparent to the

host Any MN is just a IPv6 host

Home in Any Place MAG sends the RA (Router Advertisement) messages

advertising MN’s home network prefix and other parameters MAG will emulate the home link on its access link.

RA Unicast RA should be UNICASTed to an MN It will contain MN’s Home Network Prefix

Per-MN Prefix

M:1 Tunnel LMA-MAG tunnel is a shared tunnel among many MNs. One tunnel is associated to multiple MNs’ Binding Caches.

IPv4 Support RFC 5844 (May 2010)

14/51

• RA*: MN 의 Prefix 를 Policy Store 에서 수신한 경우의 Router Advertisement• RA**: MN 의 Prefix 를 LMA 에서 수신한 경우의 Router Advertisement

MN MAG AAA&Policy Store LMA CN

MN Attachment AAA Query with MN-ID

AAA Reply with Profile

PBU with MN-ID, Home Network Prefix option (all zero), Timestamp option

PBA with MN-ID, Home Network Prefix optionRouter Advertisement(Home Network Prefix)

[MN-HoA:CN](data)[Proxy-CoA:LMAA][MN-HoA:CN](data)

[MN-HoA:CN](data)

Tunnel Setup

PBU: Proxy Binding UpdatePBA: Proxy Binding Ack.

DHCP ServerDHCP Request

DHCP Response

DHCP Request

DHCP Response

Optional

15/51

Scenario 1: Setting up Mobility Sessions on Demand◦ Create additional mobility sessions on demand

e.g., additional connection for a particular service◦ A new mobility session with a new prefix is created

WiMax

MAG

LMA

PBU

MAG

3G

단말3GWiBro

MAG

LMA

PBU

MAG

단말3GWiBro

WiMax 3G

다른 인터페이스의 스위치를 올려서 단순하게

접속만 시도

플로우 이동은 없음

Mobile IPTVflow

VoIPflow

Mobile IPTVflow

VoIPflow

HTTPflow

16/51

Scenario 2: Flow Mobility◦ If another access is enabled on the MN, some of the

existing flows could be moved over, to achieve, e.g., load balancing and better user experience

MAG

LMA

PBU

MAGMAG

LMA

MAG

단말3G

새로운 인터페이스로 한 개의 세션을 이동

단말3GWiBro

VoIPflow

Mobile IPTVflow

WiMax 3GWiMax 3G

WiBro

Mobile IPTVflow

VoIPflow

PBU

17/51

Horizontal Handover

Vertical Handover

Multiple Interface Management

Multiple Flow Management

A handover is initiated when mobile device exits the boundaries of an administrative domain. Single interface is used.

A mobile device does need to move in order to initiate a handover. Multiple interfaces are required, but use one interface at a time.

Simultaneous use of multiple interfaces and access networks. Association of an application with an interface

Ability to split individual flows between links with respect to the requirements of the flows and the user preferences

Co

mp

lexi

t y L

evel

Host-based IP Mobility

Network-basedIP Mobility

Mobility Support in IPv6[RFC 3775, June 2004]

Hierarchical Mobile IPv6[RFC 4140, Aug. 2005]

Mobile IPv6 Support for Dual Stack Hosts and Routers

[RFC 5555, June 2009]

Fast Handovers for Mobile IPv6[RFC 4068, July 2005]

Multiple Care-of Addresses Registration

[RFC 5648, Oct. 2009]

Flow Bindings in Mobile IPv6 and NEMO Basic Support

[draft-ietf-mext-flow-binding-11]

Traffic Selectors for Flow Binding[draft-ietf-mext-binary-ts-05]

Proxy Mobile IPv6[RFC 5213, Aug. 2008]

IPv4 Support for Proxy Mobile IPv6[RFC 5844, May 2010]

Fast Handovers for Proxy Mobile IPv6[RFC 5949, Sept. 2010]

Multiple Care-of Addresses Registration & Flow Bindings in Proxy Mobile IPv6[draft-trung-netext-flow-mobility-support-01 & draft-bernardos-netext-pmipv6-flowmob-01]

[ 관련 WG: MEXT, MIPSHOP, NETEXT - 2010 년 10 월 현재 ]

18/51

19/51

Simulation Topology

Simulation Scenario◦ Ping(UDP) from n4 to n0

10.1.1.0n0 - - - - - - - - - - - - - n1 n2 n3 n4 point- to- point | | | | =========== LAN 10.1.2.0

20/51

Simulation Script◦ Create nodes

◦ Attach devices

int nCsma=3;

NodeContainer p2pNodes;p2pNodes.Create (2);

NodeContainer csmaNodes;csmaNodes.Add (p2pNodes.Get (1));csmaNodes.Create (nCsma);

PointToPointHelper pointToPoint;pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));

NetDeviceContainer p2pDevices; p2pDevices = pointToPoint.Install (p2pNodes);

CsmaHelper csma; csma.SetChannelAttribute ("DataRate", StringValue ("100Mbps")); csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));

NetDeviceContainer csmaDevices; csmaDevices = csma.Install (csmaNodes); 21/51

◦ Install IPv4/IPv6 network stack

◦ Assign IP address

InternetStackHelper stack; stack.Install (p2pNodes.Get (0)); stack.Install (csmaNodes);

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);

22/51

◦ Install UDP Echo server/client application

◦ Setup trace

◦ Start simulation

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 (1)); echoClient.SetAttribute ("Interval", TimeValue (Seconds (1.))); echoClient.SetAttribute ("PacketSize", UintegerValue (1024));

ApplicationContainer clientApps = echoClient.Install (p2pNodes.Get (0)); clientApps.Start (Seconds (2.0)); clientApps.Stop (Seconds (10.0));

pointToPoint.EnablePcapAll ("second"); csma.EnablePcap ("second", csmaDevices.Get (1), true);

Simulator::Run (); Simulator::Destroy ();

23/51

PCAP trace

24/51

25/51

Overview◦ Based-on NS-3 3.8◦ Implements some part of Mobile IPv6

Mobility header, BU/BA handler

◦ Designed for easy porting to newer version of NS-3

◦ Link-layer support: Wifi only

IPv6

MIPv6 functionality PMIPv6

26/51

Tunneling◦ TunnelNetDevice – IPv6-in-IPv6 creator (Encapsulator)◦ Ipv6TunnelL4Protocol – IPv6-in-IPv6 handler (Decapsulator)

Routing◦ Ipv6StaticSourceRouting – Source address based routing

Mobility header process◦ Ipv6MobilityL4Protocol – Mobility header handler◦ Ipv6MobilityDemux◦ Ipv6MobilityBindingUpdate – BU handler◦ Ipv6MobilityBindingAck – BA handler

PMIPv6 agent◦ Pmipv6Mag/ Pmipv6Lma – PBU/PBA processing◦ BindingUpdateList/BindingCache – Store binding information

Helper◦ MagHelper/ LmaHelper – Create and aggregate objects

Application◦ UnicastRadvd – Mac Unicast of RA in Wifi network

28/51

29/51

Important functions in Header class◦ Serialize()

Compose packet data from member variables◦ Deserialize()

Fill the variables in the class from the packet data◦ GetSerializedSize()

Get total bytes of packetized data◦ Print()

Print each field of header (used for ASCII-based trace)

30/51

Header implementation exampleclass Ipv6MobilityHeader : public Header{private: uint8_t m_payload_proto; uint8_t m_header_len; uint8_t m_mh_type; uint8_t m_reserved; uint16_t m_checksum;};

uint32_t Ipv6MobilityHeader::Deserialize (Buffer::Iterator start){ Buffer::Iterator i = start;

m_payload_proto = i.ReadU8(); m_header_len = i.ReadU8(); m_mh_type = i.ReadU8(); m_reserved = i.ReadU8(); m_checksum = i.ReadNtohU16();

return GetSerializedSize ();}

void Ipv6MobilityHeader::Serialize (Buffer::Iterator start) const{ Buffer::Iterator i = start;

i.WriteU8 (m_payload_proto); i.WriteU8 (m_header_len); i.WriteU8 (m_mh_type); i.WriteU8 (m_reserved); i.WriteU16 (0);}

uint32_t Ipv6MobilityHeader::GetSerializedSize () const{ return 6;}

void Ipv6MobilityHeader::Print (std::ostream& os) const{ os << "( payload_proto = " << (uint32_t)GetPayloadProto() << " header_len = " << (uint32_t)GetHeaderLen() << " mh_type = " << (uint32_t)GetMhType() << " checksum = " << (uint32_t)GetChecksum() <<")";}

31/51

33/51

(1) – MN attachment event trigger◦ Create binding update list

(2) – Sending PBU (3)~(5) – IPv6 packet transmission among nodes

◦ Packet(PBU) will be arrived at the LMA (6) – Received by mobility header handler (7)~(9) – Demultiplexing mobility header based

on Mhtype field in the packet (10) – Received by PBU handler

◦ Create or update binding cache◦ Setup tunneling and routing

34/51

(11) – Sending PBA (12)~(14) – IPv6 packet transmission

among nodes◦ Packet(PBA) will be arrived at the MAG

(15) – Received by mobility header handler (16) –(18) – Demultiplexing (19) – Received by PBA handler

◦ Update binding update list◦ setup tunneling and routing

35/51

36/51

(1)~(2) – IPv6 packet arrival◦ Data packet from source node, either CN or MN

(3)~(4) – Incoming packet process in IPv6◦ Query to routing module◦ (3)’~(4)’ – Subsequent routing query (default) ◦ (3)”~(4)” – Source based routing query only in MAG

Source based routing is higher priority than static routing

(5) – Forwarding the packet to the MAG via tunnel device◦ IPv6-in-IPv6 Encapsulation performed

37/51

(6) – Sending encapsulated packet (7)~(9) – IPv6 packet transmission among

nodes (10)~(11) – Incoming packet process in IPv6

◦ Query to routing module (12) – Received by IPv6-in-IPv6 packet

handler◦ Decapsulation performed

(13) – Sending decapsulated packet (14) – Sending Data Packet to the

destination node, either CN or MN

38/51

MagHelper◦ Function

Install(node) Create PMIPv6 related objects and aggregate into Node Register callback for MN attachment trigger to WifiMac

in node Install(node, addr, Ptr<Node> ap_node)

Create PMIPv6 related objects and aggregate into Node Register callback for MN attachment trigger to WifiMac

in ap_node SetProfileHelper(Pmip6ProfileHelper)

Set profile helper

39/51

LmaHelper◦ Function

Install(node) Create PMIPv6 related objects and aggregate into Node

SetProfileHelper(Pmip6ProfileHelper) Set profile helper

SetPrefixPoolBase(prefix, prefix_len) Set Prefix Pool information

Pmip6ProfileHelper◦ Manage each MN’s profile information◦ Function

AddProfile(MN_ID, LL_ID, LMAA, Prefixes) Add profile for an MN

40/51

41/51

Setup mobility MobilityHelper mobility; Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();

positionAlloc->Add (Vector (-100.0, 0.0, 0.0)); //MAG1AP positionAlloc->Add (Vector (100.0, 0.0, 0.0)); //MAG2AP

mobility.SetPositionAllocator (positionAlloc); mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");

mobility.Install (aps);

Ptr<ListPositionAllocator> staPositionAlloc = CreateObject<ListPositionAllocator> ();

staPositionAlloc->Add (Vector (-100.0, 100.0, 0.0)); //STA

mobility.SetPositionAllocator (staPositionAlloc);

mobility.SetMobilityModel ("ns3::ConstantVelocityMobilityModel");

mobility.Install(sta);

Ptr<ConstantVelocityMobilityModel> cvm = sta.Get(0)-

>GetObject<ConstantVelocityMobilityModel>();

cvm->SetVelocity(Vector (20.0, 0, 0)); //move to left to right 20.0m/s

42/51

Setup Wifi Ssid ssid = Ssid("MAG");

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();

wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);

WifiHelper wifi = WifiHelper::Default ();

NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();

YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();

wifiPhy.SetChannel (wifiChannel.Create ());

wifiMac.SetType ("ns3::NqapWifiMac",

"Ssid", SsidValue (ssid),

"BeaconGeneration", BooleanValue (true),

"BeaconInterval", TimeValue (MilliSeconds(100)));

mag1ApDev = wifi.Install (wifiPhy, wifiMac, mag1Net.Get(1));

//WLAN interface

wifiMac.SetType ("ns3::NqstaWifiMac",

"Ssid", SsidValue (ssid),

"ActiveProbing", BooleanValue (false));

staDevs.Add( wifi.Install (wifiPhy, wifiMac, sta));43/51

Setup PMIPv6//attach PMIPv6 agents

Pmip6ProfileHelper *profile = new Pmip6ProfileHelper();

//adding profile for each station

profile->AddProfile(Identifier("pmip1@example.com"),

Identifier(Mac48Address::ConvertFrom(staDevs.Get(0)->GetAddress())),

backboneIfs.GetAddress(0, 1),

std::list<Ipv6Address>());

Pmip6LmaHelper lmahelper;

lmahelper.SetPrefixPoolBase(Ipv6Address("3ffe:1:4::"), 48);

lmahelper.SetProfileHelper(profile);

lmahelper.Install(lma.Get(0));

Pmip6MagHelper maghelper;

maghelper.SetProfileHelper(profile);

maghelper.Install (mags.Get(0), mag1Ifs.GetAddress(0, 0), aps.Get(0));

maghelper.Install (mags.Get(1), mag2Ifs.GetAddress(0, 0), aps.Get(1));

44/51

Setup traffic Udp6ServerHelper udpServer(6000);

ApplicationContainer apps = udpServer.Install (sta.Get (0));

apps.Start (Seconds (1.0));

apps.Stop (Seconds (10.0));

uint32_t packetSize = 1024;

uint32_t maxPacketCount = 0xffffffff;

Time interPacketInterval = MilliSeconds(10);

Udp6ClientHelper udpClient(Ipv6Address("3ffe:1:4:1:200:ff:fe00:c"), 6000);

udpClient.SetAttribute ("Interval", TimeValue (interPacketInterval));

udpClient.SetAttribute ("PacketSize", UintegerValue (packetSize));

udpClient.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));

apps = udpClient.Install (cn.Get (0));

apps.Start (Seconds (1.5));

apps.Stop (Seconds (10.0));

45/51

PBU Trace in the LMA

46/51

Trace for Handover in the MN

47/51

Tunneling Trace in the LMA

48/51

Tunneling Trace in the LMA

49/51

350

360

370

380

390

5.2 5.25 5.3 5.35 5.4 5.45 5.5 5.55 5.6

Seq

uenc

e

Time(s)

5.3849s 5.42389s

50/51

Thank you- Q&A -

51/51

top related