On Tuesday 03 June 2003 08:44 pm, Greg Wooledge wrote:
> malcolm handley ([EMAIL PROTECTED]) wrote:
> > Where is the FCP documentation these days?
>
> The last time I asked this (a couple weeks ago), the answer was that
> it had vanished in the last round of web site problems, so the only
> definitive resource was the source code.
>
> I found what I needed in scripts/fcptest.pl -- but I hope one of
> the web site administrators can restore the official online
> documentation.

For the moment, how about these?
And anyone with CVS access, might want to clean these up and throw 'em up.

--hobbs
Title: The Free Network Project
This is G o o g l e's cache of http://freenetproject.org/tiki-index.php?page=ClientProto.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
To link to or bookmark this page, use the following url: http://www.google.com/search?q=cache:JiIg8I2Q6dkJ:freenetproject.org/tiki-index.php%3Fpage%3DClientProto+freenet+clientproto&hl=en&ie=UTF-8


Google is not affiliated with the authors of this page nor responsible for its content.
These search terms have been highlighted: freenet 
These terms only appear in links pointing to this page: clientproto

Login
user:
pass:
[register|I forgot my pass]
Hosted by

Abstract



The FreenetClientProtocol?
(FCP) is designed to abstract the basics of Freenet so that client developers
do not have to track the main Freenet protocol. FCP should be the bare bones of
Freenet - metadata handling is not included in FCP though an extension to FCP
may come about at a later date to avoid writing metadata handling libraries in
many languages.

Note



This protocol is never meant to go across a network - only via the loopback.
Nodes should not accept FCP connections from hosts other than localhost by
default.

Basics



By default FCP is port 8481, but any client that uses FCP should leave
this configurable, because this may be changed in the node's configuration file
or by some future FCP revision.

FCP follows the FNP setup for session and presentation.

In the following, numbers are always hex-encoded and fields in square-brackets
are optional.

FCP allows one transaction per connection, after which the connection is torn
down. At the beginning of each connection, the client must send these 4 bytes:

00 00 00 02

These are the 2-byte session identifier and the 2-byte presentation identifier.
In the future, different identifiers may be used to allow alternate syntaxes or
encrypted FCP connections from remote hosts, for example.

After sending the session and presentation identifiers, the client sends a
message to initiate the transaction, then waits for one or more messages from
the node until the transaction is complete. Messages are a series of lines
terminated by LF or CRLF, in this form:


Header
{Field1=Value1}
.
.
{FieldN=ValueN}
EndMessage?


Message summary



This is the complete set of client to node messages, with the possible node to
client responses (only the headers are listed).


  • ClientHello
    • NodeHello
  • ClientGet
    • URIError
    • Restarted
    • DataNotFound
    • RouteNotFound
    • DataFound
      • DataChunk
  • ClientPut
    • URIError
    • Restarted
    • RouteNotFound
    • KeyCollision
    • Pending
    • Success
  • GenerateCHK
    • Success
  • GenerateSVKPair
    • Success
  • ClientDelete
    • Success

Additionally, the node may respond to any client message with a
FormatError, meaning the command was not understood, and the node
may responsd at any time with a Failed, indicating a fault in the
node itself:


(Node -> Client)

FormatError?
{Reason=}
EndMessage?



(Node -> Client)

Failed
{Reason=}
EndMessage?


Failed and FormatError will not be discussed in the
remainder of this document. Clients should be prepared to handle a
Failed at any time, and a FormatError as teh response
to any client message. Either of these messages terminates the transaction and
the connection.

Handshaking



This is totally optional for the client. Note that this counts as a transation
and thus the connection is torn down afterwards.


(Client -> Node)

ClientHello?
EndMessage?


In response the node sends the following message:


(Node -> Client)

NodeHello?
Protocol=
Node=
{HighestSeenBuild=}
EndMessage?


The optional HighestSeenBuild? will only be present if a build higher than the
node's current build is seen in the datastore. Client implementors are
advised, in this circumstance, to notify the user that they should upgrade to
the latest build of Freenet. The user should have the ability to turn off this
warning.

Requesting




(Client -> Node)

ClientGet?
URI=
HopsToLive=
EndMessage?


The client is now in the waiting state. The node may return one of
the following messages:


  • URIError: Invalid Freenet URL. The transaction is
    terminated.

  • Restarted: The client should continue waiting.

  • DataNotFound: The transaction is terminated due to not being
    able to find data.

  • RouteNotFound: The transaction is terminated due to not being
    able to find a route.



Otherwise a DataFound message is returned:


(Node -> Client)

DataFound?
DataLength=
{MetadataLength=
EndMessage?


Note - If metadata is present in the data being delivered, then DataLength
will be the total length, including metadata. The length of the pure data is

DataLength - MetadataLength.

Also, the metadata is sent first, then the data.

After a DataFound message the data itself is sent in chunks:


(Node -> Client)

DataChunk?
Length=
Data
<@Length bytes of data>


At any time when the full payload of data has not been sent a Restarted message
may be sent. (Note by David McNab? - no need to check for 'Restarted'
messages within a data chunk - just check the first line each time you're
expecting a new DataChunk.)
. This means that the data failed to verify and
the transfer will be restarted. The client should return to the waiting
state, and if a DataFound is then received, the data transfer will
start over from
the beginning. Otherwise, when the final DataChunk is received,
the transaction is complete and the connection dies.


Note - you cannot assume that the transition from metadata to data will occur
cleanly on DataChunk boundaries. It is possible for the last bytes of metadata
and the first bytes of data to be received within a DataChunk.
In your client programs, you'll need to buffer these incoming datachunks in a separate layer of your key retrieval code.
.

Inserting




(Client->Node)

ClientPut?
HopsToLive=
URI=
DataLength=
{MetadataLength=}
Data
<@DataLength number of bytes>


If the client is inserting a CHK, the URI may be abbreviated as just
CHK@. In this case, the node will calculate the CHK. The node
must get all of the trailing field before it can start the insert into Freenet.
The node may reply with one of the following messages:


  • URIError: Invalid Freenet URL. The transaction is
    terminated.

  • Restarted: The client should continue waiting.

  • RouteNotFound: The transaction is terminated due to not being
    able to find a route.

  • KeyCollision: The transaction is terminated due to a document
    with the same key already existing in Freenet. This message contains a URI
    field with the Freenet URI of the document.

  • SizeError: The transaction is terminated due to the data
    being too large for the key type; all non-CHK keys have a limit of 32 kB of
    data.



During an insertion, multiple Pending messages may be returned.
These messages signal that the data is being successfully inserted, but
insertion is not complete, and the node has not received a
StoreData message yet:


(Node -> Client)

Pending
URI=
{PublicKey=}
{PrivateKey=}
EndMessage?


When the node receives a StoreData message (and thus insertion is
complete), a Success message is returned with the Freenet URI of
the new document and possibly a private/public keypair, if the inserted
document was an SVK. See the section on key generation about this.


(Node -> Client)

Success
URI=
{PublicKey=}
{PrivateKey=}
EndMessage?


Key generation



These messages allow a client to generate keys. This does not affect Freenet
at all - the calculations are carried out at the node.

Key generation requests are done via a GenerateKey message.
Either a CHK or an SVK keypair can be generated:


(Client -> Node)

GenerateCHK
DataLength=
{MetadataLength=}
Data
<@DataLength number of bytes>


The node calculates the CHK as it would do if inserting, but instead returns
it. This completes the transaction:


(Node -> Client)

Success
URI=
EndMessage?


The format for generating SVKs is very similar but generates a pair of keys
(public and private) which are independent of any data. This is generally used
for setting up SSKs:


(Client -> Node)

GenerateSVKPair
EndMessage?


The node generates a key pair and returns:


(Node -> Client)

Success
PublicKey=
PrivateKey=
EndMessage?


The PublicKey and PrivateKey are returned as
Freenet-base64 encoded strings. These can be used to construct URIs for
requesting or inserting SSKs:


(insert) freenet:SSK@/
(request) freenet:SSK@/









Appendix: Shell script


Unix shell script to send a command to FCP, for testing purposes (you must install netcat):


(echo -e -n '\0\0\0\2'; echo "ClientHello"; echo "EndMessage") | nc localhost 8481

Postscript



I (TravisBemann) originally
transcribed this document from a converted to HTML version of an SGML document
by Adam Langley which originally documented FCP, along with a few changes to
document the introduction of the Pending message, and changing
wording and formatting in some circumstances. Thus I will credit Adam Langley
with the majority of the content in this.

-- TravisBemann?

I removed a rather off-topic debate about authorship of this document.

-- IanClarke? - 07 Aug 2002

Last modification date: Monday 10 of March, 2003 [20:09:39] by toad



© Copyright 1999-2003 Freenet Project Inc, All Rights Preserved
Title: FreenetProject.org
This is G o o g l e's cache of http://freenetproject.org/cgi-bin/twiki/view/Pub/MetadataSpec.
G o o g l e's cache is the snapshot that we took of the page as we crawled the web.
The page may have changed since that time. Click here for the current page without highlighting.
To link to or bookmark this page, use the following url: http://www.google.com/search?q=cache:N0TJE_qpCToJ:freenetproject.org/cgi-bin/twiki/view/Pub/MetadataSpec+freenet+metadataspec&hl=en&ie=UTF-8


Google is not affiliated with the authors of this page nor responsible for its content.
These search terms have been highlighted: freenet 
These terms only appear in links pointing to this page: metadataspec

Front Page

Explorers
- What is Freenet
- Donate!
- People
- Publicity
- Philosophy
- Translations

Users
- Download
- ScreenShots
- Documentation
- FAQ
- Third Party Tools
- Report Bug
- Mailing Lists
- Freenet Nodes

Authors
- Publishing

Developers
- Papers
- Architecture
- Research
- Browse CVS
- Public Area
- About This Site

Login & Edit

Hosted by
SourceForge


Freenet Metadata Spec

Author: Adam Langley, Eric Norige


Table of Contents

Overview
Part Spec
Redirect [CDC]
DateRedirect [CDC]
SplitFile [CDC]
Info [MC]
ExtInfo [MC]
Examples
Handling Other Commands

Abstract

This spec is for client metadata. The purpose of this spec is to provide convenient functionality for building web sites inside freenet.

Overview

Metadata = Version command, followed by set of Parts
Part = name of Part, followed by a number of fields, followed by EndPart? (or End for the last Part)
Version command = A Part with the name "Version" and a field called "Revision" of type number. This is 1 for the current spec. Following that an optional "Encoding" field allows for all non-version parts to be gzipped.

More formally

<Metadata> = <Version command> <Parts>* <LastPart> <Arbitrary Metadata>
<Version command> = "Version\n" "Revision=1\n" <Optional: "Encoding=gzip\n"> "EndPart\n"
<Part> = "Document\n" <Field>* "EndPart\n"
<LastPart> = "Document\n" <Field>* "End\n"
<Field> = <Key> "=" <Value> "\n"

Example 1. Abstract Metadata Format

Version
Revision=1
EndPart?
Document
Key=value
EndPart?
Document
Key1=value1
Key2=value2
End
      

Note

"//" in a URI is reserved for metadata processing. This means that the [EMAIL PROTECTED]// format is gone. Document Names are the string which comes after the "//". Each Part should have a field with key "Name". The Part whose Name matches the Document Name should be acted upon.

Control documents are allowed to have a 'default' Part, serving the function of index.html on the web. This Part is distinguished by not having a Name field. This part must be matched with a URI having no text after the "//" seperator. The default Part should not be returned when an unknown name is asked for.

The order of keys in a Part is not important, and if the same Key appears twice in a part, only the last one's value is used.

Note

All numbers are base 16

Control Document Commands are denoted [CDC] and metadata commands as [MC]

There may only be one section with the same Name.

Part Spec

Redirect [CDC]

Redirect.Target=<URI:>

The Client should redirect to the given URI.

DateRedirect [CDC]

[DateRedirect.Increment=<number: time-grain size in seconds, default=15180 (one day)>]
[DateRedirect.Offset=<number
time-grain in seconds since unix epoch (January 1, 1970) to start increments, default = 0>] DateRedirect?.Target=<URI:>
  • The date format is in UNIX format - seconds from the epoch

  • Only applies to KSKs and SSKs

  • The date must be taken UTC (TZ offset = 0)

The client should take the current time (GMT) and work out the last member of the series of times (offset, offset + i, offset + 2i, offset + 3i, ...) which occurred. The client then replaces the part of the URI after the final slash (/string) with <DATE>-string where <DATE> is the hex encoded number of seconds since the epoch.

Note

"freenet:" is speced otherwise someone could do something like "http://..."

In the case of KSKs, the human readable part is the whole key, so freenet:[EMAIL PROTECTED] becomes freenet:[EMAIL PROTECTED]

In the case of SSKs, the human readable part is the document name, and freenet:[EMAIL PROTECTED]/style becomes freenet:[EMAIL PROTECTED]/3b4cf86e-style


+++ SplitFile? [CDC]
SplitFile?.Size=<hex file size>
SplitFile?.BlockCount=<hex no. of data blocks>
[SplitFile.CheckBlockCount=<hex. no of check blocks>]
   SplitFile?.Block.<n>=<URI>
[SplitFile.Graph.<x>=a,b,c...]
      
  • 0 <= n <= 65535

  • n must be sequential, starting with 1, in the metadata part

  • n is represented in base 16

The document is made up of a number of pieces, allowing swarming.

Note

thanks much to thelema, oierw, mjr and others for this

Size Required

This defines the final size of the original file.

BlockCount Required

This defines the number of pieces of data that there are.

CheckBlockCount Optional

This defines the number of check pieces that there are. If Omitted, should default to 0.

Block.<n> Required

These are the block URIs, most likely CHKs. These must be numbered 1 to BlockCount?+CheckBlockCount. The first BlockCount? blocks are the data blocks, and the next CheckBlockCount? are the check blocks.

From the above, a client can start a swarmed download of the file. Redundant splitting is optional, and information is below.

Graph.<x> Optional

For each check Block.<x>, there must be a Graph.<x> listing the data blocks that check block derives from. Graph entries for 1..BlockCount should not be given, but for BlockCount?+1..BlockCount+CheckBlockCount must be given. A check block may also be derived from other check blocks, but only lower numbered ones.

Info [MC]

[Info.Format=<string: MIME-type>]
[Info.Description=<string
freeform>]

The Info.* namespace is reserved for Dublin Core metadata. Prepend "Info." to the keys you want to use to prevent collisions. See http://www.freenetproject.org/doc/infometadata.html for details.

Format is the proper place to put the document's mime type. Description is a Plain description of this data, not an abstract or TOC.

ExtInfo [MC]

[ExtInfo.Trailing=yes]
   [ExtInfo.URI=<URI>]
      

If ExtInfo?.Trailing is set to yes, the metadata for this file will include all data after the final "End" in the control document. If the ExtInfo?.URI parameter exists, the contents of the URI pointed to should be included in the metadata for the current document.

Examples

Example 2. Pseudo Website

Version
    Revision=1
    EndPart?
    Document
    [EMAIL PROTECTED]
    EndPart?
    Document
    Name=split
    SplitFile?.Size=102400
    SplitFile?.BlockCount=3
    SplitFile?.Block.1=freenet:[EMAIL PROTECTED]
    SplitFile?.Block.2=freenet:[EMAIL PROTECTED]
    SplitFile?.Block.3=freenet:[EMAIL PROTECTED]
    Info.Format=text/plain
    EndPart?
    Document
    Name=date-redirect
    DateRedirect?.Increment=93a80
    DateRedirect?.Offset=a8c0
    DateRedirect?[EMAIL PROTECTED]/something
    End
      

This would declare a sort of website. Assume it is inserted under freenet:[EMAIL PROTECTED]/mysite. Accessing freenet:[EMAIL PROTECTED]/mysite or freenet:[EMAIL PROTECTED]/mysite// would cause the first redirect (without a Name) to be processed.

If freenet:[EMAIL PROTECTED]/mysite//split were accessed the SplitFile? section would be processed, as would the Info section. This would (hopefully) swarm a file, with some configurable concurrency. None of the CHKs being swarmed need any metadata because it's included in the control document.

If freenet:[EMAIL PROTECTED]/mysite//date-redirect were accessed the DateRedirect? section would be processed. This would redirect to some other URI.

Example 3. TrailingInfo? example

Version
    Revision=1
    EndPart?
    Document
    [EMAIL PROTECTED]
    ExtInfo?.Trailing=yes
    EndPart?
    Document
    Name=doc1
    [EMAIL PROTECTED]
    Info.Format=text/plain
    ExtInfo?.Trailing=yes
    EndPart?
    Document
    Name=doc2
    DateRedirect?[EMAIL PROTECTED]/something
    ExtInfo?[EMAIL PROTECTED]
    End
    <XML blah blah>
blah blah
    </XML>

This describes the same website as above, but with metadata in a trailing field. It's completely reasonable for multiple documents to share the same TrailingInfo? metadata. (Since only one needs to be processed, this shouldn't be a problem)

Handling Other Commands

****This section is Deprecated pending further revision of the spec****

Other commands may be inserted if they follow the general structure of metadata commands set out above.

These commands may set an Importance header of type string. "Required" means that the client should ALWAYS stop processing if it doesn't understand this extended command. "Informational" means that the client should NEVER stop processing if it doesn't understand this extended command. "Optional" means it's up to the client to decide.

If not given, Importance defaults to Informational.

Since a client will process, for a given Name, the first command it understands, you can do the following:

Note

WaitRedirect is an example of an extended command, not a speced command

Example 4. An Extended Command

WaitRedirect?.Time=5
   WaitRedirect?[EMAIL PROTECTED]
   Redirect.Target=freenet:[EMAIL PROTECTED]
      

The WaitRedirect? will override the Redirect, if the client understands WaitRedirects?.

-- SebastianSpaeth - 24 Feb 2002

Attachment: pgp00000.pgp
Description: signature

Reply via email to