• No results found

Web Technologies Nodrm

N/A
N/A
Protected

Academic year: 2021

Share "Web Technologies Nodrm"

Copied!
626
0
0

Loading.... (view fulltext now)

Full text

(1)
(2)

ACHYUT GODBOLE is currently the Managing Director of Softexcel Consultancy Services advising global companies about strategies of growth and setting up of delivery organizations and processes for offshore centers.

Having been a National Merit Scholar throughout his educational career and with a B Tech. in Chemical Engineering from IIT, Mumbai, Godbole has over thirty years of software development experience in India, USA and UK in companies like IBM, Hindustan Lever, Systime (UK), Syntel, L&T Infotech, Apar Technologies and Disha Technologies.He has contributed to building of companies such as Patni (as GM), Syntel (as MD), L&T Infotech

(as CEO), Apar Technologies (as CEO) and Disha Technologies (as Executive Director). All these companies grew many times in terms of revenue and profitability during his tenure.

Apart from this, Godbole has written technical books like Operating Systems, Data Communications and Networking, and Web Technologies, all published by McGraw-Hill Education (India). Some of these have been published in Singapore by McGraw-Hill for international distribution and have been translated in different languages including Chinese.

ATUL KAHATE has close to thirteen years of experience in Information Technology in India and abroad in various capacities. He has done his Bachelor of Science degree in Statistics and his Master of Business Administration in Computer Systems. He has authored sixteen highly acclaimed books published by McGraw-Hill Education on various areas of Information Technology (including editions), titled Web Technologies—TCP/IP to Internet Application Architectures, Fundamentals of Computers, Information Technology and Numerical Methods, Foundations of Information Technology, Cryptography and Network Security, Object Oriented Analysis and Design, and Schaum’s Series Outlines—Programming in C++. Two of these are published as international editions worldwide by McGraw-Hill Education and have also been translated into Chinese. Several of his books are being used as course textbooks or sources of reference in a number of universities/colleges/IT companies all over the world.

Kahate has worked with Syntel, L&T Infotech, American Express and Deutsche Bank previously and is working with Oracle Financial Services Consulting (formerly i-flex solutions limited) for over 6 years now, currently as Head—Technology Practice. He lives in Pune with his wife Anita, daughter Jui and son Harsh. He can be reached at [email protected].

(3)

A

CHYUT

G

ODBOLE

Managing Director Softexcel Consultancy Services

A

TUL

K

AHATE

Head Technology Practice

Oracle Financial Services Consulting (formerly, i-flex solutions limited)

Tata McGraw-Hill Publishing Company Limited

NEW DELHI

McGraw-Hill Offices

New Delhi New York St Louis San Francisco Auckland Bogotá Caracas Kuala Lumpur Lisbon London Madrid Mexico City Milan Montreal

San Juan Santiago Singapore Sydney Tokyo Toronto

(4)

Copyright © 2008, by The McGraw-Hill Companies Inc. All rights reserved.

No part of this publication may be reproduced or distributed in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise or stored in a database or retrieval system without the prior written permission of the publishers. The program listings (if any) may be entered, stored and executed in a computer system, but they may not be reproduced for publication.

This edition can be exported from India only by the publishers, Tata McGraw-Hill Publishing Company Limited.

ISBN (13): 978-0-07-066905-5 ISBN (10): 0-07-066905-8 Managing Director: Ajay Shukla

General Manager: Publishing—SEM & Tech Ed: Vibha Mahajan Sponsoring Editor: Shalini Jha

Jr. Sponsoring Editor: Nilanjan Chakravarty Executive—Editorial Services: Sohini Mukherjee Junior Manager—Production: Anjali Razdan

General Manager: Marketing—Higher Education & School: Michael J Cruz Product Manager: SEM & Tech Ed: Biju Ganesan

Controller—Production: Rajender P Ghansela Assistant General Manager—Production: B L Dogra

Information contained in this work has been obtained by Tata McGraw-Hill, from sources believed to be reliable. However, neither Tata McGraw-Hill nor its authors guarantee the accuracy or completeness of any information published herein, and neither Tata McGraw-Hill nor its authors shall be responsible for any errors, omissions, or damages arising out of use of this information. This work is published with the understanding that Tata McGraw-Hill and its authors are supplying information but are not attempting to render engineering or other professional services. If such services are required, the assistance of an appropriate professional should be sought.

Typeset at Le Studio Graphique, Guru Shivir, 12, Sector 14, Gurgaon 122 001, and printed at Avon Printers, 271, F.I.E., Patparganj, Delhi 110 092

Cover: SDR Printers RCXLCRCXDRYZY

(5)

Sulabha and Sharad Pishavikar Vinayak and Vaishali Godbole

Pushpa Agarkar

For always being there to encourage and applaud!

ACHYUT GODBOLE To

my parents

Late Dr Meena and Dr Shashikant Kahate

For always giving me freedom to carve my own path!

(6)

NEN

Preface to the

First Edition

The Internet has a very interesting and chequered past. Born out of the cold war, it assumed an extraordinary prominence in the early I 990s, and became a buzzword in the late I 990s, as the century drew to a close. Everyone was talking about the Internet. These were the Internet times. Everything that you did was thought to have some connection or the other with the Internet—whether it involved buying, selling, recruiting, publishing, travelling, emails or even match-making. It was as if the Internet was at the center of our lives, driving each and every aspect of it.

Hundreds, if not thousands of companies sprang all around the globe with the Internet as their central focus. Many brick and mortar companies believed that they would not exist if they continued their operations in the old fashioned way, i.e. without becoming Internet-enabled. Many believed that all the middlemen who did not add value would vanish and perish. If a consumer could buy directly sitting at home logging on to the Web site of a company, what was the need for all these shops, superstores as well as agents and brokers? This new awakening gave rise to a whole lot of new technologies, especially in the field of the Web and in the wireless world. Training institutes teaching Java, ASP, HTML or WAP mushroomed and became popular.

And suddenly, the dotcom burst. Immediately, there was an awakening that the Internet was not a panacea for everything. After all, you needed to eat, drink, sleep, travel and so on. The brick and mortar had to exist to provide for all of these. The Internet, after all, was only a tool to make the brick and mortar more effective. The Internet bubble had burst. Hundreds of companies were completely destroyed in this turmoil. IT professionals stopped pursuing careers in Java, ASP, etc. as the demand for these skills significantly dropped.

The period that we are currently passing through is a period of recovery. There is a growing realization that though the Internet was not a solution to all the problems in the world, it could offer considerable help in many spheres of our activities. E-commerce was not dead after all. May be, it will not eliminate all the middlemen. However, it can and will offer a substantial help in the B2B world. Businesses embracing the Internet for their commercial activities will definitely have a competitive edge and that is a good enough reason for many corporations to still continue looking at e-enabling their operations, especially in this era of fierce competition. It is a firm belief of the authors of the present book that the Internet is still a very important force that will change the way we conduct our business, though it will be an evolution, instead of a revolution, as envisaged earlier. Therefore, Web Technologies, we believe, art still extremely important and relevant and will continue to be so for many years to come.

Both of us are practising IT professionals, dealing with the global customers and have dealt with the mainframe and the classical (two-tier) client-server architectures in the past. When we had to deal with the Web Technologies, we found literally dozens if not hundreds of books talking about HTML and Web page

(7)

NN

designing, or about directly Java programming. There are, of course, many others, which talk about how the Internet will change our lives or the businesses. But, there were and still are not many books dealing with the whole range of Web Technologies, starting from the very foundations of the Internet, i.e. TCP/IP to the basic concepts of Web Technologies—HTML, ASP, JSP, EJB, COM, CORBA, XML, EDI, WAP and the different architectural issues, such as transaction management, security, payment systems, etc. We have precisely tried to do that. We truly believe that at the time of going to press, barring one or two attempts, there is not a single book in the world, which has tried to cover the topics that this book has, especially in the manner that it has.

The book is written in an extremely simple and lucid language with ample examples and diagrams. It is truly a step-by-step introduction, though an elaborate one, to the Web Technologies. The book is aimed at graduate and post-graduate students as well as IT professionals. It will be a very useful guide to all the IT professionals, managers and project leaders, who are familiar with the world of mainframes or classical two-tier client-server architectures, and who want to understand the Web Technologies at a fair amount of depth. The readers should remember that it is not about a programming language. A very basic, elementary understanding of how computers and communications work and the knowledge of a programming language would help, but is not a must. Even business managers should understand most of the concepts and should find the book useful to deal with the Internet jargon. The book, in the ultimate analysis, is written to demystify the world of Web Technologies. The book is aimed at painting a broad picture of Web Technologies, so that one can choose to go into any topic of interest, such as Java or EJB or .Net, in depth, without losing the context.

The organization of the book is as follows.

Chapter 1 introduces the concept of networking protocols. It then discusses the OSI protocol suite. The

organization of the OSI model and the details of the various layers are discussed with relevant examples.

Chapter 2 introduces the idea of internetworking. The concepts of internetworking, what it takes to form an

internetwork are discussed. We also discuss the basics of the Internet, its history and architecture.

Chapters 3 to 6 discuss the TCP/IP protocol suite in great depth. All the key aspects of TCP/IP and all the

important TCP/IP protocols are discussed. Chapter 3 discusses the Internet layer protocols, namely IP, ARP, RARP and ICMP. We examine why IP makes the Internet such an exciting proposition, and discuss the other protocols in the context of IP. Chapter 4 covers the two transport layer protocols in the TCP/IP suite: the reliable TCP and the unreliable UDP. We also study the differences between the two. Chapter 5 examines some of the key applications of TCP/IP, namely the DNS, email, FTP and TFTP, The important email protocols, such as SMTP, POP and IMAP are discussed. We also examine how FTP and TFTP work for file transfer applications. Chapter 6 introduces the key Web application protocols, HTTP and WWW. For the sake of completeness, we also discuss the older TELNET protocol. In this chapter, we also study what HTML is, and how it is used in the creation of Web pages.

Chapter 7 takes a different path, and introduces the business side of the Web. Here, we study the various

software packages and applications that are readily available. We also examine the B2B and B2C aspects of e-commerce here.

Chapter 8 introduces the topic of Web Technologies. We study static Web pages here. We also examine the

possible Web architectures in this chapter. We study frames and forms, two of the most important aspects of Web pages.

Chapter 9 discusses the idea and importance of dynamic Web pages. We study why dynamic Web pages are so

important for the Internet to truly become a business platform. We examine the important dynamic Web page technologies, such as CGI, ASP, JSP and servlets here.

(8)

NNE

Chapter 10 moves on to active Web pages. The Java programming language introduced the concept of applets,

which made the Web pages active. We examine applets, and Microsoft’s version of active Web pages, using the ActiveX Controls.

Chapter 11 examines why session management is a very crucial issue in the Web world. We study what

happens without it, and why it is so vital. Then we examine the various technologies that allow application architects to perform session management, such as cookies, session variables, hidden variables, etc.

Chapter 12 covers the idea of a transaction, its types, and how and why the database transactions are not good

enough. We then examine the two most popular transaction management software technologies for the Web, Microsoft’s MTS and Sun’s EJB.

Chapter 13 talks about the various security issues related to the Internet. We study the basics of cryptography

here. We study what are digital certificates, digital signatures, how they can be created and used. We also study organizational security issues, with reference to firewalls.

Chapter 14 details the various payment mechanisms that are used over the Internet. We discuss SSL here,

although it is not-strictly a payment mechanism, because it is so closely referred to in the context of secure credit card payments. We also discuss the SET protocol in great detail, and then compare SET with SSL. We cover the electronic money and credit card processing models.

Chapter 15 discusses the idea of middleware. We discuss why middleware is an important aspect of modem

Web Technology architectures. We describe these details with the help of an example in a step-by-step fashion. We discuss key middleware technologies such as CORBA, RMI and DCOM. We also compare them with each other.

Chapter 16 covers Electronic Data Interchange (EDI). Although EDI is a technology that is in use for several

years now, it has gained renewed prominence due to its adaptation on the Internet. We discuss how EDI works, what are its benefits, and how it fits in with the Internet.

Chapter 17 discusses the exciting new technology of XML. We take a technical look at the XML world, and

also see how it is useful in the design of Web-based solutions. More specially, we concentrate on issues that make XML the modern ASCII.

Chapter 18 closes our discussion with an in-depth look at the Wireless Application Protocol (WAP). We study

WAP in great detail, taking a look at each of its layers. We study WML and WML Script, and also study their differences vis-à-vis HTML and JavaScript/VBScript. We also note why WAP is not so popular, and what are the likely alternatives.

Five appendices supplement our core chapters in a number of ways.

Appendix A is a case study of a Web commerce site using Microsoft’s ASP. Without going into the technical

jargon, we examine the essential requirements of a Web application, and how we can deal with those using ASP. The focus is on the architecture here, and not on the syntax.

Appendix B takes a look at the emerging technologies, such as Microsoft’s .Net Framework.

Appendix C discusses the various ways in which one can obtain connectivity to the Internet. We study how

(9)

NNEE

Appendix D presents an introduction to Object Technology for those who are not familiar with it. Apart from

the theory, we also discuss a simple case study to see how Object Technology differs from the conventional application development techniques.

Appendix E concludes our discussions with a case study on security using Public Key Infrastructure (PKI).

We examine what is required to provide for cryptographic functionalities in Web applications. For this, we put forth a list of requirements, and examine how they can be met, and what technologies are required for this purpose.

There are a number of individuals who have made this book possible. Shobha Godbole and Anita Kahate obviously stand out. We are deeply thankful that they put up with us in spite of household commitments. Anita, being a software professional herself, gave very valuable suggestions, and helped in terms of developing some of the content and also in a number of reviews. Our parents, family members, friends, colleagues and many others also constantly encouraged us. We must thank Dr N Subrahmanyam, Vibha Mahajan, Yusuf Ahmad Khan, Srinivas Iyer, Mini Narayanan and the rest of the team at Tata McGraw-Hill for their valuable suggestions and support. The book would not have seen the light of the day without their help.

But ultimately, the book is a result of a very strong passion that both of us share-the passion for acquiring and sharing knowledge, and also the passion to demystify, so that we all can learn and enjoy. To what extent this goal has been achieved, only time will tell. The reader is most welcome to write back to us at [email protected] or [email protected].

ACHYUT GODBOLE ATUL KAHATE

(10)

xv

Preface to the

Second Edition

Overview of the New Edition

It is with great pleasure that we are bringing out the second edition of this book since the time the first version came out (more than six years back). Six years is a very long time frame for the new edition of a technical book, and more so if the book happens to be covering the latest trends in Web-based technologies. We hope that the present edition lives up to the challenge, and provides a power-packed update to all the contents that were there in the first edition, in addition to a lot of new content, which has been developed from scratch. We are confident that the reader would find immense value in this book for keeping pace with the changing paradigm of Internet technologies, and that sufficient concepts as well as depth are provided to give the reader a feel of complete understanding of the whole thing.

Specific Improvements in the New Edition

Here is a summary of prominent changes made to the content and structure of the book:

n Coverage of TCP/IP is made more comprehensive by adding more relevant material to various protocols and compacting some material which was perceived to be too lengthy earlier.

n The coverage of HTML is enhanced with the inclusion of many hands-on examples.

n There is a separate chapter on JavaScript now, as against a very basic example in the first edition.

n The technology of AJAX is covered in detail.

n The obsolete material on ASP is dropped, and it is replaced by a detailed discussion of ASP.NET.

n A separate chapter is dedicated to the latest Java Web technologies.

n The material on information security is split into two chapters for more focused coverage.

n The coverage of XML is greatly expanded.

n Web services and middleware technologies are discussed in detail, with the focus shifting from DCOM, CORBA, and RMI to Web services.

n Wireless technologies are covered in detail for the first time.

n Obsolete/irrelevant material is completely removed, e.g., detailed discussions on electronic commerce and products in that space.

(11)

xvi

Scope/Target Audience

The book is already in use as a textbook or source of reference in several undergraduate/postgraduate courses (BE/B-Tech/MCA/ME/M Sc/MBA/MCS/M-Tech) in India as well as many other countries. The present edition would not only satisfy the needs of these syllabi, but would also lead to updates to these syllabi.

Roadmap for Various Target Courses

The book has been intentionally written in a very simple fashion. Explanation of complex topics is done with a view to minimize jargon. However, we would like to provide the following guidelines for different kinds of readers:

n Those who want to understand the various Internet protocols and their usage should concentrate mainly on chapters 1–6.

n Readers with interest in the programming of the Internet can start with Chapter 6, and can go on till Chapter 9. They can then read Chapters 13 and 14.

n Of course, we recommend that everyone else should read all the chapters in the given sequence for a true understanding of the whole thing.

Salient Features

The salient features of the book are the following:

n Coverage of all the relevant Web technologies in a single book, which is not found in any other book on the subject

n Lucid explanations

n A multitude of diagrams and illustrations

n Coverage of all the latest and futuristic technologies

n Suitable for people who want conceptual knowledge as well as for those who want to get into Internet programming

n Plenty of hands-on examples for readers to try out on their own

n Focus on practical situations along with relevant theory

Chapter-by-Chapter Changes

Here is a summary of changes/additions made to all the chapters in the book. Chapter 1—No changes

Chapter 2—No major changes

Chapter 3—New diagrams related to better understanding of IP addresses are added. ARP is explained in more detail. Coverage of BOOTP and DHCP protocols is added.

Chapter 4—No changes

Chapter 5—More details about the SMTP protocol are added. POP and IMAP protocols are also covered in more detail. MIME concept is explained in more detail. Coverage of PGP now includes key rings and related areas. The FTP protocol is also explained in more detail.

(12)

xvii Chapter 6—The coverage of HTML and CSS is greatly expanded with several examples.

Chapter 7—This chapter in the earlier edition had become completely obsolete. It is dropped altogether, and is replaced with a new chapter that covers the JavaScript language in far more detail than the earlier edition. Detailed coverage of the AJAX technology is also provided with several hands-on examples.

Chapter 8—This is also a completely new chapter that covers Microsoft’s ASP.NET technology in immense detail. It explains all the features that are required to create dynamic Web applications using this technology. Chapter 9—This chapter was there earlier in some form (as Chapter 9 itself), but has been completely rewritten to focus only on Java Web technologies. It covers all the important Java-based technologies such as Java servlets, JSP, JDBC, EJB, Struts, and JSF.

Chapter 10—This chapter now focuses only on Web-security related issues. It deals with application-related security concerns. It is expanded as compared to the previous edition.

Chapter 11—To complete the picture painted by the earlier chapter, this chapter discusses all the network-security related concepts. It is expanded as compared to the previous edition.

Chapter 12—This chapter is dedicated to a discussion of online payment protocols. The earlier discussions from the previous edition are retained and expanded, as appropriate.

Chapter 13—This chapter covers all the features of XML. In the earlier edition, there was a lot of focus on EDI, and very little discussion of XML. Things have been reversed now. All the key aspects of XML, including DTD, schema, XSL, parsing, etc., have been dealt with and several hands-on examples are provided for ease of understanding.

Chapter 14—This new chapter moves the attention of middleware from obsolete technologies such as CORBA and COM, and instead explains Web services in great detail.

Chapter 15—The earlier edition had only covered WAP as the wireless Internet access mechanism. This edition compresses the discussion of WAP (which is obsolete) and adds details on several other wireless Internet access protocols.

Web Supplement/CD

The Online learning Center of the book can be accessed at www.mhhe.com/webtech2 and contains the following materials.

For the Student

n Extra Reading Material on Web Technology, Dynamic Web Pages, Active Web Pages, E-Commerce.

n Self-Assessment Quiz

n Web References

n Link providing direct access to author’s inbox for interaction with students For the Instructor

n Solutions Manual

n PowerPoint Slides

(13)

xviii

Acknowledgements

Several people have helped us throughout the years in making the first edition first a reality and then a success. Our family members, friends, and colleagues have been always of tremendous help. Shobha Godbole and Anita Kahate stand out for their support while their husbands keep on carrying out their idiosyncrasies! In addition,

Atul would like to acknowledge the support of his parents (Dr Shashikant and Late Dr Meena Kahate), daughter Jui and son Harsh, and all the colleagues at Oracle Financial Services Consulting (earlier i-flex solutions limited) and students/teachers at various colleges.

We would also like to acknowledge the efforts of the following reviewers who have meticulously gone through the initial manuscript and enriched it with their useful suggestions and feedback.

Sanjiv Jain Laxmi Narayan College of Technology

Bhopal

Vijay Gupta Bharat Institute of Technology

Meerut

Chiranjeev Kumar Computer Science and Engineering Indian School of Mines, Dhanbad

Deepali Vora Department of Computer Engineering and IT

Vidyalankar Institute of Technology, Mumbai

Charusheela Nehete Department of Computer Science and Engineering Vivekananda Institute of Technology, Mumbai

R R Rajalakshmi Department of Computer Science and Engineering Kongu Engineering College, Erode

D D Venkatesan Department of Information Technology Bharathidasan Institute of Technology Anna University, Chennai

V Senthilkumaran Department of Mathematics and Computer Applications PSG College of Technology

Feedback

We hope that the second edition of the book is received with even better enthusiasm than the first. If you have any comments, suggestions, or questions, feel free to write to us at [email protected] and [email protected]. We would be glad to hear from you.

ACHYUT GODBOLE ATUL KAHATE

(14)

NEEE

Foreword

Internet is going to be a dominant force in the 21st century. By the year 2010, it would be virtually impossible for any business to be completely unconnected with the Internet and, therefore, application development in the years to come will be predominately based on the Web Technologies. Web services, in particular, are going to play an extremely pivotal role in future applications development. However, this was not the case a few decades or even a few years back.

If the 1960s could be called decade of mainframe computing, the 1970s the decade of minicomputers, the 1980s the decade of the PC, the decade of 1990 was dominated by networking in general and the Internet in particular. The turn of the century not only faced and successfully overcame the Y2K menace, but also saw the bubble of the Internet and the dotcom finally burst.

At one time, people actually believed that the Internet could solve almost all the problems. Thanks to the media, everybody believed that almost all businesses could be conducted on the net and that the brick and mortar business model was almost breathing its last. The Java language and the web architectures started becoming popular. But, after the dotcom burst, the interest in the Internet started receding.

However, though, Internet is not the panacea for all the ills or business challenges, it is far from dead. While the to-Consumer (B2C) model will have to undergo a number of major changes, the Business-to-Business (B2B) model is a very sturdy one. In fact, almost all the IT Systems that will be designed in times to come will have to be based on or be connected with the web in some fashion or other. Therefore, the basic understanding of web architectures—J2EE, .Net, the aspects related to performance, security, design, XML, Web services, WAP and many other aspects—is going to be extremely important for not only the programmer, but also project/business managers, designers and architects.

It is on this background that the present book written by Achyut S. Godbole and Atul Kahate is an extremely important contribution to the complete understanding of Web Technologies. The book is written in an extremely simple language with very good and illustrative figures, which enhance the understanding of the subject. The authors have succeeded in demystifying the subject by presenting a complex subject in a very simple and easy-to-understand manner.

The organization of the text, its sequence, the summaries and questions at the end of each chapter make this an ideal text for any student of Computer Science/Information Technology at Bachelor’s or Master’s level. It can also be used by the business managers/architects who want to get acquainted with this subject at a fairly deep level.

(15)

NEL

Web services and the related products are likely to create new paradigms in tomorrow’s software world. This will give a tremendous boost to entrepreneurs around the world including India. I am sure this book will provide solid foundation for all such professionals.

I congratulate both Achyut and Atul for this work. I am very proud of Achyut because he is one of the rare CEOs who, apart from contributing to the growth of various companies and the IT business in general, has also managed to write serious technical books on Information Technology. I wish both the authors the best of success!

HARISH MEHTA Chairman and Managing Director Onward Technologies Limited COFOUNDER OF MASCOM

(16)

LEE

Contents

Foreword xiii

Preface to the Second Edition xv

Preface to the First Edition xix

1. Networking Protocols and OSI Model

1–21

Introduction 1

1.1 Protocols in Computer Communications 3 1.2 The OSI Model 7

1.3 OSI Layer Functions 10

Summary 20

Review Questions 20

2. Internetworking Concepts, Devices, Internet Basics,

22–43

History and Architecture

Introduction 22

2.1 Why Internetworking? 23

2.2 The Problems in Internetworking 23 2.3 Dealing with Incompatibility Issues 24 2.4 A Virtual Network 27 2.5 Internetworking Devices 28 2.6 Repeaters 29 2.7 Bridges 30 2.8 Routers 35 2.9 Gateways 38

2.10 A Brief History of the Internet 39 2.11 Growth of the Internet 40

Summary 42

(17)

LEEE

3. TCP/IP Part I Introduction to TCP/IP, IP, ARP, RARP, ICMP

44–79

Introduction 44 3.1 TCP/IP Basics 45 3.2 Addressing 48 3.3 Why IP Addresses? 50 3.4 Logical Addresses 52 3.5 TCP/IP Example 52

3.6 The Concept of IP Address 60

3.7 Address Resolution Protocol (ARP) 67

3.8 Reverse Address Resolution Protocol (RARP) 71 3.9 BOOTP 73

3.10 DHCP 74

3.11 Internet Control Message Protocol (ICMP) 74

Summary 77

Review Questions 78

4. TCP/IP Part II TCP, UDP

80–100

Introduction 80

4.1 TCP Basics 80 4.2 Features of TCP 81

4.3 Relationship between TCP and IP 84 4.4 Ports and Sockets 85

4.5 Connections—Passive Open and Active Open 89 4.6 TCP Connections 89

4.7 What Makes TCP Reliable? 91 4.8 TCP Segment Format 92 4.9 Persistent TCP Connections 94 4.10 User Datagram Protocol (UDP) 95 4.11 UDP Datagram 95

4.12 Differences between UDP and TCP 97

Summary 98

Review Questions 99

5. TCP/IP Part III DNS, Email, FTP, TFTP

101–144

Introduction 101

5.1 Domain Name System (DNS) 101 5.2 Electronic Mail (Email) 108 5.3 File Transfer Protocol (FTP) 132

5.4 Trivial File Transfer Protocol (TFTP) 141

Summary 142

(18)

EN

6. TCP/IP Part IV WWW, HTTP, TELNET

145–190

Introduction 145

6.1 Brief History of WWW 146

6.2 The Basics of WWW and Browsing 146 6.3 Hyper Text Markup Language (HTML) 153 6.4 Web Browser Architecture 180

6.5 Common Gateway Interface (CGI) 182 6.6 Remote Login (TELNET) 185

Summary 189

Review Questions 189

7. JavaScript and AJAX

191–231

Introduction 191 7.1 JavaScript 191 7.2 AJAX 217 Summary 230 Review Questions 230

8. ASP.NET—An Overview

232–278

Introduction 232

8.1 Popular Web Technologies 235 8.2 What is ASP.NET? 235

8.3 An Overview of the .NET Framework 236 8.4 ASP.NET Details 239

8.5 Server Controls and Web Controls 242 8.6 Validation Controls 249

8.7 Database Processing 255 8.8 ActiveX Controls 276

Summary 276

Review Questions 277

9. Java Web Technologies

279–338

Introduction 279

9.1 Java Servlets and JSP 282 9.2 Apache Struts 315

9.3 JavaServer Faces (JSF) 317 9.4 Enterprise JavaBeans (EJB) 325 9.5 Java Applets 332

9.6 Why are Active Web Pages Powerful? 332 9.7 When not to Use Active Web Pages? 333

(19)

N

9.8 Life Cycle of Java Applets 334

Summary 337 Review Questions 337

10. Web Security

339–378

Introduction 339 10.1 Principles of Security 340 10.2 Cryptography 348

10.3 Plain Text and Cipher Text 350 10.4 Digital Certificates 355

10.5 Digital Signatures 357

10.6 Secure Socket Layer (SSL) 366

Summary 377 Review Questions 377

11. Network Security

379–407

Introduction 379 11.1 Firewalls 379 11.2 IP Security 386

11.3 Virtual Private Networks (VPN) 403

Summary 406

Review Questions 406

12. Online Payments

408–435

Introduction 408

12.1 Payments using Credit Cards 408

12.2 Secure Electronic Transaction (SET) 413 12.3 3-D Secure Protocol 425 12.4 Electronic Money 428 12.5 PayPal 433 Summary 434 Review Questions 434

13. Introduction to XML

436–501

13.1 What is XML? 436 13.2 XML versus HTML 442

13.3 Electronic Data Interchange (EDI) 445 13.4 XML Terminology 449

13.5 Introduction to DTD 455 13.6 Document Type Declaration 457 13.7 Element Type Declaration 460

(20)

NE

13.8 Attribute Declaration 464 13.9 Limitations of DTDs 465 13.10 Introduction to Schema 466 13.11 Complex Types 469

13.12 Extensible Stylesheet Language Transformations (XSLT) 472 13.13 Basics of Parsing 487

13.14 JAXP 494

Summary 499

Review Questions 500

14. Web Services and Middleware

502–543

Middleware Concepts 502

14.1 CORBA 508

14.2 Java Remote Method Invocation (RMI) 521

14.3 Microsoft’s Distributed Component Object Model (DCOM) 523 14.4 Web Services 526

14.5 Web Services using Apache Axis—A Case Study 529 14.6 A Web Service Written in Apache Axis using Java 531 14.7 Configuring a Web Service Using Axis 532

14.8 Deploying a Web Service Using Axis 533 14.9 Testing the Web Service 534

14.10 Cleaning Up and Un-Deploying 539 14.11 Enabling the SOAP Monitor 540

Summary 542 Review Questions 542

15. Wireless Internet

544–578

Introduction 544 15.1 Mobile IP 544 15.2 Mobile TCP 549

15.3 General Packet Radio Service (GPRS) 550 15.4 Wireless Application Protocol (WAP) 552

Summary 576

Review Questions 577

Appendix

579–597

(21)

1

1

+D=FJAH

Networking Protocols

and OSI Model

INTRODUCTION

Protocol is nothing but a convention. We encounter this term quite often in newspapers when describing the

meeting between the leaders of two nations. To signify that “Everything is okay and the train can start” by a green flag is also a protocol. When we write a letter, we follow a certain protocol. The place where we write the address, afix the stamp, write the name of the recipient, and the way we begin with the pleasantries and write “Yours lovingly” or “Yours sincerely”, etc., all define a protocol.

Protocols can and normally have layers hidden in them, if we look into them a little carefully. A good example is human conversation, in general, and over the telephone, in particular. Figure 1.1 depicts these layers. We will take this example and describe the exact steps to learn about these layers. An interesting point is that we do this without knowing that we use protocols. While studying this, we will encounter a number of terms, which are also used in the computer networks.

We will assume that two persons X and Y want to have a conversation over the telephone about the World War and we will also assume that each one is taking down what the other has to say. Thus, we will term this World War as an idea. Normally, the conversation takes place in terms of several messages from either end, hopefully one after the other. A message is a block of statements or sentences. A message could also consist of only one word such as okay or yes, denoting a positive acknowledgement (ACK) of what has been heard or received. A message could also mean a negative acknowledgement (NAK) or request for repeating such as Come again or, Pardon me or, Can you repeat please, etc. Remember that this can happen both ways. For instance, a typical conversation could be as follows.

X: In World War II, the Allied countries should have…. However, they did not do so because of the climatic conditions. In addition, they did not have enough ammunition.

Y: Yeah, I agree.

X: Also, if you consider the factor of the atomic energy....

Y: No, but, I think, there is another angle to it. If you consider the boundary between the two countries, it will be obvious. There is also a great book on the subject.

X: Come again.

Y: No, but I think there is another angle to it. X: Yeah, but that is not the only factor... Y: Could you repeat, please?

(22)

2

Fig. 1.1 Layers in human communication

Therefore, at the level of ideas, both X and Y feel that they are discussing an idea such as World War. However, in reality the conversation consists of a number of messages from both sides, as discussed before. Therefore, at a lower level, the view would be that a number of messages are sent at both ends. The protocol at this level decides what denotes a positive acknowledgement, what denotes a negative acknowledgement, etc., for the entire message.

A message could be too long. In this case, it may not be wise for X to speak for half an hour, only to receive a request for repeating the message in the end from Y. It is, therefore, prudent to send/receive positive or negative acknowledgements after each sentence in a message by Yeah, Okay or Come again, etc. A sentence is like a packet in the computer parlance. In this case also, one could decide a protocol to necessarily send a positive or negative acknowledgement after each sentence. If that is the case, the sender (the speaker) X will not proceed to the next statement until he hears some form of acknowledgement, or otherwise, and, in fact, repeat the statement if he receives a negative acknowledgement before proceeding. An alternative to this would be a time-out strategy. The speaker X would speak a sentence and wait for some time to hear any kind of acknowledgement. If he does not hear anything back, he assumes that the previous statement was not received properly, and therefore, repeats the sentence. A form of sliding window would mean speaking and acknowledging multiple sentences simultaneously, may be 3 or 4 at a time. This is via media between acknowledging each

(23)

3 sentence or the full message. We are not aware of this, but we actually follow all these protocols in daily conversations.

Apart from this error control, we also take care of flow control. This refers to the speed mismatch between the speaker and the listener. If the speaker speaks too fast, the listener says Go slow or Please wait if he is taking down the message. In the world of computers, if the receiving computer is not fast enough, or if its memory buffer is full, which cannot hold any further data, it has to request the sender to wait. This is called as flow control. Thus, the data link control layer is responsible for the error control at the sentences level, and the flow control. This layer also decides who is going to speak, when, by a convention, or in brief, who has a control of the medium (in this case, the telephone line). This is called as media access control. This function of media access control becomes necessary, because, the telephone line is shared between X and Y, and both can and usually do speak simultaneously, causing chaos. In fact, it can so happen that after a pause, thinking that the other party is waiting to hear from you, you may start speaking. However, exactly at the same time, the other party also can start speaking, thinking that you want the other party to speak. This results in a collision. The conversation gets mixed up normally, and both the parties realize about this collision and stop talking for a while (unless it is a married couple!). Hopefully, the parties will pause for different time intervals, thereby avoiding collision. Otherwise, this process repeats. When to start speaking, how long to wait after the collision before restarting, etc., are typical conventions followed at this layer. These are the unwritten protocols of the media access control that we follow in our everyday conversation.

In actual practice, we know that when we speak, the electrical signals in the telephone wires change. This is a physical layer. There must be a protocol here, too! This level signifies how the telephone instruments are constructed, the way the telephone wires are manufactured and laid, the signal levels to denote engaged or busy tone, the signal level to generate a ring, the signal levels required to carry human voice, etc. This is a protocol at a physical layer. Obviously, if a telephone and a refrigerator were connected at two ends of a wire, communication would be impossible!

1.1 PROTOCOLS IN COMPUTER COMMUNICATIONS

The same concept of protocols applies equally well to the computer communications. Let us see, how. Let us imagine a network of computers, as shown in Fig. 1.2.

Each computer is called a node. In distributed processing, different parts of databases/files can and normally do reside on different nodes, as per the need. This necessitates transmitting files or messages from one node to the other as and when needed. Let us assume that node A wants to transfer a file X to node D. Node A is not directly connected to node D. This is very common, because connecting every node to every other node would mean a huge amount of wiring.

This is the reason that the concept of store and forward is used in computer networks. First of all, a path is chosen. Let us say that it is A-F-G-D. Using this path, node A sends the file to node F. The computer at F normally has to store this file in its memory buffer or on the disk. This storing is necessary, because the link F-G may be busy at this juncture, or node F may have received a number of messages/files to be sent to other nodes (A, E or G) already, and those could be waiting in a queue at node F. When the link F-G is free and ready for transmitting the file from F to G, node F actually transmits it to the node G. Thus, the node F stores and forwards the file from A to G. This process repeats until the file reaches the destination node D. This procedure demands that each node maintains a memory buffer to store the file, and some software, which controls the queuing of different messages and then transmitting them to the next nodes. This software also will have to take care of error and flow control functions in an error-free manner.

(24)

4

Fig. 1.2 A typical computer network

When the file/message is transmitted, both the nodes (source and destination), as well as all the intermediate nodes, have to agree on some basic fundamentals. For example, what is a bit 1 and what is a bit 0? As we know, ultimately, bit 0 and 1 correspond to some physical property (voltage level 0 = bit 0, voltage level 5 = bit 1, etc.). If there is no understanding between the nodes, the bits could be completely misinterpreted. This understanding or protocol at the physical level is called the physical layer. It deals with things like bits 0 and 1, the communication modes (serial/parallel, simplex/half-duplex/duplex, synchronous/asynchronous, etc.).

How does the next node find out whether the file or the message was received correctly or not? And also, how does that node react if it finds an error? There are several methods to detect an error in transmission. Obviously, we will need to compute the Cyclic Redundancy Check (CRC) for the whole file, append it with the data, re-compute the CRC on the received data portion at the destination, and compare the received and computed CRC to ensure that they are the same.

There are many ways in which the positive or negative acknowledgement can be sent by the receiving node to the source node. If no error is detected, the receiving node can send a positive acknowledgement back, meaning that everything is OK. However, if an error is detected, the receiving node can either send a negative acknowledgement or choose not to send anything. The latter is called time out. In this method, the source node can wait for some time for the positive acknowledgement and having not received it in a specific time, conclude that the file has not been received OK at the destination and then send it again. This is a good method, except that when the source node starts sending the file again, the positive acknowledgement (OK message) from the receiving node could have been already travelled half way to the source node. When this acknowledgement is received at the source node, it will be too late for the source node! The file/message would have been already sent twice to the destination node! There is normally a protocol to handle such a situation (e.g., the receiving node discards the second copy of the file). A surer way is to definitely send either OK or NOT OK message back, and not to use the time out method, i.e., wait until either a positive or negative acknowledgement is received. However, this entails long waits because these messages themselves could take long time to travel, due to the network traffic. The overall network efficiency in this case reduces, as the source node has to wait until it receives some acknowledgement.

All these functions of error detection, acknowledgements and retransmissions are clubbed under a name error control, and constitute an important part of the communications software, i.e., the data link layer in the

(25)

5 networking terminology, residing at every node, i.e., the source, destination as well as all the intermediate nodes, because the message has to reach correctly to the next node first, before it reaches the destination node correctly. The data link layer also takes care of flow control and the speed mismatch between any two adjacent communicating computers. If the sending computer sends data too fast, it can get lost at the destination. The speeds, therefore, have to be continuously adjusted or monitored. This is called as flow control.

If an error is detected, the entire file will have to be retransmitted. If the file size is large, the probability of an error is higher, as well as the time that it will take for retransmission. Also, the chances of an error in a retransmission are higher. This is the reason that large messages (such as a file) are broken down in smaller chunks or blocks. These are called packets. To avoid error, data is sent in packets also when two pairs of computers want to use a shared transmission line. Imagine that computer A wants to send a big file of 10 MB to computer D by a route A-F-G-D. Also, at the same time, computer F wants to send a small file of 2 KB to computer G. Further, suppose that the transmission of the big file over the link F-G starts momentarily ahead of the smaller file transmission over F-G. Assuming that only one pair of computers can use one transmission line exclusively, the smaller transmission will have to wait for a long time before the bigger transmission gets over. Thus, a bigger transmission simply can hold up smaller transmissions, causing great injustice. Thus, it is better that each communication party breaks down their transmission into packets and takes turn to send down packets. Thus, both the files are broken down into packets first. At node F, a packet from the big file is followed by a packet from the small file, etc. This is called as Time Division Multiplexing, (TDM). At the other end (G), the smaller file is reassembled and used, whereas the packets for the bigger file are separated, stored and forwarded to the node D.

Obviously, every packet will have to have a header containing source address, destination address, packet number and CRC. The destination address is used for forwarding or routing the packet to the next node, and ultimately to the final destination. The packet number helps in reassembling the packets in case they reach the destination out of sequence. The CRC is used for error control.

There are two ways in which the path can be chosen. One is the virtual circuit approach, and the other is the datagram approach. In a virtual circuit, the path is chosen in the beginning and all the packets belonging to the same message follow the same route. For instance, if a route A-F-G-D is chosen to send the file from A to D, all the packets of that file will traverse by the same route. At D, therefore, they will be received in the same order only, thereby avoiding the function of re-sequencing. This is because, even if packet 2 is received erroneously by node G from node F, node G will ask for its retransmission. Node F will then retransmit packet 2, and before sending packet 3, wait until making sure that node G has received packet 2 without any error. It will send packet 3 only after ensuring this. All this necessitates maintaining many buffers at different nodes for storing and forwarding the packets. As against this, in datagram, the entire circuit is not pre-determined. A packet is sent to the next node on the route, which is the best at that time, and will take the packet to the ultimate destination.

Choosing a path or routing is not a simple task by any stretch of imagination. Remember, each node is receiving many packets from different nodes to be temporarily stored and then forwarded to different nodes. For instance, node F in Fig. 1.2 can have packets received from A to be forwarded to E or G, or meant for itself. It can also have packets received from E to be forwarded to A or to G, or to D via G, or the packets meant for itself. Node F can be receiving packets from node G meant for nodes A, E or for itself. In addition, node F itself will want to send various packets to different nodes. Therefore, the buffer of node F will contain all these packets. The source and destination addresses come handy in keeping track of these packets. We can imagine a buffer memory at node F, where all these packets are stored and then a scheduling algorithm picks them up one by one and sends or forwards them based on the destination node and the route chosen.

(26)

6

Now, to send the data from node A to node D, should it be sent via A-F-G-D or A-B-C-D or A-E-D or A-F-E-D or A-F-G-E-D or A-F-E-G-D? Apparently, A-E-D seems to be an obvious answer, as AED appears to be the shortest route. However, looks can be deceptive. Node E’s buffer may be full at a given moment due to a message to be sent to node A from nodes G or D. If we follow a First Come First Serve (FCFS) method for forwarding the messages, there will be a long wait before our message received from A will be forwarded to D.

This is an example of network congestion. These congestion levels have to be known before the route is chosen. Also, a path may be required to be chosen from one node to any other node. Therefore, this information about congestion or load on all the nodes and all the lines should be available at every node. Each node then has algorithms to choose the best path at that moment. This again is an important part of communications software, the network layer in the OSI parlance, residing at every node.

Note that although we have shown the network to be consisting of only the computers called as nodes, in real life, it is not so simple. Since these computers in a network are used for specialized purposes (such as running an application program or serving files on request), the job of routing packets from the sending computer to the receiving computer is handled by dedicated computers called as routers. A router is a special computer that has the sole job of routing packets between the various computers on a network. It decides which packet to forward to which next node, so that it can ultimately reach the final destination. The necessary routing software runs inside the router to carry out this routing process. Therefore, although we have not shown for the sake of simplicity, in real life, we would have a number of routers connecting the various portions of a network to each other.

In the case of the datagram approach, different packets belonging to a single message can travel by different routes. For a packet, a decision is taken about the next node to which it should be sent. For instance, at a given moment, the node F as well as the line A-F could have the least congestion (as compared to A-E and A-B). Therefore, the packet is sent via the route A-F. It takes a finite time for the packet to reach the node F, and then for the node F to check the CRC and send back the acknowledgement. Only after this, the node A decides to send the next packet. However, during this time interval, a number of packets could have arrived at node F from node E, to be forwarded to either A or G, or the ones meant for F itself. Therefore, the congestion at node F may have increased. Hence, the next packet could be sent by node A via the route A-E to be ultimately forwarded to D.

Therefore, different packets belonging to a message may not travel by a given pre-determined route. In this case, it is possible that packet 3 may arrive before packet 2 at node D. This necessitates the function of re-sequencing and making sure that the entire message has been received without error. One could think of a CRC for the entire message level to be recomputed and matched before acknowledging the error-free receipt of the whole message. This packet consisting of the acknowledgement for the entire message will travel from the destination node to the source node. This function of ensuring in sequence and error-free receipt of the entire message and its acknowledgement retransmission is again a part of the communication software, typically the Transport Layer in the networking parlance. It is clear that in case of the virtual circuit approach, there is a guarantee that packets will arrive at the destination in the order that they were sent, because, in this case, a route (also called as a Virtual Circuit Number—VCN) is chosen in the beginning itself. It is used for all the packets belonging to that message. This is also why the packet in the virtual circuits does not require the full source and destination addresses. It only requires the Virtual Circuit Number (VCN). The routing tables maintained at the various nodes maintain the VCN and the next node entries. They are sufficient for routing. The datagram approach demands that the packet carry the source and destination node addresses, which can be utilized for routing, and finding the next node each time by using routing algorithms.

(27)

7 We will realize that there are two types of protocols. Some protocols are necessary between any two adjacent nodes and generally they operate at a packet level, i.e., they make sure that the next adjacent node receives a packet or frame correctly. In the networking parlance, physical, data link and network layers are the layers, which belong to this category. The other type of protocols is between the end points, i.e., the source node and the destination node (nodes A and D in this example). They make sure a connection is established between these two points, sessions started and terminated properly, messages (and not packets) are sent/received and acknowledged properly, and necessary data encryption/decryption or compression/decompression and code conversions/translations are done before handing the message over to the destination node. These are typically transport, session, presentation, and application layers in the networking parlance. Table 1.1 depicts this (we apologize for a forward reference).

Actually, communication software dealing with algorithm for error/flow control, routing, data compression, encryption, etc., could have been coded in one single program. However, such a program would have been difficult to code and maintain. It is for this reason that this function is divided into its logical parts or modules called as layers. Using this concept, many manufacturers started coding their communication software in different number of layers. Thus, there was chaos.

Finally, the standards body ISO decided that there has to be a standard for this communication so that different computers by different manufacturers could communicate with one another very smoothly. They came up with a seven-layer architecture known as Open System Interconnection (OSI). Regardless of the number of layers, all these functions described above have to be taken care of by any communication software, and this software has to reside at every node. Today, OSI has become a standard with which you can compare, though very few have actually implemented the OSI layers exactly as they are described in the standard. Therefore, OSI is actually a reference model. We will study it from this perspective.

1.2 THE OSI MODEL

1.2.1 Introduction

The OSI model is structured on seven layers, described in Table 1.1.

Table 1.1 OSI Layers

Layer Number Layer Name

1 (Lowest) → Physical 2 Data Link 3 Network 4 Transport 5 Session 6 Presentation 7 (Highest) → Application

(28)

8

Fig. 1.3 OSI Layers arranged in a hierarchy

Let us now study Fig. 1.4. Suppose host X wants to send a message to another host Y. This message would travel via a number of intermediate nodes. These intermediate nodes are concerned with the lowermost three OSI layers, i.e., physical, data link and network, as shown in Fig. 1.4. The other four layers are used by the sender (X) and the recipient (Y) only. Therefore, they are called as end-to-end layers.

Fig. 1.4 Communication between hosts X and Y using the OSI layers

Note that within a host (either X or Y in this example), each layer calls upon the services of its lower layer. For instance, layer 7 uses the services provided by layer 6. Layer 6 in turn, uses the services of layer 5, and so on. Between X and Y, the communication appears to be taking place between the layers at the same level. This

(29)

9 is called as virtual communication or virtual path between X and Y. For instance, layer 7 on host X thinks that it is communicating directly with layer 7 on host Y. Similarly, layer 6 on host X and layer 6 on host Y have a virtual communication connection between them.

It is pointless keeping all the communication software functions in every node. Therefore, the functions of the bottom-most three layers are contained into a special computer called as router. You could, now, construct a network of all routers, and imagine that the nodes are attached to the various routers as shown in Fig. 1.5, which is the same as Fig. 1.2, except that we employ routers.

Fig. 1.5 Routers in a network

All that we said about data link layer functions, routing, etc., is still valid as we can see. When node A wants to send a message to node F, node A sends it to router RA. After this, it gets through a specific route to router RF, and then it reaches the node F.

1.2.2 Layered Organization

The application layer software running at the source node creates the data to be transmitted to the application layer software running at a destination node (remember virtual path?). It hands it over to the presentation layer at the source node. Each of the remaining OSI layers from this point onwards adds its own header to the packet as it moves from this layer (presentation layer) to the bottom-most layer (the physical layer) at the source node. At the lowest physical layer, the data is transmitted as voltage pulses across the communication medium, such as coaxial cable.

That means that the application layer (layer 7) hands over the entire data to the presentation layer. Let us call this as L7 data, as shown in Fig. 1.6. After the presentation layer receives and processes this data, it adds its own header to the original data and sends it to the next layer in the hierarchy (i.e., the session layer). Therefore, from the sixth (presentation) layer to the fifth (session) layer, the data is sent as L7 data + H6, as shown in Fig. 1.5, where H6 is the header added by the sixth (presentation) layer.

(30)

10

Now, for the fifth (session) layer, L7 data + H6 is the input data (see Fig. 1.5). Let us call this together as L6 data. When the fifth (session) layer sends this data to the next, i.e., the fourth (transport) layer, it sends the original data (which is L6 data) plus its own header H5 together, i.e., L6 data + H5, and so on. In the end, the original data (L7) and all the headers are sent across the physical medium.

Figure 1.6 illustrates this process.

Fig. 1.6 Data exchange using OSI layers

1.3 OSI LAYER FUNCTIONS

1.3.1 Physical Layer

The physical layer is concerned with sending raw bits between the source and destination nodes, which, in this case, are adjacent nodes. To do this, the source and the destination nodes have to agree on a number of factors such as voltage which constitutes a bit value 0, voltage which constitutes bit value 1, what is the bit interval (i.e., the bit rate), whether the communication is in only one or both the directions simultaneously (i.e., simplex,

half-duplex or full-duplex), and so on. It also deals with the electrical and mechanical specifications of the

(31)

11

Fig. 1.7 Physical layer between adjacent nodes

To summarize, the physical layer has to take into account the following factors.

Signal encoding How are the bits 0 and 1 to be represented?

Medium What is the medium used, and what are its properties?

Bit synchronization Is the transmission asynchronous or synchronous?

Transmission type Is the transmission serial or parallel?

Transmission mode Is the transmission simplex, half-duplex, or full-duplex?

Topology What is the topology (mesh, star, ring, bus or hybrid) used?

Multiplexing Is multiplexing used, and if so, what is its type (FDM, TDM)?

Interface How are the two closely linked devices connected?

Bandwidth Which of baseband or broadband communication is used?

Signal type Are analog signals used, or digital ones?

1.3.2 Data Link Layer

The data link layer is responsible for transmitting a group of bits between the adjacent nodes. The group of bits is generally called as frame. The network layer passes a data unit to the data link layer. At this stage, the data link layer adds the header and trailer information to this, as shown in Fig. 1.8. This now becomes a data unit to be passed to the physical layer.

The header (and trailer, which is not shown, but is instead assumed to be present) contains the addresses and other control information. The addresses at this level refer to the physical addresses of the adjacent nodes in the network, between which the frame is being sent. Thus, these addresses change as the frame travels from

(32)

12

different nodes on a route from the source node to the destination node. The addresses of the end nodes, i.e., those of the source and destination nodes, are already a part of data unit transferred from the network layer to the data link layer. Therefore, it is not a part of the header and trailer added and deleted at the data link layer. Hence, they remain unchanged as the frame moves through different nodes from the source to the destination.

Fig. 1.8 Data link layer between adjacent nodes

Let us illustrate this by an example. Let us refer to Fig. 1.2. Let us imagine that node A wants to send a packet to node D. Let us imagine that we use the datagram approach. In this case, the logical (i.e., IP) addresses of nodes A and D, say ADDL (A) and ADDL (D) are the source and destination addresses. The data unit passed by the network layer to the data link layer will contain them. The data unit will look as it is shown in Fig. 1.9. Let us call this as DN.

Fig. 1.9 Data unit at the network layer (DN)

When this data unit (DN) is passed from the network layer at node A to the data link layer at node A, the following happens.

(i) The routing table is consulted, which mentions the next node to which the frame should be sent for a specific destination node, which is node D in this case. Let us imagine that the next node is F, based on the congestion conditions at that time, i.e., the path A-F is selected.

(ii) At this juncture, the data link layer at node A forms a data unit, say DD, which looks, as shown in Fig. 1.10. We will notice that DD has encapsulated DN and added the physical addresses of A and F (i.e., those of the NICs of A and F) as ADDP (A) and ADDP (F) to it.

(iii) Using the physical addresses of adjacent nodes A and F, the packet moves from node A to node F after performing the flow control functions, as discussed later (i.e., checking if node F is ready to accept a frame from A and at what data rate, etc.). Here, the packet is passed on from the data link layer to the network layer of node F after performing the error-control function (i.e., verifying that the packet is error-free). Here, ADDP (A) and ADDP (F) are removed and DN is recovered. Now, this DN needs to

(33)

13 be sent to the next hop to reach node D. For this, the final destination address, i.e., ADDL (D), is extracted from DN. The frame now has to be sent from node F to node D.

Fig. 1.10 Data unit at the data link layer (DD) at node A

(iv) Again, the routing algorithm is performed at node F using ADDR (D) as the final destination, and the congestion conditions, etc., and a path is chosen. Let us say that the chosen path is FG.

(v) The network layer at node F passes DN to the data link layer at node F. Here, the physical addresses of F and G are added to form the data unit at the data link layer at node F, as shown in Fig. 1.11.

Fig. 1.11 Data unit at data link layer (DD) at node F

(vi) This continues until the data unit at data link layer DD reaches node D. There again, the physical addresses are removed to get the original DN, which is passed on to the network layer at node D. the network layer verifies ADDL (A) and ADDL (D), ensures that the packet is meant for itself, removes these addresses, and sends the actual data to the transport layer at node D.

The data link layer also performs the flow control function. Based on the speeds of the CPUs, transmission, buffer size and congestion condition, it is determined whether the frame/packet can be sent to the adjacent node, and if so, at what speed. If it can be sent, the node is ready to send the data. However, we have to make sure that the medium is free to carry the frame/packet.

If the connection is a multipoint type (i.e., the medium is shared), then the problem of who should send how much data at what times, has to be solved. This problem typically arises in Local Area Networks (LANs), and is solved by the Media Access Control (MAC) protocol. Therefore, in LANs, the data ink layer is split into two sub-layers, as shown in Fig. 1.12. In this case, LLC takes care of normal data link layer functions, such as error control and flow control, etc.

References

Related documents

Physical Layer Data Link Layer Network Layer Transport Layer Session Layer.. Presentation Layer

The seven layers of the ISO OSI reference model, shown in Figure 3.3 are: application layer, presentation layer, session layer, transport layer, network layer, data link layer

Network Link Transport Application Presentation Session Transport Network Link Physical.. The 7-layer OSI Model The

Physical Layer Data Link Layer Network Layer Transport Layer Session Layer.. Presentation Layer

• OSI 7 layers 1 - The Physical Layer 2 - The Data Link Layer 3 - The Network Layer 4 - The Transport Layer 5 - The Session Layer 6 - The Presentation Layer 7 - The Application Layer.

Network Layer Transport Layer Session Layer Presentation Layer Application process Application Layer Network Protocol Data Link Protocol. Physical Protocol Physical Layer

Attacks on Different Layers Application Presentation Session Transport Network Data Link Physical Application Transport Internet Network Access Layer 2: PPTP, Token

Network Layer Transport Layer Session Layer Presentation Layer Application process Application Layer Physical Layer Data Link Layer. Network Layer Transport Layer Session