12.07.2015 Views

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

$a0 network $netobj$a0 set fid_ 26$a0 set prio_ 2$<strong>ns</strong> connect $a0 $a1Note th<strong>at</strong> the configur<strong>at</strong>ion of the flow ID <strong>and</strong> priority are h<strong>and</strong>led through the Agent base class. <strong>The</strong> purpose of settingthe flow id field in the common header is to label packets belonging to particular flows of live d<strong>at</strong>a. Such packets can bedifferentially tre<strong>at</strong>ed with respect to drops, reorderings, etc. <strong>The</strong> connect method i<strong>ns</strong>tructs agent $a0 to send its live trafficto the $a1 agent via the current route through the simul<strong>at</strong>ed topology.44.4 Network ObjectsNetwork objects provide access to a live network. <strong>The</strong>re are several forms of network objects, depending on the protocollayer specified for access to the underlying network, in addition to the facilities provided by the host oper<strong>at</strong>ing system. Useof some network objects requires special access privileges where noted. Generally, network objects provide an entrypointinto the live network <strong>at</strong> a particular protocol layer (e.g. link, raw IP, UDP, etc) <strong>and</strong> with a particular access mode (read-only,write-only, or read-write). Some network objects provide specialized facilities such as filtering or promiscuous access (i.e.the pcap/bpf network object) or group membership (i.e. UDP/IP multicast). <strong>The</strong> C++ class Network is provided as a baseclass from which specific network objects are derived. Three network objects are currently supported: pcap/bpf, raw IP, <strong>and</strong>UDP/IP. Each are described below.44.4.1 Pcap/BPF Network Objects<strong>The</strong>se objects provide an extended interface to the LBNL packet capture library (libpcap). (See ftp://ftp.ee.lbl.gov/libpcap.tafor more info). This library provides the ability to capture link-layer frames in a promiscuous fashion from network interfacedrivers (i.e. a copy is made for those programs making use of libpcap). It also provides the ability to read <strong>and</strong> write packettrace files in the “tcpdump” form<strong>at</strong>. <strong>The</strong> extended interface provided by <strong>ns</strong> also allows for writing frames out to the networkinterface driver, provided the driver itself allows this action. Use of the library to capture or cre<strong>at</strong>e live traffic may be protected;one generally requires <strong>at</strong> least read access to the system’s packet filter facility which may need to be arranged througha system administr<strong>at</strong>or.<strong>The</strong> packet capture library works on several UNIX-based pl<strong>at</strong>forms. It is optimized for use with the Berkeley Packet Filter(BPF) [25], <strong>and</strong> provides a filter compiler for the BPF pseudomachine machine code. On most systems supporting it, a kernelresidentBPF implement<strong>at</strong>ion processes the filter code, <strong>and</strong> applies the resulting p<strong>at</strong>tern m<strong>at</strong>ching i<strong>ns</strong>tructio<strong>ns</strong> to receivedframes. Those frames m<strong>at</strong>ching the p<strong>at</strong>ter<strong>ns</strong> are received through the BPF machinery; those not m<strong>at</strong>ching the p<strong>at</strong>tern areotherwise unaffected. BPF also supports sending link-layer frames. This is generally not suggested, as an entire properlyform<strong>at</strong>tedframe must be cre<strong>at</strong>ed prior to h<strong>and</strong>ing it off to BPF. This may be problem<strong>at</strong>ic with respect to assigning properlink-layer headers for next-hop destin<strong>at</strong>io<strong>ns</strong>. It is generally preferable to use the raw IP network object for sending IP packets,as the system’s routing function will be used to determine proper link-layer encapsul<strong>at</strong>ing headers.Configur<strong>at</strong>ion Pcap network objects may be configured as either associ<strong>at</strong>ed with a live network or with a trace file. Ifassoci<strong>at</strong>ed with a live network, the particular network interface to be used may be specified, as well as an optional promiscuousflag. As with all network objects, they may be opened for reading or writing. Here is an example:set me [exec hostname]set pf1 [new Network/Pcap/Live]$pf1 set promisc_ true385

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!