资源简介

CruiseYoung提供的带有详细书签的电子书籍目录 http://blog.csdn.net/fksec/article/details/7888251 该资料是《TCP/IP详解 卷1:协议》的源代码 对应的书籍资料见: TCP/IP详解 卷1:协议(09年度畅销榜TOP50)(08年度畅销榜TOP50) http://download.csdn.net/detail/fksec/4657587 基本信息 原书名: TCP/IP Illustracted Volume 1:The Protocols 原出版社: Addison Wesley/Pearson 作者: W.Richard Stevens 译者: 范建华等 丛书名: 计算机科学丛书 出版社:机械工业出版社 ISBN:7111075668 上架时间:2000-7-1 出版日期:2000 年4月 页码:423 版次:1-1 所属分类:计算机 > 计算机网络 > 网络协议 > TCP/IP 教材 > 研究生/本科/专科教材 > 工学 > 计算机 教材 > 计算机教材 > 本科/研究生 > 计算机专业教材 > 计算机专业课程 > 计算机网络 编辑推荐   09年度畅销榜TOP50    08年度畅销榜TOP50 作译者 作者: W.Richard Stevens 国际知名的Unix和网络专家,《TCP/IP 详解》(三卷本)作者   W.Richard Stevens(1951-1999),是国际知名的Unix和网络专家;受人尊敬的计算机图书作家;同时他还是广受欢迎的 教师和顾问。Stevens先生1951年生于赞比亚,他的家庭曾多次搬迁,最终定居于南非。早年,他就读于美国弗吉尼亚州的费什本军事学校,后获得密歇根大学学士、亚利桑那大学系统工程硕 士和博士学位。他曾就职于基特峰国家天文台,从事计算机编程;还曾在康涅狄格州纽黑文市的健康系统国际公司任主管计算机服务的副总裁。Stevens先生不幸病逝于1999年9月1日,他的离 去是计算机界的巨大损失。 目录 封面 -1 第1章 概述 1 1.1 引言 1 1.2 分层 1 1.3 TCP/IP的分层 4 1.4 互联网的地址 5 1.5 域名系统 6 1.6 封装 6 1.7 分用 8 1.8 客户-服务器模型 8 1.9 端口号 9 1.10 标准化过程 10 1.11 RFC 10 1.12 标准的简单服务 11 1.13 互联网 12 1.14 实现 12 1.15 应用编程接口 12 1.16 测试网络 13 1.17 小结 13 第2章 链路层 15 2.1 引言 15 2.2 以太网和IEEE 802封装 15 2.3 尾部封装 17 2.4 SLIP:串行线路IP 17 2.5 压缩的SLIP 18 2.6 PPP:点对点协议 18 2.7 环回接口 20 2.8 最大传输单元MTU 21 2.9 路径MTU 21 2.10 串行线路吞吐量计算 21 2.11 小结 22 第3章 IP:网际协议 24 3.1 引言 24 3.2 IP首部 24 3.3 IP路由选择 27 3.4 子网寻址 30 3.5 子网掩码 32 3.6 特殊情况的IP地址 33 3.7 一个子网的例子 33 3.8 ifconfig命令 35 3.9 netstat命令 36 3.10 IP的未来 36 3.11 小结 37 第4章 ARP:地址解析协议 38 4.1 引言 38 4.2 一个例子 38 4.3 ARP高速缓存 40 4.4 ARP的分组格式 40 4.5 ARP举例 41 4.5.1 一般的例子 41 4.5.2 对不存在主机的ARP请求 42 4.5.3 ARP高速缓存超时设置 43 4.6 ARP代理 43 4.7 免费ARP 45 4.8 arp命令 45 4.9 小结 46 第5章 RARP:逆地址解析协议 47 5.1 引言 47 5.2 RARP的分组格式 47 5.3 RARP举例 47 5.4 RARP服务器的设计 48 5.4.1 作为用户进程的RARP服务器 49 5.4.2 每个网络有多个RARP服务器 49 5.5 小结 49 第6章 ICMP:Internet控制报文协议 50 6.1 引言 50 6.2 ICMP报文的类型 50 6.3 ICMP地址掩码请求与应答 52 6.4 ICMP时间戳请求与应答 53 6.4.1 举例 54 6.4.2 另一种方法 55 6.5 ICMP端口不可达差错 56 6.6 I

资源截图

代码片段和文件信息

/*
 * Issue an ICMP address mask request and print the reply.
 *
 * This program originated from the public domain ping program written
 * by Mike Muuss.
 *
 * You must be superuser to run this program (or it must be suid to root)
 * since it requires a raw socket.
 */

#include 
#include 
#include 
#include 
#include 
#include 

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define DEFDATALEN (12) /* default data length */
#define MAXIPLEN 60
#define MAXICMPLEN 76
#define MAXPACKET (65536 - 60 - 8)/* max packet size */

struct sockaddr whereto; /* who to send request to */
int datalen = DEFDATALEN;
int s;
u_char outpack[MAXPACKET];
char *hostname;
u_long inet_addr();
char *inet_ntoa();
void sig_alrm(int);
int response = 0;

main(argc argv)
int argc;
char **argv;
{
int i ch fdmask hold packlen preload;
extern int errno;
struct hostent *hp;
struct sockaddr_in *to;
struct protoent *proto;
u_char *packet;
char *target hnamebuf[MAXHOSTNAMELEN] *malloc();

if (argc != 2)
exit(1);

target = argv[1];

bzero((char *)&whereto sizeof(struct sockaddr));
to = (struct sockaddr_in *)&whereto;
to->sin_family = AF_INET;

/* try to convert as dotted decimal address
   else if that fails assume it‘s a hostname */
to->sin_addr.s_addr = inet_addr(target);
if (to->sin_addr.s_addr != (u_int)-1)
hostname = target;
else {
hp = gethostbyname(target);
if (!hp) {
fprintf(stderr “unknown host %s\n“ target);
exit(1);
}
to->sin_family = hp->h_addrtype;
bcopy(hp->h_addr (caddr_t)&to->sin_addr hp->h_length);
strncpy(hnamebuf hp->h_name sizeof(hnamebuf) - 1);
hostname = hnamebuf;
}

packlen = datalen + MAXIPLEN + MAXICMPLEN;
if ( (packet = (u_char *)malloc((u_int)packlen)) == NULL) {
fprintf(stderr “malloc error\n“);
exit(1);
}

if ( (proto = getprotobyname(“icmp“)) == NULL) {
fprintf(stderr “unknown protocol icmp\n“);
exit(1);
}

if ( (s = socket(AF_INET SOCK_RAW proto->p_proto)) < 0) {
perror(“socket“); /* probably not running as superuser */
exit(1);
}

/*
 * We send one request then wait 5 seconds printing any
 * replies that come back.  This lets us send a request to
 * a broadcast address and print multiple replies.
 */

signal(SIGALRM sig_alrm);
alarm(5); /* 5 second time limit */

sender(); /* send the request */

for (;;) {
struct sockaddr_in from;
int cc fromlen;

fromlen = sizeof(from);
if ( (cc = recvfrom(s (char *)packet packlen 0
         (struct sockaddr *)&from &fromlen)) < 0) {
if (errno == EINTR)
continue;
perror(“recvfrom error“);
continue;
}
procpack((char *)packet cc &from);
}
}

/*
 * Send the ICMP address mask request.
 */

sende

评论

共有 条评论