Date post: | 14-Dec-2015 |
Category: |
Documents |
Upload: | donna-curlin |
View: | 213 times |
Download: | 0 times |
3
OSI 7 Layers
• International Standards Organization (ISO) is a multina-tional body dedicated to worldwide agreement on inter-national standards. – Almost three-fourths of countries in the world are
represented in the ISO.
• An ISO standard that covers all aspects of network communications is the Open Systems Interconnection (OSI) model. – It was first introduced in the late 1970s.
• The OSI model is a layered framework for the design of network systems that allows communication between all types of computer systems
4
OSI 7 Layers
• Physical: transmit bits over a medium• Data link: organize bits into a frame• Network: move packets from source to destina-
tion• Transport: provide reliable process-to-process
message delivery• Session: establish, manage, and terminate ses-
sions• Presentation: translate, encrypt and compress
data• Application: allow access to the network re-
sources
7
Physical Layer
• The physical layer consists of the basic network-ing hardware transmission technologies of a net-work
• The bit stream may be grouped into code words or symbols and converted to a physical signal that is transmitted over a hardware transmission medium
8
Data Link Layer
• The data link layer is the protocol layer that transfers data between nodes on the same LAN segment
• Data link layer services– Encapsulation of network layer data packets into
frames– Frame synchronization– Logic link control sublayer
• Error control (ARQ)• Flow control
– Media access control (MAC) sublayer• Multiple access protocols for channel-access control (e.g.
CSMA/CD, CSMA/CA)• Physical addressing (MAC addressing)• LAN switching (packet switching)• Data packet queuing or scheduling
9
Data Link Layer
• Address Resolution Protocol (ARP)– is used to convert an IP address to a MAC ad-
dress
10
Network Layer
• The network layer is responsible for packet forward-ing including routing through intermediate routers
• Protocols– IPv4 / IPv6: Internet Protocol– ICMP: Internet Control Message Protocol– ARP: Address Resolution Protocol– IGMP: Internet Group Management Protocol– PIM-SM: Protocol Independent Multicast Sparse
Mode– PIM-DM: Protocol Independent Multicast Dense
Mode– RIP: Routing Information Protocol
13
Network Layer
• Internet Control Message Protocol (ICMP)– is used by network devices, like routers, to
send error message indicating• for example a requested service is not available or a
host or router could not be reached
– is assigned protocol number 1• But it is still network layer protocol
14
Network Layer
• Internet Control Message Protocol (Cont’d)– Ping
• operates by sending ICMP echo request packets to the target host and waiting for an ICMP echo re-sponse
– Traceroute
15
Transport Layer
• A transport layer provides end-to-end communi-cation services for applications
• Transport layer services– Same order delivery
• Segment numbering
– Reliability• ACK message
– Flow control– Congestion avoidance– Multiplexing
• Ports
17
Transport Layer
• TCP Three Way Handshaking
Connectionopened
PassiveopenActive
open
SYN
UAPRS F
seq: 8000
SYN +ACKUAPRS F
seq: 15000
ack: 8001rwnd: 5000
ACK
UAPRS F
seq: 8000ack: 15001
rwnd: 10000
20
Socket
• A socket is an endpoint of an inter-process com-munication flow across a computer network– A socket address is the combination of an IP
address and a port number• (src_ip, src_port, dst_ip, dst_port)
– Based on this address, sockets deliver incom-ing data packets to the appropriate application process or thread
21
Socket API
• Header files– <sys/socket.h>
• Core Berkely Software Distribution (BSD) socket func-tions and data structures
– <netinet/in.h>• AF_INET and AF_INET6 address families
– <arpa/inet.h>• Functions for manipulating numeric IP addresses
– <netdb.h>• Functions for translating protocol names and host
names into numeric addresses
22
Socket API
• socket(int domain, int type, int protocol)– creates a new socket of a certain socket type
and allocates system resources to it• connect(int fd, struct sockaddr *remote_host,
socklen_t addr_length)– is used on the client side, and assigns a free
local port number to a socket– attempts to establish a new TCP connection
• bind(int fd, struct sockaddr *remote_host, socklen_t addr_length)– is used on the server side, and associates a
socket with a socket address structure
23
Socket API
• listen(int fd, int backlog_queue_size)– is used on the server side, and causes a bound
TCP socket to enter listening state– store requests into a backlog queue
• accept(int fd, struct sockaddr *remote_host, socklen_t *addr_length)– is used on the server side– accepts a received incoming attempt to create
a new TCP connection from the remote client• send(), recv(), write(), read(), sendto(), recvfrom()
– are used for sending and receiving data to/from a remote host
24
Socket API
• socket(int domain, int type, int protocol)– Domain
• AF_INET: IPv4• AF_INET6: IPv6
– Type• SOCK_STREAM: reliable stream• SOCK_DGRAM: datagram service• SOCK_RAW: raw protocols
– Protocol• IPPROTO_TCP, IPPROTO_UDP, IPPROTO_RAW, and so
on• The value ‘0’ is used to select a default protocol from
the selected domain and type
25
Socket API
• AF_INET v.s. PF_INET– At socket.h
• /* Protocol families. */• #define PF_INET 2 /* IP protocol family. */• /* Address families. */• #define AF_INET PF_INET
– The current POSIX.1-2008 specification doesn’t specify any of PF_-constants, but only AF_- constants
26
Socket API
• htonl(), htons(), ntohl(), ntohs()– convert values between host and network byte
order– On the i386 the host byte order is LSB first,
whereas the network byte order is MSB first
27
Socket API
• inet_aton(), inet_ntoa()– Internet address manipulation routines– inet_aton() converts the Internet host address,
given in IPv4 dotted notation, to a network bytes
– inet_ntoa() converts the Internet host address, given in network byte order, to a string in IPv4 dotted notation
28
simple_server.c
• Create a socket– SO_REUSEADDR option
• the socket can be successfully bound unless there is a conflict with another socket bound to exactly the same combination of source address and port
• Specify the address
31
host_lookup.c
• Well-known ports– The port numbers in the range from 0 to 1023
are the well-known ports– They are used by system processes that pro-
vide widely used types of network services– Example
• 20: ftp-data• 21: ftp-command• 22: ssh• 23: telnet• 80: http• 443: https
33
host_lookup.c
• gethostbyname(const char *name)– returns a structure of type hostent for the
given host name– name can be either a hostname or an IPv4 ad-
dress in dot notation or IPv6 address in colon notation
35
webserver_id.c
• Get webserver id by using a HTTP HEAD com-mand
• Get host address
• Send a HTTP GET command and filter received data