Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 6401 Introduction to Computer Networks 09/21/2010 Outline - UNIX sockets - A simple client-server program - Project 1 - LAN bridges and learning.

Similar presentations


Presentation on theme: "CS 6401 Introduction to Computer Networks 09/21/2010 Outline - UNIX sockets - A simple client-server program - Project 1 - LAN bridges and learning."— Presentation transcript:

1 CS 6401 Introduction to Computer Networks 09/21/2010 Outline - UNIX sockets - A simple client-server program - Project 1 - LAN bridges and learning

2 CS 6402 Berkeley Sockets Networking protocols are implemented as part of the OS –The networking API exported by most OS’s is the socket interface –Originally provided by BSD 4.1c ~1982. The principal abstraction is a socket –Point at which an application attaches to the network –Defines operations for creating connections, attaching to network, sending/receiving data, closing.

3 CS 6403 Connection-oriented example (TCP) Server Socket() Bind() Client Socket() Listen() Accept() Recv() Send() Connect() Send() Recv() Block until connect Process request Connection Establishmt. Data (request) Data (reply)

4 CS 6404 Connectionless example (UDP) Server Socket() Bind() Client Socket() Recvfrom() Sendto() Bind() Sendto() Recvfrom() Block until Data from client Process request Data (request) Data (reply)

5 CS 6405 Socket call Means by which an application attached to the network int socket(int family, int type, int protocol) Family: address family (protocol family) –AF_UNIX, AF_INET, AF_NS, AF_IMPLINK Type: semantics of communication –SOCK_STREAM, SOCK_DGRAM, SOCK_RAW –Not all combinations of family and type are valid Protocol: Usually set to 0 but can be set to specific value. –Family and type usually imply the protocol Return value is a handle for new socket

6 CS 6406 Bind call Binds a newly created socket to the specified address Int bind(int socket, struct sockaddr *address, int addr_len) Socket: newly created socket handle Address: data structure of address of local system –IP address and port number (demux keys) –Same operation for both connection-oriented and connectionless servers Can use well known port or unique port

7 CS 6407 Listen call Used by connection-oriented servers to indicate an application is willing to receive connections Int(int socket, int backlog) Socket: handle of newly creates socket Backlog: number of connection requests that can be queued by the system while waiting for server to execute accept call.

8 CS 6408 Accept call After executing listen, the accept call carries out a passive open (server prepared to accept connects). Int accept(int socket, struct sockaddr *address, int addr_len) It blocks until a remote client carries out a connection request. When it does return, it returns with a new socket that corresponds with new connection and the address contains the clients address

9 CS 6409 Connect call Client executes an active open of a connection Int connect(int socket, struct sockaddr *address, int addr_len) Call does not return until the three-way handshake (TCP) is complete Address field contains remote system’s address Client OS usually selects random, unused port

10 CS 64010 Send(to), Recv(from) After connection has been made, application uses send/recv to data Int send(int socket, char *message, int msg_len, int flags) –Send specified message using specified socket Int recv(int scoket, char *buffer, int buf_len, int flags) –Receive message from specified socket into specified buffer

11 CS 64011 Socket Implimentation Protocol implementation –Process per protocol Use a separate process to implement each protocol Messages are passes between processes –Process per message Use one process to handle each message/communication Generally more efficient Buffer use –Applications use buffers as do protocols Copies are VERY expensive Message abstraction enables pointers to be used and minimal copies

12 CS 64012 Practical issues – using sockets You have to be very careful when using these calls –Specific data structures and formats –Ports cannot be less than 1024 You can use other tools to see if things are working –Tcpdump –/proc –netstat Client and server can be on same system Think about error handling methods

13 CS 64013CS 64013 Switches and Learning Outline Why bridges (old name for switches)? Example of Layer 2 forwarding How do bridges build their forwarding tables?

14 CS 64014 LAN Properties Exploit physical proximity. –Often a limitation on the physical distance –E.g. to detect collisions in a contention based network Relies on single administrative control and some level of trust. –Broadcasting packets to everybody and hoping everybody (other than the receiver) will ignore the packet Broadcast: nodes can send messages that can be heard by all nodes on the network. –Almost essential for network administration –Can also be used for applications, e.g. video conferencing But broadcast fundamentally does not scale.

15 CS 64015 Building Larger LANs: Bridges Hubs are physical level devices –Don’t isolate collision domains  broadcast issues At layer 2, bridges connect multiple IEEE 802 LANs –BRIDGE is just an old name for a switch –Separate a single LAN into multiple smaller collision domains Reduce collision domain size host Bridge

16 CS 64016 Basic Bridge Functionality Bridges are full fledged packet switches Frame comes in on an interface –Switch looks at destination LAN address –Determines port on which host connected –Only forward packets to the right port –Must run CSMA/CD with hosts connected to same LAN Also between bridge and host connected to a LAN

17 CS 64017 Bridges provide “transparent” functionality Design features: –“Plug and play” capability –Self-configuring without hardware or software changes –Bridge do not impact the operation of the individual LANs Three components of transparent bridges: 1)Forwarding of frames 2)Learning of addresses 3)Spanning tree algorithm

18 CS 64018 Address Lookup/Forwarding Example Address is a 48 bit IEEE MAC address. Next hop: output port for packet Timer is used to flush old entries Size of the table is equal to the number of hosts Flat address  no aggregation No entry  packets are broadcasted Bridge 8711C98900AA 2 AddressNext Hop A21032C9A591 1 99A323C90842 2 301B2369011C 2 695519001190 3 8:15 Info 8:36 8:01 8:16 8:11 1 3 2

19 CS 64019 Learning Bridge tables can be filled in manually (flush out old entries etc) –Time consuming, error-prone –Self-configuring preferred Bridges use “learning”  crucial to their transparent functioning Keep track of source address of packet (S) and the arriving interface (I). –Fill in the forwarding table based on this information –Packet with destination address S must be sent to interface I! host Bridge


Download ppt "CS 6401 Introduction to Computer Networks 09/21/2010 Outline - UNIX sockets - A simple client-server program - Project 1 - LAN bridges and learning."

Similar presentations


Ads by Google