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

📄 node494.html

📁 相关搜索: ns2仿真结果分析 all-awk ns2 ns2 无限网络中awk文件 ... [2.tcl.rar] - 在ns2平台上实现对AODV协议的模拟
💻 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>36.1.3 Transmitting user data over UDP</TITLE><META NAME="description" CONTENT="36.1.3 Transmitting user data over UDP"><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="node495.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node495.html"><LINK REL="previous" HREF="node493.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node493.html"><LINK REL="up" HREF="node491.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node491.html"><LINK REL="next" HREF="node495.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node495.html"></HEAD><BODY ><!--Navigation Panel--><A NAME="tex2html9020"  HREF="node495.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node495.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html9014"  HREF="node491.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node491.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html9008"  HREF="node493.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node493.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html9016"  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="tex2html9018"  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="tex2html9021"  HREF="node495.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node495.html">36.1.4 Transmitting user data</A><B> Up:</B> <A NAME="tex2html9015"  HREF="node491.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node491.html">36.1 Using application-level data</A><B> Previous:</B> <A NAME="tex2html9009"  HREF="node493.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node493.html">36.1.2 Passing data between</A> &nbsp <B>  <A NAME="tex2html9017"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html9019"  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="SECTION07213000000000000000">36.1.3 Transmitting user data over UDP</A></H2><P>Currently there is no support in class Agent to transmit userdata. There are two ways to transmit a serialized ADU through transportagents. First, for UDP agent (and all agents derived from there), wecan derive from class UDP and add a new method<TT>send(int nbytes, char *userdata)</TT> to pass user data fromApplication to Agent. To pass data from an Agent to an Application issomewhat trickier: each agent has a pointer to its attachedapplication, we dynamically cast this pointer to an AppConnector andthen call <TT>AppConnector::process_data()</TT>.<P>As an example, we illustrate how class HttpInvalAgent isimplemented. It is based on UDP, and is intended to deliver web cacheinvalidation messages (/webcache/inval-agent.h). It is defined as:<P><PRE>        class HttpInvalAgent : public Agent {        public:                 HttpInvalAgent();                virtual void recv(Packet *, Handler *);                virtual void send(int realsize, AppData* data);        protected:                int off_inv_;        };</PRE><P>Here <TT>recv(Packet*, Handler*)</TT> overridden to extract user data,and a new <TT>send(int, AppData*)</TT> is provided to include user datain packetes. An application (HttpApp) is attached to an HttpInvalAgentusing <TT>Agent::attachApp()</TT> (a dynamic cast is needed). In<TT>send()</TT>, the following code is used to write user data fromAppData to the user data area in a packet:<P><PRE>        Packet *pkt = allocpkt(data-\&gt;size());        hdr_inval *ih = (hdr_inval *)pkt-\&gt;access(off_inv_);        ih-\&gt;size() = data-\&gt;size();        char *p = (char *)pkt-\&gt;accessdata();        data-\&gt;pack(p);</PRE><P>In <TT>recv()</TT>, the following code is used to read user data frompacket and to deliver to the attached application:<P><PRE>        hdr_inval *ih = (hdr_inval *)pkt-\&gt;access(off_inv_);        ((HttpApp*)app_)-\&gt;process_data(ih-\&gt;size(), (char *)pkt-\&gt;accessdata());        Packet::free(pkt);</PRE><P><HR><!--Navigation Panel--><A NAME="tex2html9020"  HREF="node495.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node495.html"><IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="file:/usr/share/latex2html/icons/next.png"></A> <A NAME="tex2html9014"  HREF="node491.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node491.html"><IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="file:/usr/share/latex2html/icons/up.png"></A> <A NAME="tex2html9008"  HREF="node493.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node493.html"><IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="file:/usr/share/latex2html/icons/prev.png"></A> <A NAME="tex2html9016"  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="tex2html9018"  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="tex2html9021"  HREF="node495.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node495.html">36.1.4 Transmitting user data</A><B> Up:</B> <A NAME="tex2html9015"  HREF="node491.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node491.html">36.1 Using application-level data</A><B> Previous:</B> <A NAME="tex2html9009"  HREF="node493.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node493.html">36.1.2 Passing data between</A> &nbsp <B>  <A NAME="tex2html9017"  HREF="node1.html" tppabs="http://www.isi.edu/nsnam/ns/doc/node1.html">Contents</A></B>  &nbsp <B>  <A NAME="tex2html9019"  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 + -