?? agents-3.html.svn-base
字號:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.6">
<TITLE>Agent interaction in JNS: Setting up agents</TITLE>
<LINK HREF="Agents-4.html" REL=next>
<LINK HREF="Agents-2.html" REL=previous>
<LINK HREF="Agents.html#toc3" REL=contents>
</HEAD>
<BODY>
<A HREF="Agents-4.html">Next</A>
<A HREF="Agents-2.html">Previous</A>
<A HREF="Agents.html#toc3">Contents</A>
<HR>
<H2><A NAME="s3">3. Setting up agents</A></H2>
<P>Obviously, agents are not naturally inclined to run on top of each other. They
somehow have to be attached to each other, for example TCP has to be attached
to IP.
<P>In JNS, the order is that <I>higher-level agents attach to lower-level agents</I>. For example, in order to attach TCP to IP you would use the following
code:
<HR>
<PRE>
ip_instance.attach(tcp_instance,Protocols.TCP);
</PRE>
<HR>
The Protocols.TCP parameter is an identifier by which the lower-level protocol
can identify packets and what higher-level agents they should be given to. In
the case of IP, all IP packets that have the protocol field set to 'TCP' will
be given to 'tcp_instance' now.
<P>
<P>When the 'attach' function is called, the lower-level protocol will subsequently reverse-attach itself to the higher-level protocol. This is in order to give
the higher level protocol a chance to obtain a reference to the lower level. In the previous example 'tcp_instance' had no way to get a reference to
'ip_instance'. So <I>ip_instance.attach(...)</I> will call back the following
function:
<HR>
<PRE>
Tcp.attach(Agent lower_level)
</PRE>
<HR>
to do the reverse attachment.
<P>
<P>For some detail on how all of this actually work, I'd recommend you look at
the jns/trace/SimpleGoBackN.java source file and Test_GoBackN.java. The former
is a protocol that attaches to IP.
<P>
<P>
<HR>
<A HREF="Agents-4.html">Next</A>
<A HREF="Agents-2.html">Previous</A>
<A HREF="Agents.html#toc3">Contents</A>
</BODY>
</HTML>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -