故把以前做IPMSG时翻译的文档贴过来希望对网络编程新.docx

上传人:b****1 文档编号:20105915 上传时间:2023-04-25 格式:DOCX 页数:13 大小:20.89KB
下载 相关 举报
故把以前做IPMSG时翻译的文档贴过来希望对网络编程新.docx_第1页
第1页 / 共13页
故把以前做IPMSG时翻译的文档贴过来希望对网络编程新.docx_第2页
第2页 / 共13页
故把以前做IPMSG时翻译的文档贴过来希望对网络编程新.docx_第3页
第3页 / 共13页
故把以前做IPMSG时翻译的文档贴过来希望对网络编程新.docx_第4页
第4页 / 共13页
故把以前做IPMSG时翻译的文档贴过来希望对网络编程新.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

故把以前做IPMSG时翻译的文档贴过来希望对网络编程新.docx

《故把以前做IPMSG时翻译的文档贴过来希望对网络编程新.docx》由会员分享,可在线阅读,更多相关《故把以前做IPMSG时翻译的文档贴过来希望对网络编程新.docx(13页珍藏版)》请在冰豆网上搜索。

故把以前做IPMSG时翻译的文档贴过来希望对网络编程新.docx

故把以前做IPMSG时翻译的文档贴过来希望对网络编程新

最近看到一些朋友在编写网络程序是遇到一些问题,故把以前做IPMSG时翻译的文档贴过来,希望对网络编程新手有所帮助,在寻找编程项目的同学们也可参照此文档写出自己的IPMSG。

本文只包含其中几个比较重要的命令以及运行机制的中文翻译,更详细的内容请参照文后的IPMSG协议英文文档

声明:

下述协议内容略去了一些在编写程序过程中没有用到协议内容,最初的Ipmsg协议是用日文写的,下面协议内容由本人(cugb_cat)翻译自Mr.Kanazawa的英文文档。

本翻译文档可任意传播和使用。

      IP信使传输协议(第9版草案)      1996/02/21

          2003/01/14修订

          H.Shirouzu

        shirouzu@h.email.ne.jp

关于IP信使:

  IP信使使用TCP/UDP协议提供收发消息及文件(目录)。

特性:

IP信使能够安装在任何一个安装了TCP/IP协议栈的操作系统上,使用在线用户的动态识别机制,可以和在线所有用户进行信息交换。

运行机制介绍:

使用TCP/UDP端口(默认端口为2425),消息的收发使用UDP协议,文件(文件夹)的收发使用TCP协议。

1、  命令字:

1)  基本命令字(32位命令字的低8位)

  IPMSG_NOOPERATION    不进行任何操作

  IPMSG_BR_ENTRY    用户上线

  IPMSG_BR_EXIT      用户退出

  IPMSG_ANSENTRY    通报在线

  IPMSG_SENDMSG      发送消息

  IPMSG_RECVMSG      通报收到消息

  IPMSG_GETFILEDATA    请求通过TCP传输文件

  IPMSG_RELEASEFILES  停止接收文件

  IPMSG_GETDIRFILES    请求传输文件夹

2)  选项位(32位命令字的高24位)

IPMSG_SENDCHECKOPT  传送检查(需要对方返回确认信息)

IPMSG_FILEATTACHOPT  传送文件选项

3)  附件类型命令(文件类型命令字的低8位)

IPMSG_FILE_REGULAR  普通文件

IPMSG_FILE_DIR    目录文件

IPMSG_FILE_RETPARENT  返回上一级目录

2、  数据包格式(使用字符串):

1)  数据包格式(版本1的格式)

版本号

(1):

包编号:

发送者姓名:

发送者主机名:

命令字:

附加信息

2)  举例如下

“1:

100:

shirouzu:

Jupiter:

32:

Hello”

3、  数据包处理总述:

1)  用户识别

当IPMSG启动时,命令IPMSG_BR_ENTRY被广播到网络中,向所有在线的用户提示一个新用户的到达(即表示“我来了”);所有在线用户将把该新上线用户添加到自己的用户列表中,并向该新上线用户发送IPMSG_ANSENTRY命令(即表示“我在线”);该新上线用户接收到IPMSG_ANSENTRY命令后即将在线用户添加到自己的用户列表中。

2)  收发消息

使用IPMSG_SENDMSG命令发送消息,消息内容添加在附加信息中;在接收消息时,如果对方要求回信确认(IPMSG_SENDCHECKOPT位打开),则需发送IPMSG_RECVMSG命令并将对方发送的数据包的编号放在附加信息中一同发送至发送消息方

3)  附加文件的扩充(添加于第9版)

带有IPMSG_FILEATTACHOPT位的IPMSG_SENDMSG命令可用来传输文件,文件属性内容添加在附加信息中,添加在消息内容后并以’\0’与之分隔开。

传输文件时以下信息将被添加到消息内容之后(包括格式):

文件序号:

文件名:

大小(单位:

字节):

最后修改时间:

文件属性[:

附加属性=val1[,val2…][:

附加信息=…]]:

\a:

文件序号…

(文件大小、最后修改时间和文件属性为十六进制数,如果文件名中包含’:

’则使用“:

:

”代替)。

接收端开始接收文件时,请求传输文件命令IPMSG_GETFILEDATA将发送到发送端的TCP端口(和UDP的发送端口相同),并将发送端发送的包编号:

文件序号:

偏移量(全为十六进制格式)写到附加信息区一同发送,文件发送端接收到该请求信息并进行校验正确后即开始发送文件(不使用任何格式,亦不进行加密)。

当接收端接收到目录文件时,将发送附加信息区为发送端发送的包编号:

文件序号:

偏移量(全为十六进制格式)的IPMSG_GETDIRFILES命令,以用来请求传输目录文件;发送端则将头信息长度:

文件名:

文件大小:

文件属性:

文件内容添加到附加信息区(除了文件名和文件内容外,其余皆为十六进制),头信息长度是从头信息长度开始到文件内容前的‘:

’分割符为止的字符个数。

当文件属性为IPMSG_FILE_DIR时,IPMsg能够自动识别其为目录,下一个文件的数据在该目录之后。

当文件属性为IPMSG_FILE_RETPARENT时,IPMsg识别其动作为返回上一级目录,在这种情况下,文件名为‘.’其属性为当前目录的值。

附IPMSG协议英文版:

QUOTE:

OriginalipmsgprotocolspecificationiswritteninJapanese.

ThisdocumentwastranslatedbyMr.Kanazawa.

Thisdocumentisnotverifiedyet.

----------------------------------------------------------------------

  IPMessengercommunicationprotocol(Draft-9)  1996/02/21

                      Modified2003/01/14

                        H.Shirouzu

                    shirouzu@h.email.ne.jp

----------------------------------------------------------------------

AboutIPMessenger

  ThisisaSend/ReceivemessageserviceusingtheTCP/UDPPort.

Characteristics

  IPMessengercanbeinstalledinanyOSifTCP/IPisusedonyourmachine.

  Dynamicmemberrecognitioncanbedonewithinyournetworkorspecifiednetwork.

  YoucanexchangemessagesbetweenallIPMsgmembers.

Functiondescription

  UseTCP/UDPport(default:

2425).Seethefollowingdescriptions

  (MessageSend/Receive:

UDP,FileSend/Receive:

TCP)

1.Command

  1)Commandfunctions(Low8bitsfromcommandnumber32bits)

  IPMSG_NOOPERATION    NoOperation

  IPMSG_BR_ENTRY        Entrytoservice(Start-upwithaBroadcastcommand)

  IPMSG_BR_EXIT        Exitfromservice(EndwithaBroadcastcommand)

  IPMSG_ANSENTRY        Notifyanewentry

  IPMSG_BR_ABSENCE    Changeabsencemode

  IPMSG_BR_ISGETLIST    Searchvalidsendinghostmembers

  IPMSG_OKGETLIST        Hostlistsendingnotice

  IPMSG_GETLIST        Hostlistsendingrequest

  IPMSG_ANSLIST        Hostlistsending

  IPMSG_SENDMSG        Messagetransmission

  IPMSG_RECVMSG        Messagereceivingcheck

  IPMSG_READMSG        Messageopennotice

  IPMSG_DELMSG        Messagediscardednotice

  IPMSG_ANSREADMSG    Messageopenconfirmationnotice(addedfromversion-8)

  IPMSG_GETFILEDATA    FileTransferrequestbyTCP

  IPMSG_RELEASEFILES    Discardattachmentfile

  IPMSG_GETDIRFILES    Attachmenthierarchicalfilerequest

  IPMSG_GETINFO        GetIPMSGversioninfo.

  IPMSG_SENDINFO        SendIPMSGversioninfo.

  IPMSG_GETABSENCEINFO    Getabsencesentence

  IPMSG_SENDABSENCEINFO    Sendabsencesentence

  IPMSG_GETPUBKEY        RSAPublicKeyAcquisition

  IPMSG_ANSPUBKEY        RSAPublicKeyResponse

  2)Optionflag(High24bitsfromcommandnumber32bits)

  IPMSG_ABSENCEOPT    Absencemode(Memberrecognitioncommand)

  IPMSG_SERVEROPT        Server(Reserved)

  IPMSG_DIALUPOPT        Sendindividualmemberrecognitioncommand

  IPMSG_SENDCHECKOPT    Transmissioncheck

  IPMSG_SECRETOPT        Sealedmessage

  IPMSG_READCHECKOPT    Sealedmessagecheck(addedfromver8)

  IPMSG_PASSWORDOPT    Lock

  IPMSG_BROADCASTOPT    Broadcastmessage

  IPMSG_MULTICASTOPT    Multi-cast(Multiplecastsselection)

  IPMSG_NEWMUTIOPT    Newversionmulti-cast(reserved)

  IPMSG_AUTORETOPT    Automaticresponse(Ping-pongprotection)

  IPMSG_NOLOGOPT        Nologfiles

  IPMSG_NOADDLISTOPT    NoticetothemembersoutsideofBR_ENTRY

  IPMSG_FILEATTACHOPT    Fileattachment

  IPMSG_ENCRYPTOPT    Code

  IPMSG_NOPOPUPOPT    (Nolongervalid)

  IPMSG_RETRYOPT        Re-sendflag(UsewhenacquiringHOSTLIST)

  3)Extendedcodeflag(hexformatcombination)

  IPMSG_RSA_512

  IPMSG_RSA_1024

  IPMSG_RSA_2048

  IPMSG_RC2_40

  IPMSG_RC2_128

  IPMSG_RC2_256

  IPMSG_BLOWFISH_128

  IPMSG_BLOWFISH_256

  IPMSG_SIGN_MD5

  4)Extendedfilesforattachment(fileattrlow8bits)

  IPMSG_FILE_REGULAR

  IPMSG_FILE_DIR

  IPMSG_FILE_RETPARENT

  IPMSG_FILE_SYMLINK

  IPMSG_FILE_CDEV

  IPMSG_FILE_BDEV

  IPMSG_FILE_FIFO

  IPMSG_FILE_RESFORK

  5)Attachmentfileextendedattribute(fileattrhigh24bits)

  IPMSG_FILE_RONLYOPT

  IPMSG_FILE_HIDDENOPT

  IPMSG_FILE_EXHIDDENOPT

  IPMSG_FILE_ARCHIVEOPT

  IPMSG_FILE_SYSTEMOPT

  6)Extendedfileattributeforattachmentfile

  IPMSG_FILE_UID

  IPMSG_FILE_USERNAME

  IPMSG_FILE_GID

  IPMSG_FILE_GROUPNAME

  IPMSG_FILE_PERM

  IPMSG_FILE_MAJORNO

  IPMSG_FILE_MINORNO

  IPMSG_FILE_CTIME

  IPMSG_FILE_MTIME

  IPMSG_FILE_ATIME

  IPMSG_FILE_CREATETIME

  IPMSG_FILE_CREATOR

  IPMSG_FILE_FILETYPE

  IPMSG_FILE_FINDERINFO

  IPMSG_FILE_ACL

  IPMSG_FILE_ALIASFNAME

  IPMSG_FILE_UNICODEFNAME

2.Commandformat(Useallcharacterstrings)

  1)Command(Formatversion-1)

  Ver

(1):

PacketNo:

SenderName:

SenderHost:

CommandNo:

AdditionalSection

  2)AnexampleforMessageSend/Receivebyusingthecurrentcommandformat

  "1:

100:

shirouzu:

jupiter:

32:

Hello"

3.Commandprocessoverview

  1)Memberrecognition

  AnIPMSG_BR_ENTRYcommandnotifiesanewentrytothecurrent

  membersatstart-up.

  Allmembersaddthenewmembertotheirlistaftergettinganotificationmessage.

  AnIPMSG_ANSENTRYcommandsendsamessagebacktothenewmember.

  Thenewmembergetsthecurrentmemberdatabya

  IPMSG_ANSENTRYcommand.Allmemberscancommunicateaslongasan

  IPpacketexists.

  AnIPMSG_BR_ABSENCEcommandbroadcastsabsencemodecancelor

  nicknamechangetoallmembers.However,anIPMSG_ANSENTRYcommand

  doesnotsendamessageback,whichisdifferentfromanIPMSG_BR_ENTRY

  command.

  IPMSG_BR_ENTRY,IPMSG_ANSENTRY,andIPMSG_BR_ABSENCEcommands

  useanIPMSG_ABSENCEOPTflagforabsencemode.Inputanicknameto

  additionalcommand.

  AddanIPMSG_DIALUPOPTflagfordial-upuserswhocan'tbereachedby

  abroadcastcommand.Amemberrecognitioncommandneedstobe

  sentindividuallytothememberswiththisoptionalflag.

  (Extendedgroup)IPMSG_BR_ENTRYandIPMSG_BR_ABSENCEcommands

  sendsagroupnamebyaddingthenewgroupnameafterthecurrent

  commandformatcharacterstrings(Input'\0'betweenthecurrent

  commandandextendedname).

  2)Send/ReceiveMessage

  SendMessageusesanIPMSG_SENDMSGcommandthatcaninputamessage

  intheextendedarea.

  ReceiveMessagesendsbackanIPMSG_RECVMSGcommandonly

  ifanIPMSG_SENDCHECKOPTflagisON.Inputtheoriginalpacketnumber

  totheextendedarea.

  BroadcastMessageSendusesanIPMSG_BOADCASTOPTcommand

  andanIPMSG_SENDMSGflagshouldbeON.

  Auto-Sendpacket(absencenotice)needstobeaddedtoIPMSG_AUTORETOPT

  forping-pongprotection.IfeitheroneoranotherpacketisON,then

  confirmation/auto-sendpacketisnotsentback.

  SendMessageSealingneedstobeanIPMSG_SECRETOPTpacketON.

  Inthiscase,ReceiveMessagesendsanIPMSG_READMSGcommand.

  Inputtheoriginalpacketnumbertotheextendedarea.

  (AdditionalIPMSG_NOADDLISTOPT)

  WhenreceivinganIPMSG_SENDMSGpacketfromahostthatis

  notonyourSend/Receivelist,IPMsgwilleitherconfirmahostby

  sendinganIPMSG_BR_ENTRYcommandoraddahostnameto

  theSend/Receivelist.

  However,single-shotMessageSend/Receiveactionneedstobeavoided.

  AddanIPMSG_NOADDLISTOPTflagtoanIPMSG_SENDMSGcommand.

  (AdditionalIPMSG_READCHECKOPTfromversion-8)

  WhenanIPMSG_READMSGcommandcontainsanIPMSG_READCHECKOPTflag,

  IPMsgprocessisthesameasIPMSG_SENDMSGwithan

  IPMSG_SENDCHECKOPTflag.

  However,SendMessageusesanIPMSG_ANSREADMSGcommand,

  notIPMSG_RECVMSG.

  3)MessageSend/Receive亅encryptedext

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 职业教育 > 职业技术培训

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1