⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lan.tex

📁 柯老师网站上找到的
💻 TEX
📖 第 1 页 / 共 2 页
字号:
%\documentstyle[11pt,fullpage]{article}%\setlength{\parindent}{0 in}%\setlength{\parskip}{.1in}%\setlength{\topmargin}{-0.5in}%\setlength{\textheight}{8.5in}%\begin{document}%% personal commentary:%        DRAFT DRAFT DRAFT%        - GNGUYEN%\chapter{Local Area Networks}\label{chap:lan}The characteristics of the wireless and local area networks (LAN) areinherently different from those of point-to-point links.  A networkconsisting of multiple point-to-point links cannot capture the sharingand contention properties of a LAN.  To simulate these properties, wecreated a new type of a Node, called \code{LanNode}.  The OTclconfigurations and interfaces for \code{LanNode} reside in the followingtwo files in the main \ns\ directory:\begin{verbatim}        tcl/lan/vlan.tcl        tcl/lan/ns-ll.tcl        tcl/lan/ns-mac.tcl\end{verbatim}\section{Tcl configuration}\label{sec:lan_tcl}The interface for creating and configuring a LAN slightly differs fromthose of point-to-point link.  At the top level, the OTcl class\code{Simulator} exports a new method called \code{make-lan}.  Theparameters to this method are similar to the method \code{duplex-link},except that \code{make-lan} only accepts a list of nodes as a singleparameter instead of 2 parameters as in \code{duplex-link}:\begin{verbatim}Simulator instproc make-lan {nodes bw delay lltype ifqtype mactype chantype}\end{verbatim}The optional parameters to \code{make-lan} specify the type of objectsto be created for the link layer (\code{LL}), the interface queue, theMAC layer (\code{Mac}), and the physical layer (\code{Channel}).  Belowis an example of how a new CSMA/CD (Ethernet) LAN is created.Example:\begin{program}        $ns make-lan "$n1 $n2" $bw $delay LL Queue/DropTail Mac/Csma/Cd\end{program}creates a LAN with basic link-layer, drop-tail queue, and CSMA/CD MAC.\section{Components of a LAN}\label{sec:lan_components}LanLink captures the functionality of the three lowest layers in thenetwork stack:\begin{enumerate}\item	Link Layer (LL)\item	Medium Access Control (MAC) Layer\item	Physical (PHY) Layer\end{enumerate}\begin{figure}[tb]  \centerline{\includegraphics{lan1}}  \caption{Connectivity within a LAN}  \label{fig:lan-connectivity}\end{figure}Figure~\ref{fig:lan-connectivity} illustrates the extended networkstack that makes simulations of local area network possible in \ns.  Apacket sent down the stack flowsthrough the link layer (\code{Queue} and \code{LL}), the MAC layer(\code{Mac}), and the physical layer (\code{Channel} to\code{Classifier/Mac}).  The packet then makes its way up the stack throughthe \code{Mac}, and the \code{LL}.At the bottom of the stack, the physical layer is composed of twosimulation objects: the \code{Channel} and \code{Classifier/Mac}.  The\code{Channel} object simulates the shared medium and supports the mediumaccess mechanisms of the MAC objects on the sending side of thetransmission.  On the receiving side, the \code{Classifier/Mac} isresponsible for delivering and optionally replicating packets to thereceiving MAC objects.Depending on the type of physical layer, the MAC layer must contain acertain set of functionalities such as: carrier sense, collisiondetection, collision avoidance, etc.  Since these functionalities affectboth the sending and receiving sides, they are implemented in a single\code{Mac} object.  For sending, the \code{Mac} object must follow a certainmedium access protocol before transmitting the packet on the channel.For receiving, the MAC layer is responsible for delivering the packet tothe link layer.Above the MAC layer, the link layer can potentially have manyfunctionalities such as queuing and link-level retransmission.  Theneed of having a wide variety of link-level schemes leads to thedivision of functionality into two components: \code{Queue} and\code{LL} (link-layer).  The \code{Queue} object, simulating theinterface queue, belongs to the same \code{Queue} class that isdescribed in Chapter~\ref{chap:qmgmt}.  The \code{LL} object implementsa particular data link protocol, such as ARQ.  By combining both thesending and receiving functionalities into one module, the \code{LL}object can also support other mechanisms such as piggybacking.\section{Channel Class}\label{sec:channel}The \code{Channel} class simulates the actual transmission of the packetat the physical layer.  The basic \code{Channel} implements a sharedmedium with support for contention mechanisms.  It allows the MAC tocarry out carrier sense, contention, and collision detection.  If morethan one transmissions overlaps in time, a channel raises the collisionflag.  By checking this flag, the MAC object can implement collision detectionand handling.Since the transmission time is a function of the number of bits in thepacket and the modulation speed of each individual interface (MAC), the\code{Channel} object only sets its busy signal for the durationrequested by the MAC object.  It also schedules the packets to bedelivered to the destination MAC objects after the transmission timeplus the propagation delay.\subsection{Channel State}\label{sec:channelstate}The C++ \clsref{Channel}{../ns-2/channel.h} includes enough internalstate to schedule packet delivery and detect collisions.  It exports thefollowing OTcl configuration parameter:\begin{tabularx}{\linewidth}{rX}\code{delay\_} & propagation delay on the channel \\\end{tabularx}\subsection{Example: Channel and classifier of the physical layer}\label{ex:channel}\begin{verbatim}        set channel_ [new Channel]        $channel_ set delay_ 4us        # propagation delay        set mcl_ [new Classifier/Mac]        $channel_ target $mcl_        $mcl_ install $mac_DA $recv_iface                . . .\end{verbatim}\subsection{Channel Class in C++}\label{sec:channelcplus}In C++, the class Channel extends the Connector objectwith several new methods tosupport a variety of MAC protocols.  The class is defined as follow in\nsf{channel.h}:\begin{program}   class Channel : public Connector \{   public:        Channel();        void recv(Packet* p, Handler*);        virtual int send(Packet* p, double txtime);        virtual void contention(Packet*, Handler*);        int hold(double txtime);        virtual int collision() \{ return numtx_ > 1; \}        virtual double txstop() \{ return txstop_; \}                . . .   \};\end{program}The important methods of the class \code{Channel} are:\begin{itemize}\item  \code{txstop()} method returns the time when the channel will becomeidle, which can be used by the MAC to implement carrier sense.\item  \code{contention()} method allows the MAC to contend for the channelbefore sending a packet.  The channel then use this packet to signal thecorresponding \code{Mac} object at the end of each contention period.\item  \code{collision()} method indicates whether a collision occursduring the contention period.  When the \code{Channel} signal the end ofthe contention period, the MAC can use the \code{collision()} method todetect collision.\item  \code{send()} method allows the MAC object to transmit a packet on thechannel for a specified duration of time.\item  \code{hold()} method allows the MAC object to hold the channel for aspecified duration of time without actually transmitting any packets.This is useful in simulating the jamming mechanism of some MACprotocols.\end{itemize}\section{MacClassifier Class}\label{sec:mac_classifier}The \code{MacClassifier} class extends the \code{Classifier} class toimplement a simple broadcasting mechanism.  It modifies the\code{recv()} method in the following way: since the replication of apacket is expensive, normally a unicast packet will be classified bythe MAC destination address \code{macDA_} and delivered directly tothe MAC object with such an address.  However, if the destinationobject cannot be found or if the MAC destination address is explicitlyset to the broadcast address \code{BCAST_ADDR}, the packet will bereplicated and sent to all MACs on the lan excluding the one that isthe source of the packet.  Finally, by setting the bound variable\code{MacClassifier::bcast_} to a non--zero value, will cause\code{MacClassifier} always to replicate packets.\begin{program}    class MacClassifier : public Classifier \{    public:        void recv(Packet*, Handler*);    \};    void MacClassifier::recv(Packet* p, Handler*)    \{        Mac* mac;        hdr_mac* mh = hdr_mac::access(p);        if (bcast_ || mh->macDA() == BCAST_ADDR || (mac = (Mac *)find(p)) == 0) \{                // Replicate packets to all slots (broadcast)                . . .                return;        \}        mac->recv(p);    \}\end{program}\section{MAC Class}\label{sec:mac}The \code{Mac} object simulates the medium access protocols that arenecessary in the shared medium environment such as the wireless andlocal area networks.  Since the sending and receiving mechanisms aretightly coupled in most types of MAC layers,it is essential for the \code{Mac} object to be duplex.On the sending side, the \code{Mac} object is responsible for adding theMAC header and transmitting the packet onto the channel.  On thereceiving side, the \code{Mac} object asynchronously receives packetsfrom the classifier of the physical layer.  After MAC protocolprocessing, it passes the data packet to the link layer.\subsection{Mac State}\label{sec:macstate}The C++ \clsref{Mac}{../ns-2/mac.h} class contains enough internal stateto simulate the particular MAC protocol.  It also exports the followingOTcl configuration parameter:\begin{tabularx}{\linewidth}{rX}\code{bandwidth\_} & modulation rate of the MAC \\\code{hlen\_} & additional bytes added to packet for MAC header \\\code{label\_} & MAC address \\\end{tabularx}\subsection{Mac Methods}\label{sec:macmethods}The \clsref{Mac}{../ns-2/mac.cc} class added several Tcl methods forconfiguration, in particular, linking with other simulation objects:\begin{tabularx}{\linewidth}{rX}\code{channel} & specify the channel for transmission \\\code{classifier} & the classifier that deliver packets to receiving MAC \\\code{maclist} & a link list of MAC interfaces on the same node \\\end{tabularx}\subsection{Mac Class in C++}\label{sec:maccplus}In C++, the \code{Mac} class derives from \code{Connector}.  When the\code{recv()} method gets a packet, it identifies the direction of thepacket based on the presence of a callback handler.  If there is acallback handler, the packet is outgoing, otherwise, it is incoming.\begin{program}   class Mac : public Connector \{   public:        Mac();        virtual void recv(Packet* p, Handler* h);        virtual void send(Packet* p);        virtual void resume(Packet* p = 0);                . . .    \};\end{program}When a \code{Mac} object receives a packet via its \code{recv()} method,it checks whether the packet is outgoing or incoming.  For an outgoingpacket, it assumes that the link-layer of the sender has obtained thedestination MAC address and filled in the \code{macDA\_} field of theMAC header, \code{hdr_mac}.  The \code{Mac} object fills in the rest ofthe MAC header with the source MAC address and the frame type.  It thenpasses the packet to its \code{send()} method, which carries out themedium access protocol.  For the basic \code{Mac} object, the\code{send} method calls \code{txtime()} to compute the transmissiontime, then invokes \code{Channel::send} to transmit the packet.  Finally, it 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -