📄 node153.html
字号:
<html><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><!--Converted with jLaTeX2HTML 2002 (1.62) JA patch-1.4patched version by: Kenshi Muto, Debian Project.LaTeX2HTML 2002 (1.62),original version by: Nikos Drakos, CBLU, University of Leeds* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan* with significant contributions from: Jens Lippmann, Marek Rouchal, Martin Wilck and others --><HTML><HEAD><TITLE>14.5.3 Mac Class in C++</TITLE><META NAME="description" CONTENT="14.5.3 Mac Class in C++"><META NAME="keywords" CONTENT="everything"><META NAME="resource-type" CONTENT="document"><META NAME="distribution" CONTENT="global"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"><META NAME="Generator" CONTENT="jLaTeX2HTML v2002 JA patch-1.4"><META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"><LINK REL="STYLESHEET" HREF="everything.css" tppabs="http://www.isi.edu/nsnam/ns/doc/everything.css"><LINK REL="next" HREF="node154.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node154.html"><LINK REL="previous" HREF="node152.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node152.html"><LINK REL="up" HREF="node150.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node150.html"><LINK REL="next" HREF="node154.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node154.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html3636" HREF="node154.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node154.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html3630" HREF="node150.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node150.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html3624" HREF="node152.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node152.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html3632" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="file:/usr/share/latex2html/icons/contents.png"></A> <A NAME="tex2html3634" HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html"><IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="file:/usr/share/latex2html/icons/index.png"></A> <BR><B> Next:</B> <A NAME="tex2html3637" HREF="node154.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node154.html">14.5.4 CSMA-based MAC</A><B> Up:</B> <A NAME="tex2html3631" HREF="node150.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node150.html">14.5 MAC Class</A><B> Previous:</B> <A NAME="tex2html3625" HREF="node152.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node152.html">14.5.2 Mac Methods</A>   <B> <A NAME="tex2html3633" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html3635" HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html">Index</A></B> <BR><BR><!--End of Navigation Panel--><H2><A NAME="SECTION031153000000000000000"></A><A NAME="sec:maccplus"></A><BR>14.5.3 Mac Class in C++</H2><P>In C++, the <TT>Mac</TT> class derives from <TT>Connector</TT>. When the<TT>recv()</TT> 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.<P><PRE> class Mac : public Connector { public: Mac(); virtual void recv(Packet* p, Handler* h); virtual void send(Packet* p); virtual void resume(Packet* p = 0); . . . };</PRE><P>When a <TT>Mac</TT> object receives a packet via its <TT>recv()</TT> 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 <TT>macDA<BR>_</TT> field of theMAC header, <TT>hdr_mac</TT>. The <TT>Mac</TT> object fills in the rest ofthe MAC header with the source MAC address and the frame type. It thenpasses the packet to its <TT>send()</TT> method, which carries out themedium access protocol. For the basic <TT>Mac</TT> object, the<TT>send</TT> method calls <TT>txtime()</TT> to compute the transmissiontime, then invokes <TT>Channel::send</TT> to transmit the packet. Finally, it schedules itself to resume after the transmission time has elapsed.<P>For an incoming packet, the MAC object does its protocol processing andpasses the packet to the link-layer.<P><HR><!--Navigation Panel--><A NAME="tex2html3636" HREF="node154.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node154.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html3630" HREF="node150.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node150.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html3624" HREF="node152.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node152.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html3632" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html"><IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="file:/usr/share/latex2html/icons/contents.png"></A> <A NAME="tex2html3634" HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html"><IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="file:/usr/share/latex2html/icons/index.png"></A> <BR><B> Next:</B> <A NAME="tex2html3637" HREF="node154.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node154.html">14.5.4 CSMA-based MAC</A><B> Up:</B> <A NAME="tex2html3631" HREF="node150.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node150.html">14.5 MAC Class</A><B> Previous:</B> <A NAME="tex2html3625" HREF="node152.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node152.html">14.5.2 Mac Methods</A>   <B> <A NAME="tex2html3633" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html3635" HREF="node590.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node590.html">Index</A></B> <!--End of Navigation Panel--><ADDRESS>2003-09-23</ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -