📄 node156.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.6.1 LL Class in C++</TITLE><META NAME="description" CONTENT="14.6.1 LL 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="node157.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node157.html"><LINK REL="previous" HREF="node155.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node155.html"><LINK REL="up" HREF="node155.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node155.html"><LINK REL="next" HREF="node157.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node157.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html3678" HREF="node157.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node157.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html3672" HREF="node155.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node155.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html3666" HREF="node155.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node155.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html3674" 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="tex2html3676" 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="tex2html3679" HREF="node157.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node157.html">14.6.2 Example: Link Layer</A><B> Up:</B> <A NAME="tex2html3673" HREF="node155.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node155.html">14.6 LL (link-layer) Class</A><B> Previous:</B> <A NAME="tex2html3667" HREF="node155.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node155.html">14.6 LL (link-layer) Class</A>   <B> <A NAME="tex2html3675" HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>   <B> <A NAME="tex2html3677" 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="SECTION031161000000000000000"></A><A NAME="sec:llcplus"></A><BR>14.6.1 LL Class in C++</H2><P>The C++ class <TT>LL</TT> derives from the <TT>LinkDelay</TT> class. Sinceit is a duplex object, it keeps a separate pointer for the send target,<TT>sendtarget</TT>, and the receive target, <TT>recvtarget</TT>. It alsodefines the methods <TT>recvfrom()</TT> and <TT>sendto()</TT> to handle theincoming and outgoing packets respectively.<P><PRE> class LL : public LinkDelay { public: LL(); virtual void recv(Packet* p, Handler* h); virtual Packet* sendto(Packet* p, Handler* h = 0); virtual Packet* recvfrom(Packet* p); inline int seqno() { return seqno_; } inline int ackno() { return ackno_; } inline int macDA() { return macDA_; } inline Queue *ifq() { return ifq_; } inline NsObject* sendtarget() { return sendtarget_; } inline NsObject* recvtarget() { return recvtarget_; } protected: int command(int argc, const char*const* argv); void handle(Event* e) { recv((Packet*)e, 0); } inline virtual int arp (int ip_addr) { return ip_addr; } int seqno_; // link-layer sequence number int ackno_; // ACK received so far int macDA_; // destination MAC address Queue* ifq_; // interface queue NsObject* sendtarget_; // for outgoing packet NsObject* recvtarget_; // for incoming packet LanRouter* lanrouter_; // for lookups of the next hop };</PRE><P><BR><HR><ADDRESS>2003-09-23</ADDRESS></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -