libJingle中关于p2p的一段文字翻译

 
Peer-to-Peer Component     

P2P组件

 

This component manages the connection between the local and remote computer. It sends and receives peer to peer data across the network, generates local candidates , allocates sockets, and manages and monitors connection quality. The data channel is created and managed by the top level P2PTransport object, which hosts a P2PTransportChannel that is the actual endpoint for data reading and writing. libjingle provides several port types, including UDP, TCP, and a mock SSL port. P2PTransportChannel abstracts data sending and receiving to a simple read or write command. The Session Logic and Management Component uses this component as a black box to generate candidates, maintain the connection, and send/receive data as requested. In general, you should not need to modify items in this component for different session types, although there are a very few scenarios in which you might.

这个组件管理本地和远程计算机之间的连接。该组件发送和接收穿过网络的点对点的数据,产生本地候选,分配套接字,还管理和监视连接质量。由顶级对象P2PTransport 创建和管理数据通道,宿主在P2PTransport 中的P2PTransportChannel 是实际用于读写数据的端点。libjingle提供了多种端口类型,包括UDP、TCP、和模拟的SSL端口。P2PTransportChannel将实际数据的手法抽象到一个简单的读写命令。会话逻辑和管理组件使用本组件以黑盒的形式封装了候选产生、连接维护和收发数据。通常,你不用为不同的会话类型修改本组件中的项目,除了仅有的几个场景。

  • PortAllocator , together with its helper class PortAllocatorSession (not shown), allocates local ports in response to requests from P2PTransport . The application creates this object. It is extended to enable new kinds of ports and protocols—libjingle provides a subclass, HttpPortAllocator , which supports relay ports more naturally. A custom application Session Logic and Management Component class instantiates this object.
  • PortAllocator ,与它的辅助类PortAllocatorSession 一起,根据P2PTransport 的请求分配本地端口。应用程序应创建本对象。这个类可以被扩展,以便新类型的端口和协议可以被使用-libjingle提供了一个派生类,HttpPortAllocator ,用于更自然的支持中继端口。一个定制的应用程序会话逻辑和管理组件中实例化本组件。
  • P2PTransport is the top level creation object for the peer to peer data channel . Its purpose is to create and monitor the P2PTransportChannel objects that represent data connections, but it does not see any of the actual data itself. After creating a data connection, it hands this connection (a P2PTransportChannel ) off to the requestor (the Session object). Only one channel, judged the best connection by write latency, is active at any given time. Incoming latency is not checked. In turn, each Channel has one or more Connection objects, which represent a local Port /remote address pair representing the actual data stream. P2PTransport switches connections automatically when a connection becomes unwritable. P2PTransport uses the helper class PortAllocator to find and allocate physical ports/sockets on the computer. P2PTransport is instantiated by Session when it is initiated by either party. Although Session can hold multiple Transport objects of different types, in the current code only one P2PTransport instance is used. (See Transports, Channels, and Connections for more information)
  • P2PTransport是为P2P数据通道创建的顶级对象。它的目的用于创建和监视用于表示数据连接的P2PTransportChannel 对象,但它自身并看不到任何实际的数据。在创建数据连接后,它负责根据Session对象的请求来切断连接。仅有一个通道,就是根据写反应时间(write latency)被裁定为最佳连接的那一个,始终保持激活。读入反应时间并未检查。每个 Channel 有一个或多个Connection 对象,该对象用本地端口/远端地址对来表达实际的数据流。P2PTransport 自动切换连接当该连接变为不可写。P2PTransport 使用辅助类PortAllocator 来查找和分配实际的计算机物理端口/套接字。P2PTransport 类由Session 在当事方初始化时实例化。尽管Session 可以拥有多个不同类型的Transport 对象,但当前代码仅有一个P2PTransport 实例被使用。
  • P2PTransportChannel wraps a number of connections and continually monitors and selects the best one. This is the end of the data pipeline. Applications read data by listening for P2PTransportChannel::SignalReadPacket and calling P2PTransportChannel::SendPacket (or by calling similar methods on a wrapper class, such as PseudoTcpChannel ).
  • P2PTransportChannel 封装了一系列的连接,并持续监视并选择一个最好的。这是end of(终止/后台??)数据管道。应用程序通过侦听(这里的侦听是指sigslot中的事件回调机制)P2PTransportChannel::SignalReadPacket 和调用P2PTransportChannel::SendPacket 来读取数据。
  • Ports and Sockets (not shown) are wrappers that handle the actual requests to send and receive data to and from the remote computer. A Port object wraps a physical port on the local computer by means of the Socket object that it hosts. A Socket object represents the physical socket on the local computer. The base Socket class is overridden for specific socket types. Socket objects are additionally wrapped by the AsyncPacketSocket class, which enables asynchronous packet reception. Sockets are created by Session or other objects and passed to a Port when it is created. The basic Port class is extended for specific types of ports (UDP, TCP, and so on). A Port object generates candidate lists (actually each port only generates one candidate) at a request from the PortAllocator object, which asks each type of port (TCP, UDP, Relay, etc) to generate a candidate list. Ports also send and approve bind requests from remote computers, read and write data to the socket asynchronously. Port objects are responsible for generating local candidates to send to the remote computer.
  • Ports and Sockets 封装了用于对远程计算机发送和读取数据的请求。一个Port 对象封装了位于本地计算机上的物理端口。一个Socket 对象封装了物理的socket(指操作系统中的socket handle)。一个Socket 基类被指定套接字类型的子类所改写。Socket 被进一步封装为AsyncPacketSocket 类,它可以异步接收数据包。。。。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值