Weitere ähnliche Inhalte
Ähnlich wie Plan 9 TCP/IP overview less than 40 characters
Ähnlich wie Plan 9 TCP/IP overview less than 40 characters (20)
Mehr von Ryousei Takano (20)
Kürzlich hochgeladen (20)
Plan 9 TCP/IP overview less than 40 characters
- 1. Plan 9
TCP/IP
oraccha
Plan9 http://d.hatena.ne.jp/oraccha/
2010 3 31
- 2. /net
•
net
ether0 tcp udp cs dns
0 1 clone stats
ctl data err listen local remote status
- 3. •
• NW /net bind
% ns
:
bind -a '#l' /net /net/ether
bind -a '#I' /net IP /net/ipifc,arp,icmp,udp,tcp,...
- 4. write(2) read(2)
ip/devip.c ipwrite ipread
wq rq
tcpkick
ip/tcp.c tcpiput
tcpoutput
ip/ip.c ipoput4 ipiput4
ip/ethermedium.c etherbwrite etherread4
etherbwrite
pc/devether.c etheroq
in
oq
etheriq
pc/etherxxxx.c transmit interrupt
- 5. Queue Block
• struct Queue:
•
• Block
• struct Block:
• BSD mbuf Linux sk_buff
• Block 64KB
- 6. write (port/sysfile.c)
• fdtochan fd Chan *c
• devtab[c->type]->write
Proc Fgrp Chan Dev devtab[]
‘l’
“IP”
*fgrp **fd type ðerdevtab
&ipdevtab
(*write)()
devtab[]
- 7. Dev ipdevtab = {
'I', /* dc */
"ip", /* name */
ipreset, /* reset */
devinit, /* init [Do nothing] */
devshutdown, /* shutdown [Do nothing] */
ipattach, /* attach */
ipwalk, /* walk */
ipstat, /* stat */
ipopen, /* open */
ipcreate, /* create [Eperm] */
ipclose, /* close */
ipread, /* read */
ipbread, /* block read */
ipwrite, /* write */
ipbwrite, /* block write */
ipremove, /* remove [Eperm] */
ipwstat, /* wstat */
};
- 8. • namec ipattach
• Fs ipprotoinit[]
e.g. tcpinit
Fs *ipfs[Nfs] Fs Proto
dev
dev “tcp”
*p[] IP_TCPPROTO
IP_TCPPROTO
*t2p[]
*f
ipprotoinit[]
- 9. void tcpinit(Fs *fs) {
Proto *tcp;
Tcppriv *tpriv;
tcp = smalloc(sizeof(Proto));
tpriv = tcp->priv = smalloc(sizeof(Tcppriv));
tcp->name = "tcp";
tcp->connect = tcpconnect;
tcp->announce = tcpannounce;
tcp->ctl = tcpctl;
tcp->state = tcpstate;
tcp->create = tcpcreate;
tcp->close = tcpclose;
tcp->rcv = tcpiput;
tcp->advise = tcpadvise;
tcp->stats = tcpstats;
tcp->inuse = tcpinuse;
tcp->gc = tcpgc;
tcp->ipproto = IP_TCPPROTO;
tcp->nc = scalednconv();
tcp->ptclsize = sizeof(Tcpctl);
tpriv->stats[MaxConn] = tcp->nc;
Fsproto(fs, tcp);
}
- 10. Closed
passive open appl: listen()
appl: connect()
send: SYN
recv: SYN
send: SYN, ACK Listen active open
recv: SYN
Syn_received Syn_sent
send: SYN, ACK
recv: ACK recv: SYN, ACK
Established send: ACK
active close
recv: FIN
Close_wait
send: ACK
recv: FIN appl: close()
Finwait1
send: ACK
Closing passive close send: FIN
recv: FIN, ACK recv: ACK
recv: ACK Last_ack
send: ACK
2MSL timeout recv: ACK
recv: FIN
Finwait2 Time_wait
send: ACK ※
- 11. update:
• Tcpctl: TCP TCB
•
• cwnd:
• window:
• Limbo: listener
- 12. • TCP
• Reno Tahoe
•
• Window scaling option
- 13. • tcpackproc #I0tcpack
• 50
expire
•
• tcb->timer: tcptimeout
• tcb->acktimer: tcpacktimer
• tcb->katimer: tcpkeepalive
• tcb->rtt_timer: RTT
- 14. •
• /net/tcp/*/state
• IPv4 IPv4-mapped IPv6