0% found this document useful (0 votes)
97 views

Net Centric Programming: Adeel-ur-Rehman

Uploaded by

Ali hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
97 views

Net Centric Programming: Adeel-ur-Rehman

Uploaded by

Ali hasan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 36

Net Centric Programming

Lecture 1
Adeel-ur-Rehman

1
About Me
 Education
 2014, M.S. (Computing), SZABIST
 Work Experiences
 Senior Scientific Officer, National Centre for Physics (NCP).
 Offshore Developer, CERN (European Centre for Nuclear
Research), Switzerland.
 Visiting Faculty, QAU
 Ex-Visiting Faculty Experience
 SZABIST Islamabad Campus, PMAS-AAU Rawalpindi
 TechnoEd institute (ORACLE partner in Pakistan)

2
About Me
 Research Interests
 Programming Languages
 Data Science and AI
 Parallel & Distributed Computing
 Emerging Technologies (DNA, Quantum Computing etc.)
 My Google Scholar Profile (3 Journal, 8 Conference pubs.)
 https://scholar.google.com.pk/citations?
hl=en&user=URH5Zp0AAAAJ
 Contact
[email protected]

3
Course Reference Books
• Recommended Books
– Java Network Programming. 4th ed., E. R. Harold, O’Reilly,
2014. ([JNP])
– Java I/O, E. R. Harold, O’Reilly, ([JIO])
– Java Network Programming and distributed computing, David
Reilly, Michael Reilly (JNPD)
– An Introduction to Network Programming in Java, by Jan
Graba, Springer 2013 ([INPJ-JG])
• Further Readings
– “Java Distributed Computing”, J. Farley, O’Reilly, 1998, ISBN: 1-
56592-206-9 [FAR].
– “Java 2 Developer’s Handbook”, P. Heller and S. Roberts,
Sybex, 1999, ISBN: 0- 7821-2179-9 [Java2H]
– “Java 1.2 Unleashed”, J. Jaworski,: Macmillan Computer
Publishing, 1998, ISBN: 1575213893 [Java2U] 4
Course Contents
Week Book References Lecture Topics
1st JNP • Basic Networking Concepts
• Networks
• IP, TCP and UDP
• Internet
• Client Server Model

2nd & 3rd JNP, JIO • Java I/O


• Sockets, Datagrams
• Java Streams
• Java.io package

4th JNP, JIO • Java.io


• Inputstream, outputstram
• Reader, writers,
• File I/O streams

5th JNP, JNPD • Streams

6th JNP, JNPD • Threads

5
Course Contents
Week Book References Lecture Topics
7th JNP • InternetAddresses
8th • MID Term
9th & 10th JNP • URL, and URI
11th JNP • HTTP
12th • URLConnection
13th JNP, JNPD • Sockets for clients
• Sockets for servers
14th [INPJ-JG, , JNPD] • RMI
• RMI Case Study
15th & 16tt [INPJ-JG, , JNPD] • CORBA

6
Grading Criteria

Marks

Quizzes 10

Assignments 10

Project 05

Midterm Exam 25

Final Exam 50

7
Introduction
• Network programming
– has become a core part of every developer’s toolbox.
– Today, more programs are network aware than aren’t. Besides classic applications like
email, web browsers, and remote login, most major applications have some level of
networking built in.
• Examples:
– IDEs like Eclipse and IntelliJ IDEA communicate with source code repositories like Git
(via GitHub) and Sourceforge.
– Word processors like Microsoft Word open files from URLs.
– Antivirus programs like Norton AntiVirus check for new virus definitions by connecting
to the vendor’s website every time the computer is started.
– Music players like iTunes and related services like Spotify sync and stream media files
– Gamers playing multiplayer first-person shooters like Halo gleefully frag each other in
real time.
– Supermarket cash registers running IBM SurePOS ACE communicate with their store’s
server in real time with each transaction.
– Schedule applications like Microsoft Outlook automatically synchronize calendars
among employees in a company.

8
Introduction
• Java was the first programming language designed from the ground
up for network applications.
• One of the first two real Java applications was a web browser. As
the Internet continues to grow, Java is uniquely suited to build the
next generation of network applications.
• One of the biggest secrets about Java is that it makes writing
network programs easy.
• In fact, it is far easier to write network programs in Java than in
almost any other language.

9
Network

PC client

Internet
Server
Local Area Network

PDA

10
Network
• A network is a collection of:
– Computers
– and other devices
– that can send data to and receive data from one another, more or less in real time.
• Wired network
– electromagnetic waves.
• Wireless networks
– transmit data using radio waves;
• Optical network
– Long distance transmissions are now carried over fiber-optic cables that send light
waves through glass filaments.
• Each machine on a network is called a node. Most nodes are
computers, but printers, routers, bridges, gateways, dumb
terminals, and vending machines (Coca-Cola™) can also be nodes.
• Nodes that are fully functional computers are also called hosts.
– I will use the word node to refer to any device on the network,
– and the word host to refer to a node that is a general-purpose computer. 11
Network Addresses
• Every network node has an address, a sequence of bytes
that uniquely identifies it.
• The more bytes there are in each address, the more
addresses there are available and the more devices that
can be connected to the network simultaneously.
• Ethernet addresses (Mac addresses):
– are attached to the physical Ethernet hardware.
– Manufacturers of Ethernet hardware use preassigned manufacturer codes to make sure there are
no conflicts between the addresses in their hardware and the addresses of other manufacturers’
hardware.

• Internet addresses:
– are normally assigned to a computer by the organization that is responsible for it.
– However, the addresses that an organization is allowed to choose for its computers are assigned
by the organization’s Internet service provider (ISP).
– ISPs get their IP addresses from regional Internet registries.

12
Names
• On some kinds of networks, nodes also have text names
that help human beings identify them such as
“www.elharo.com” or “Beth Harold’s Computer.”
• At a set moment in time, a particular name normally refers
to exactly one address.
• However, names are not locked to addresses.
• Names can change while addresses stay the same; likewise,
addresses can change while the names stay the same.
• One address can have several names and one name can
refer to several different addresses.

13
Packets
• All modern computer networks are packet-switched
networks:
• Data traveling on the network is broken into chunks called
packets and each packet is handled separately.
• Each packet contains information about who sent it and
where it’s going (i.e. source and destination addresses).
• Advantage:
– The most important advantage of breaking data into individually addressed
packets is that packets from many ongoing exchanges can travel on one wire,
which makes it much cheaper to build a network: many computers can share
the same wire without interfering.
• In contrast, when you make a local telephone call within
the same exchange on a traditional phone line, you have
essentially reserved a wire from your phone to the phone
of the person you’re calling (circuit-switching). 14
Protocol
• A protocol is a precise set of rules defining how computers
communicate: the format of addresses, how data is split
into packets, and so on.
• There are many different protocols defining different
aspects of network communication.
• For example, the Hypertext Transfer Protocol (HTTP)
defines how web browsers and servers communicate; at
the other end of the spectrum, the IEEE 802.3 standard
defines a protocol for how bits are encoded as electrical
signals on a particular type of wire.

15
Protocol…(2)
• Open, published protocol standards allow software and
equipment from different vendors to communicate with
one another.
• A web server doesn’t care whether the client is a Unix
workstation, an Android phone, or an iPad, because all
clients speak the same HTTP protocol regardless of
platform.

16
Network Communication
• Sending data across a network is a complex operation that
must be carefully tuned to the physical characteristics of
the network as well as the logical character of the data
being sent.
• Software that sends data across a network must
understand how to avoid collisions between packets,
convert digital data to analog signals, detect and correct
errors, route packets from one host to another, and more.
• The process is further complicated when the requirement
to support multiple operating systems and heterogeneous
network cabling is added.

17
Network Layers
• To hide most of this complexity from the application
developer and end user, the different aspects of network
communication are separated into multiple layers.
• Each layer represents a different level of abstraction
between the physical hardware (i.e., the wires and
electricity) and the information being transmitted.
• In theory, each layer only talks to the layers immediately
above and immediately below it.
• Separating the network into layers lets you modify or even
replace the software in one layer without affecting the
others, as long as the interfaces between the layers stay
the same.

18
Protocols

TCP / IP Layers

19
20
TCP / IP VS OSI Layers

21
TCP / IP Layers
• In this model, applications in the application layer talk
only to the transport layer. The transport layer talks only
to the application layer and the Internet layer.
• The Internet layer in turn talks only to the host-to-
network layer and the transport layer, never directly to
the application layer.
• The host-to-network layer moves the data across the
wires, fiber-optic cables, or other medium to the host-to-
network layer on the remote system, which then moves
the data up the layers to the application on the remote
system.
• For example, when a web browser sends a request to a
web server to retrieve a page, the browser is actually
talking to the transport layer on the local client machine. 22
TCP / IP Layers…(2)
• The transport layer breaks the request into TCP segments,
adds some sequence numbers and checksums to the data,
and then passes the request to the local internet layer.
• The internet layer fragments the segments into IP
datagrams of the necessary size for the local network and
passes them to the host-to-network layer for transmission
onto the wire.
• The host-to-network layer encodes the digital data as
analog signals appropriate for the particular physical
medium and sends the request out the wire where it will
be read by the host-to-network layer of the remote
system to which it’s addressed.

23
TCP / IP Layers…(3)
• The host-to-network layer on the remote system decodes the
analog signals into digital data, then passes the resulting IP
datagrams to the server’s internet layer.
• The internet layer does some simple checks to see that the IP
datagrams aren’t corrupt, reassembles them if they’ve been
fragmented, and passes them to the server’s transport layer.
• The server’s transport layer checks to see that all the data arrived
and requests retransmission of any missing or corrupt pieces.
• This request actually goes back down through the server’s internet
layer, through the server’s host-to-network layer, and back to the
client system, where it bubbles back up to the client’s transport
layer, which retransmits the missing data back down through the
layers. This is all transparent to the application layer.

24
TCP / IP Layers…(4)
• Once the server’s transport layer has received enough
contiguous, sequential datagrams, it reassembles them
and writes them onto a stream read by the web server
running in the server application layer.
• The server responds to the request and sends its response
back down through the layers on the server system for
transmission back across the Internet and delivery to the
web client.

25
Host to-Network Layer
• The hidden parts of the network belong to the host to-network
layer (also known as the link layer, data link layer, or network
interface layer).
• The host-to-network layer defines how a particular network
interface—such as an Ethernet card or a WiFi antenna—sends IP
datagrams over its physical connection to the local network and the
world.
• The part of the host-to-network layer made up of the hardware that
connects different computers (wires, fiber-optic cables, radio waves,
or smoke signals) is sometimes called the physical layer of the
network.
• As a Java programmer, you don’t need to worry about this layer
unless something goes wrong—the plug falls out of the back of your
computer, or someone drops a backhoe through the T–1 line
between you and the rest of the world.
• In other words, Java never sees the physical layer. 26
Host to-Network Layer…(2)
• The primary reason you’ll need to think about the host-to-network
layer and the physical layer, if you need to think about them at all, is
performance.
• For instance, if your clients reside on fast, reliable fiber-optic
connections, you will design your protocol and applications
differently than if they’re on high-latency satellite connections
• You’ll make still different choices if your clients are on a 3G data
plan where they’re charged by the byte for relatively low
bandwidth.
• And if you’re writing a general consumer application that could be
used by any of these clients, you’ll try to hit a sweet spot
somewhere in the middle, or perhaps even detect and dynamically
adapt to individual client capabilities.
• However, whichever physical links you encounter, the APIs you use
to communicate across those networks are the same. What makes
that possible is the internet layer. 27
Internet Layer
• A network layer protocol defines how bits and bytes of
data are organized into the larger groups called packets,
and the addressing scheme by which different machines
find one another.
• The Internet Protocol (IP) is the most widely used network
layer protocol in the world and the only network layer
protocol Java understands.
• In fact, it’s two protocols: IPv4, which uses 32-bit
addresses, and IPv6, which uses 128- bit addresses and
adds a few other technical features to assist with routing.
• IPv4 still accounts for more than 90% of Internet traffic,
but IPv6 is catching on fast and may well surpass IPv4 in
near future.
28
Internet Layer…(2)
• Although these are two very different network protocols
that do not interoperate on the same network without
special gateways and/or tunneling protocols, Java hides
almost all of the differences from you.
• In both IPv4 and IPv6, data is sent across the internet
layer in packets called datagrams.
• Each IPv4 datagram contains a header between 20 and 60
bytes long and a payload that contains up to 65,515 bytes
of data. (In practice, most IPv4 datagrams are much
smaller, ranging from a few dozen bytes to a little more
than eight kilobytes.)
• An IPv6 datagram contains a larger header and up to four
gigabytes of data.
29
Internet Layer…(3)

30
Internet Layer…(3)

• Second purpose of the Internet layer is to enable different types of Host-to-Network layers
to talk to each other.
• Internet routers translate between WiFi and Ethernet, Ethernet and DSL, DSL and fiber-
optic backhaul protocols, and so forth.
• Without the internet layer, each computer could only talk to other computers that shared
its particular type of network.
• The internet layer is responsible for connecting heterogenous networks to each other
using homogeneous protocols. 31
Transport Layer
• Raw datagrams have some drawbacks.
1. Most notably, there’s no guarantee that they will be delivered.
2. Even if they are delivered, they may have been corrupted in
transit.
3. The header checksum can only detect corruption in the header,
not in the data portion of a datagram.
4. Finally, even if the datagrams arrive uncorrupted, they do not
necessarily arrive in the order in which they were sent.

32
Transport Layer…(2)
• Individual datagrams may follow different routes from
source to destination.
• Just because datagram A is sent before datagram B does
not mean that datagram A will arrive before datagram B.
• The transport layer is responsible for ensuring:
– that packets are received in the order they were sent
– that no data is lost or corrupted.
– If a packet is lost, the transport layer can ask the sender to
retransmit the packet.
• IP networks implement this by adding an additional
header to each datagram that contains more information.
• Protocols of transport layer:
– TCP:
– UDP: 33
Application Layer
• The layer that delivers data to the user is called the
application layer.
• The three lower layers all work together to define
how data is transferred from one computer to
another.
• The application layer decides what to do with the
data after it’s transferred.
• For example, an application protocol like HTTP (for
the World Wide Web) makes sure that your web
browser displays a graphic image as a picture, not
a long stream of numbers.
34
Application Layer…(2)
• The application layer is where most of the network
parts of your programs spend their time.
• There is an entire alphabet soup of application
layer protocols: in addition to HTTP for the Web,
there are SMTP, POP, and IMAP for email; FTP,
FSP, and TFTP for file transfer; NFS for file access;
Gnutella and BitTorrent for file sharing; the Session
Initiation Protocol (SIP) and Skype for voice
communication; and many, many more.
• In addition, your programs can define their own
application layer protocols as necessary.
35
End of Lecture 1

36

You might also like