Emulation

Embed Size (px)

DESCRIPTION

^^ tài liệu hay

Citation preview

  • Emulation in nsAlefiya Hussain

  • What is Emulation ?Ability to introduce the simulator into a live networkApplication:Allows testing real-world implementationsAllows testing simulated protocols Requirements: Scheduler support Packet capture and generation capabilities

  • Schedulerns operates in virtual time using event- driven simulation Real-time scheduler Does not advance the virtual clock to next eventDispatches event at real-time

  • Emulation Objects Interface between ns and network trafficNetwork Objects Access to live network viaBPF and raw sockets Tap Objects Conversion between ns andnetwork packet formats

    Capture: BPFns Inject: Raw socketnetwork to nsns to network

  • Modes of OperationPacket conversion leads to two modes of operation

    Opaque ModeNetwork packet fields are not interpreted

    Protocol ModeNetwork packet is interpretedTTL values reflect hop count in simulatorNetwork packet fields are generated Ping responder, TCP application

  • Opaque ModeNetwork packet is passed unmodified through simulator Network PacketSourceDestinationSizeDataNs packet contains a pointer to the network packet Read packetsWrite packetsnsNetwork

  • Protocol ModeNetwork packet fields are generated by the simulator

    DataThe ns packet header is mapped onto the network packet header and visa versa . Send/receive packets from applicationnsTCP AgentNetworkHost ATCPApplicationHost BSend/receive packets from nsNetwork Packet

  • ApplicationsOpaque ModeCross-traffic interaction leading to drop, delay and re-ordering of packets End to End application testingProtocol ModeProtocol and conformance testingEvaluate effect of DDoS attacks Wireless networks

  • Example: SetupGoal: Make a ns TCP agent interact with a TCP servernseTCP serverDisable IP forwardingsysctl w net.inet.ip.forwarding=0Assign 10.0.0.1 and 6000 to TCP agent

    Add route to dummy IP address route add 10.0.0.1 192.168.1.1Disable IP redirects sysctl w net.inet.ip.redirect=0A 192.168.1.1B 192.168.1.2 port 8000Switch

  • Example Scriptset ns [new Simulator]$ns use-scheduler RealTime set entry_node [$ns node]set tcp_node [$ns node] $ns duplex-link $entry_node \$tcp_node 10Mb 1ms DropTail

    set tcp [new Agent/TCP/FullTcp]$ns attach-agent $tcp_node $tcp Activate ns and Change to real-time schedulerCreate topologyCreate TCP AgentTCP Agenttcp_nodeentry_node

  • Example Script set bpf [new Network/Pcap/Live] set dev [$bpf open readonly eth0]$bpf filter "src 192.168.1.2 and src port 8000 \ and dst 10.0.0.1 and dst port 6000set capture_tap [new Agent/TCPTap] $capture_tap network $bpf $ns attach-agent $entry_node $capture_tap$ns simplex-connect $capture_tap $tcp

    set rawsocket [new Network/IP] $rawsocket open writeonly set inject_tap [new Agent/TCPTap] $inject_tap advertised-window 512$inject_tap extipaddr 192.168.1.2" $inject_tap extport 8000$inject_tap network $rawsocket$ns attach-agent $entry_node $inject_tap $ns simplex-connect $tcp $inject_tap TCP Agenttcp_nodeentry_nodeRawSocketCaptureTapBPFInjectTap

  • Example Script$ns at 0.01 "$tcp advance 1"$ns at 20.0 exit 0"$ns runstart nseTCP Server (8000)SwitchTCP AgentBPFRaw SocketB 192.168.1.2A 192.168.1.1

  • Further Information http://www.isi.edu/nsnam/ns/ns-emulation.htmlScripts ~ns/emulate Opaque Mode:em.tcl Protocol Modethrutcp.tclpingdemo.tcltcpemu.tclKevin Fall, Network Emulation in the Vint/NS Simulator, ISCC July 1999